jamen, helt sikkert. Her er siden:
http://www.fmjq.ca/... du kan bare skrive nogle tilfældige tal. Beregning og canvas er på den efterfølgende side (
http://www.fmjq.ca/result.php).
Her er result.php:
<?php
error_reporting(0);
header("Cache-Control: no-cache");
header("Cache-control: private");
header("Pragma: no-cache");
header("Expires: time() -1");
?><!DOCTYPE html>
<html lang="da">
<head>
<title>FMJQ</title>
<meta charset="utf-8">
<meta name="author" content="FMJQ">
<meta name="description" content="FMJQ">
<meta name="keywords" content="FMJQ">
<meta name="viewport" content="minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">
<link href="
http://fmjq.ca/favicon.ico" rel="shortcut icon" type="image/x-icon">
<link href="
http://fmjq.ca/apple-touch-icon.png" rel="apple-touch-icon" sizes="180x180" type="image/png">
<link href="
http://fmjq.ca/favicon-32x32.png" rel="icon shortcut" sizes="32x32" type="image/png">
<link href="
http://fmjq.ca/favicon-16x16.png" rel="icon shortcut" sizes="16x16" type="image/png">
<link href="weight_balance_calculation.css" rel="stylesheet" type="text/css">
<script src="jquery.min.js"></script>
</head>
<body>
<div id="wrapper">
<!-- BANNER START -->
<header>
<a href="index.php" id="clickable_header"><img alt="Weight & Balance" src="rans_s_12_airaile.png" title="Weight & Balance"></a>
</header>
<!-- BANNER END -->
<br style="clear: both">
<!-- MENU START -->
<nav>
<a href="#" id="responsive_menu_icon"></a>
<ul>
<li><a class="button" href="index.php">Weight & Balance</a>
<li><a class="button" href="specifications.php">Specifications</a>
</ul>
</nav>
<!-- MENU END -->
<!-- CONTENT START -->
<section id="main">
<h1>Weight & Balance</h1>
<?php
session_start();
$Ballast_Weight = $_SESSION['strBallast'];
$Ballast_Arm = 36;
$Ballast_Moment = $Ballast_Weight * $Ballast_Arm;
$Main_Gear_Left_Weight = 259;
$Main_Gear_Left_Arm = 108;
$Main_Gear_Left_Moment = $Main_Gear_Left_Weight * $Main_Gear_Left_Arm;
$Main_Gear_Right_Weight = 243;
$Main_Gear_Right_Arm = 108;
$Main_Gear_Right_Moment = $Main_Gear_Right_Weight * $Main_Gear_Right_Arm;
$Tail_Weight = 27;
$Tail_Arm = 248;
$Tail_Moment = $Tail_Weight * $Tail_Arm;
$Total_Aircraft_Weight = $Ballast_Weight + $Main_Gear_Left_Weight + $Main_Gear_Right_Weight + $Tail_Weight;
$Total_Aircraft_Moment = $Ballast_Moment + $Main_Gear_Left_Moment + $Main_Gear_Right_Moment + $Tail_Moment;
$Total_Aircraft_C_of_G = $Total_Aircraft_Moment / $Total_Aircraft_Weight;
$Pilot_Weight = $_SESSION['strPilot'];
$Pilot_Arm = 85;
$Pilot_Moment = $Pilot_Weight * $Pilot_Arm;
$Passenger_Weight = $_SESSION['strPassenger'];
$Passenger_Arm = 85;
$Passenger_Moment = $Passenger_Weight * $Passenger_Arm;
$Total_Zero_Fuel_Weight = $Pilot_Weight + $Passenger_Weight + $Total_Aircraft_Weight;
$Total_Zero_Fuel_Moment = $Pilot_Moment + $Passenger_Moment + $Total_Aircraft_Moment;
$Total_Zero_Fuel_C_of_G = ($Total_Aircraft_Moment + $Pilot_Moment + $Passenger_Moment + $Total_Zero_Fuel_Moment) / ($Total_Aircraft_Weight + $Pilot_Weight + $Passenger_Weight + $Total_Zero_Fuel_Weight);
$Usable_Fuel_Weight = $_SESSION['strUsable_Fuel'] * 6.35;
$Usable_Fuel_Arm = 103;
$Usable_Fuel_Moment = $Usable_Fuel_Weight * $Usable_Fuel_Arm;
$Total_Take_Off_Weight = $Total_Zero_Fuel_Weight + $Usable_Fuel_Weight;
$Total_Take_Off_Moment = $Total_Zero_Fuel_Moment + $Usable_Fuel_Moment;
$Total_Take_Off_C_of_G = ($Total_Zero_Fuel_Moment + $Usable_Fuel_Moment) / ($Total_Zero_Fuel_Weight + $Usable_Fuel_Weight);
$Max_Take_Off_Weight = 960;
$Min_Take_Off_C_of_G = 99;
$Max_Take_Off_C_of_G = 106;
?>
<!-- DISPLAY CALCULATIONS START -->
<p><span class="error"><?php if ($Total_Take_Off_Weight >= $Max_Take_Off_Weight) echo "Warning: Max Take-Off Weight Exceeded"?></span>
<br><span class="error"><?php if ($Total_Take_Off_C_of_G < $Min_Take_Off_C_of_G || $Total_Take_Off_C_of_G > $Max_Take_Off_C_of_G) echo "Warning: C og G Outside Limit"?></span></p>
<table style="width: 100%">
<tr>
<th>Weight</th>
<th>Arm</th>
<th>Moment</th>
<th>C of G</th>
</tr>
<tr>
<td colspan="4">1. Ballast</td>
</tr>
<tr>
<td class="calculation"><?php echo number_format($Ballast_Weight, 2, '.', ',')?></td>
<td class="calculation"><?php echo number_format($Ballast_Arm, 2, '.', ',')?></td>
<td class="calculation"><?php echo number_format($Ballast_Moment, 2, '.', ',')?></td>
<td> </td>
</tr>
<tr>
<td colspan="4">2. Main Gear - Left</td>
</tr>
<tr>
<td class="calculation"><?php echo number_format($Main_Gear_Left_Weight, 2, '.', ',')?></td>
<td class="calculation"><?php echo number_format($Main_Gear_Left_Arm, 2, '.', ',')?></td>
<td class="calculation"><?php echo number_format($Main_Gear_Left_Moment, 2, '.', ',')?></td>
<td> </td>
</tr>
<tr>
<td colspan="4">3. Right Gear - Left</td>
</tr>
<tr>
<td class="calculation"><?php echo number_format($Main_Gear_Right_Weight, 2, '.', ',')?></td>
<td class="calculation"><?php echo number_format($Main_Gear_Right_Arm, 2, '.', ',')?></td>
<td class="calculation"><?php echo number_format($Main_Gear_Right_Moment, 2, '.', ',')?></td>
<td> </td>
</tr>
<tr>
<td colspan="4">4. Tail</td>
</tr>
<tr>
<td class="calculation"><?php echo number_format($Tail_Weight, 2, '.', ',')?></td>
<td class="calculation"><?php echo number_format($Tail_Arm, 2, '.', ',')?></td>
<td class="calculation"><?php echo number_format($Tail_Moment, 2, '.', ',')?></td>
<td> </td>
</tr>
<tr>
<td class="table_heading" colspan="4">Total Aircraft</td>
</tr>
<tr>
<td class="calculation"><?php echo number_format($Total_Aircraft_Weight, 2, '.', ',')?></td>
<td class="calculation"> </td>
<td class="calculation"><?php echo number_format($Total_Aircraft_Moment, 2, '.', ',')?></td>
<td class="calculation"><?php echo number_format($Total_Aircraft_C_of_G, 2, '.', ',')?></td>
</tr>
<tr>
<td colspan="4"> </td>
</tr>
<tr>
<td colspan="4">5. Pilot</td>
</tr>
<tr>
<td class="calculation"><?php echo number_format($Pilot_Weight, 2, '.', ',')?></td>
<td class="calculation"><?php echo number_format($Pilot_Arm, 2, '.', ',')?></td>
<td class="calculation"><?php echo number_format($Pilot_Moment, 2, '.', ',')?></td>
<td> </td>
</tr>
<tr>
<td colspan="4">6. Passenger</td>
</tr>
<tr>
<td class="calculation"><?php echo number_format($Passenger_Weight, 2, '.', ',')?></td>
<td class="calculation"><?php echo number_format($Passenger_Arm, 2, '.', ',')?></td>
<td class="calculation"><?php echo number_format($Passenger_Moment, 2, '.', ',')?></td>
<td> </td>
</tr>
<tr>
<td class="table_heading" colspan="4">Total - Zero Fuel</td>
</tr>
<tr>
<td class="calculation"><?php echo number_format($Total_Zero_Fuel_Weight, 2, '.', ',')?></td>
<td class="calculation"> </td>
<td class="calculation"><?php echo number_format($Total_Zero_Fuel_Moment, 2, '.', ',')?></td>
<td class="calculation"><?php echo number_format($Total_Zero_Fuel_C_of_G, 2, '.', ',')?></td>
</tr>
<tr>
<td colspan="4"> </td>
</tr>
<tr>
<td colspan="4">7. Usable Fuel (<?php echo number_format($_SESSION['strUsable_Fuel'], 2, '.', ',')?> gal)</td>
</tr>
<tr>
<td class="calculation"><?php echo number_format($Usable_Fuel_Weight, 2, '.', ',')?></td>
<td class="calculation"><?php echo number_format($Usable_Fuel_Arm, 2, '.', ',')?></td>
<td class="calculation"><?php echo number_format($Usable_Fuel_Moment, 2, '.', ',')?></td>
<td> </td>
</tr>
<tr>
<td class="table_heading" colspan="4">Total - Take-Off</td>
</tr>
<tr>
<td class="calculation" <?php if ($Total_Take_Off_Weight >= $Max_Take_Off_Weight) echo "style=\"background: red; color: white\""?>><?php echo number_format($Total_Take_Off_Weight, 2, '.', ',')?></td>
<td class="calculation"> </td>
<td class="calculation"><?php echo number_format($Total_Take_Off_Moment, 2, '.', ',')?></td>
<td class="calculation" <?php if ($Total_Take_Off_C_of_G < $Min_Take_Off_C_of_G || $Total_Take_Off_C_of_G > $Max_Take_Off_C_of_G) echo "style=\"background: red; color: white\""?>><?php echo number_format($Total_Take_Off_C_of_G, 2, '.', ',')?></td>
</tr>
</table>
<!-- DISPLAY CALCULATIONS END -->
<!-- CANVAS START -->
<div style="margin-top: 600px; position: relative">
<div id="canvasArea">
<canvas id="selectedArea" width="102" height="466"></canvas>
<p class="dotted"></p>
<canvas id="myCanvas" width="360" height="600"></canvas>
</div>
</div>
<?php
$x1 = number_format($Total_Zero_Fuel_Weight, 2);
$y1 = number_format($Total_Zero_Fuel_C_of_G, 2);
$x2 = number_format($Total_Take_Off_Weight, 2);
$y2 = number_format($Total_Take_Off_C_of_G, 2);
?>
<script>
// JQUERY METHOD CALLS DRAWING CANVAS.
$(document).ready(function() {
drawVertical(ctx);
drawHorizontal(ctx);
let x1 = <?php echo $x1; ?>;
let y1 = <?php echo $y1; ?>;
let x2 = <?php echo $x2; ?>;
let y2 = <?php echo $y2; ?>;
// DRAWS LINE FROM X1 AND Y1 TO X2 AND Y2
drawLine(ctx, x1, y1, x2, y2);
});
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
// DRAWS HORIZONTAL LINES FOR GRID. COUNTS OF HORIZONTAL LINES ARE 35 AND EVERY INTERVAL IS 15 PIXELS.
function drawHorizontal(ctx) {
for (var i =0; i<=520; i+=15 ) {
let plotYVal = 1000-i/15*10;
ctx.beginPath();
// IF PLOT VALUES ARE 1000, 950, 900 ETC., LINES AND VALUES ARE DISPLAYED BOLD LINE AND FONT.
if (i%75) ctx.lineWidth = 0.5;
else ctx.lineWidth = 2;
ctx.lineCap = "butt";
ctx.moveTo(50, i+25);
ctx.lineTo(350, i+25);
ctx.stroke();
// Y AXIS: INSERT NUMERICAL VALUE.
if (plotYVal%50) ctx.font = "8px Arial";
else ctx.font = "bold 8px Arial";
ctx.textAlign = "end";
ctx.fillText(plotYVal, 40, i+29);
}
}
// DRAWS VERTICAL LINE FOR GRID. COUNTS OF VERTICAL LINES ARE 20 AND EVERY INTERVAL IS 15 PIXELS.
function drawVertical(ctx) {
for (var j=0; j<=300; j+=15) {
if (j!=0) {
let plotXVal = 95+j/15;
ctx.beginPath();
if(j%75)ctx.lineWidth = 0.5;
else ctx.lineWidth = 2;
ctx.lineCap = "butt";
ctx.moveTo(j+50, 25);
ctx.lineTo(j+50, 550);
ctx.stroke();
// X AXIS: INSERT NUMERICAL VALUE.
if (plotXVal%5) ctx.font = "8px Arial";
else ctx.font = "bold 8px Arial";
ctx.fillText(plotXVal, j+45, 570);
}
}
}
// DRAWS LINE BETWEEN TWO POINT.
function drawLine(element, val1, val2, val3, val4) {
if (val1!=="" && val2!=="" && val3!=="" && val4!=="") {
// DECLARES X1, Y1, X2, AND Y2 TO CORRESPOND COMPUTER COORDINATES WITH ORDINARY COORDINATES.
let x1 = (val1-95)*15+50;
let y1 = (1000-val2)*1.5+25;
let x2 = (val3-95)*15+50;
let y2 = (1000-val4)*1.5+25;
element.beginPath();
element.lineWidth=3;
element.lineCap = "round";
element.moveTo(x1, y1);
element.lineTo(x2, y2);
element.strokeStyle = "blue";
element.stroke();
}
}
</script>
<!-- CANVAS END -->
<br style="clear: both">
</section>
</div> <!-- "wrapper" -->
<!-- CONTENT END -->
</body>
</html>