Center of Gravity Calculator
[insert_php]//—————————————-
//cj location behind front wheels = rear wheel weights / overall weight x wheelbase
if($_POST[‘a’] == “lbfw”)
{
$lbfw_rear_wheel_weight = $_POST[‘lbfw_rear_wheel_weight’];
$lbfw_overall_weight = $_POST[‘lbfw_overall_weight’];
$lbfw_wheelbase = $_POST[‘lbfw_wheelbase’];
$lbfw_errors = 0;
if($_POST[‘lbfw_rear_wheel_weight’] == “”) {$lbfw_errors++;}
else { if(!is_numeric($_POST[‘lbfw_rear_wheel_weight’])) {$lbfw_errors++;} }
if($_POST[‘lbfw_overall_weight’] == “”) {$lbfw_errors++;}
else { if(!is_numeric($_POST[‘lbfw_overall_weight’])) {$lbfw_errors++;} }
if($_POST[‘lbfw_wheelbase’] == “”) {$lbfw_errors++;}
else { if(!is_numeric($_POST[‘lbfw_wheelbase’])) {$lbfw_errors++;} }
if($lbfw_errors != 0) {$lbfw_error_msg = “Please enter proper values!”;}
else
{
$total_lbfw = $_POST[‘lbfw_rear_wheel_weight’] / $_POST[‘lbfw_overall_weight’] * $_POST[‘lbfw_wheelbase’];
$view_total_lbfw = ” Location Behind Front Wheels = “.$total_lbfw;
}
}
//—————————————-
//cg location off-center to heavy side = track / 2 – [ weight on light side / overall weight ] x track
if($_POST[‘a’] == “locohs”)
{
$locohs_weight_on_light_side = $_POST[‘locohs_weight_on_light_side’];
$locohs_overall_weight = $_POST[‘locohs_overall_weight’];
$locohs_track = $_POST[‘locohs_track’];
$locohs_errors = 0;
if($_POST[‘locohs_weight_on_light_side’] == “”) {$locohs_errors++;}
else { if(!is_numeric($_POST[‘locohs_weight_on_light_side’])) {$locohs_errors++;} }
if($_POST[‘locohs_overall_weight’] == “”) {$locohs_errors++;}
else { if(!is_numeric($_POST[‘locohs_overall_weight’])) {$locohs_errors++;} }
if($_POST[‘locohs_track’] == “”) {$locohs_errors++;}
else { if(!is_numeric($_POST[‘locohs_track’])) {$locohs_errors++;} }
if($locohs_errors != 0) {$locohs_error_msg = “Please enter proper values!”;}
else
{
$total_locohs = $_POST[‘locohs_track’] / 2 – ($_POST[‘locohs_weight_on_light_side’] / $_POST[‘locohs_overall_weight’]) * $_POST[‘locohs_track’];
$view_total_locohs = ” Center of Gravity = “.$total_locohs;
}
}
//—————————————-
//cg height = [ level wheelbase x raised wheelbase x added weight on scale / distance raised ] x overall weight
//or maybe (level wheelbase x raised wheelbase x added weight on scale) / (distance raised x overall weight)
if($_POST[‘a’] == “hotcog”)
{
$hotcog_level_wheelbase = $_POST[‘hotcog_level_wheelbase’];
$hotcog_raised_wheelbase = $_POST[‘hotcog_raised_wheelbase’];
$hotcog_overall_weight = $_POST[‘hotcog_overall_weight’];
$hotcog_added_weight_on_scales = $_POST[‘hotcog_added_weight_on_scales’];
$hotcog_distance_raised = $_POST[‘hotcog_distance_raised’];
$hotcog_errors = 0;
if($_POST[‘hotcog_level_wheelbase’] == “”) {$hotcog_errors++;}
else { if(!is_numeric($_POST[‘hotcog_level_wheelbase’])) {$hotcog_errors++;} }
if($_POST[‘hotcog_raised_wheelbase’] == “”) {$hotcog_errors++;}
else { if(!is_numeric($_POST[‘hotcog_raised_wheelbase’])) {$hotcog_errors++;} }
if($_POST[‘hotcog_overall_weight’] == “”) {$hotcog_errors++;}
else { if(!is_numeric($_POST[‘hotcog_overall_weight’])) {$hotcog_errors++;} }
if($_POST[‘hotcog_added_weight_on_scales’] == “”) {$hotcog_errors++;}
else { if(!is_numeric($_POST[‘hotcog_added_weight_on_scales’])) {$hotcog_errors++;} }
if($_POST[‘hotcog_distance_raised’] == “”) {$hotcog_errors++;}
else { if(!is_numeric($_POST[‘hotcog_distance_raised’])) {$hotcog_errors++;} }
if($hotcog_errors != 0) {$hotcog_error_msg = “Please enter proper values!”;}
else
{
$total_hotcog = ($_POST[‘hotcog_level_wheelbase’] * $_POST[‘hotcog_raised_wheelbase’] * $_POST[‘hotcog_added_weight_on_scales’] / $_POST[‘hotcog_distance_raised’]) * $_POST[‘hotcog_overall_weight’];
$view_total_hotcog = ” Height of the Center of Gravity = “.$total_hotcog;
}
}
//===============================================
$content = ‘
‘;
$content = addslashes($content);
$content = “\$result=\””.$content.”\”;”;
eval($content);
print stripslashes($result);
[/insert_php]