small fixes to make code look better

This commit is contained in:
kbrannen
2023-04-21 00:37:09 -05:00
parent d24a5feb6b
commit 5ae3fe8774

View File

@@ -62,7 +62,6 @@ while (1)
# draw graph
for (my $height=int(-16.0 * ($velocity / 32.0) ** 2.0 + $velocity ** 2.0 / 32.0 + .5) ; $height >= 0 ; $height -= .5)
{
#print "h=$height\n"; # kevin
if (int($height) == $height) { print sprintf("%2d", $height); }
else { print " "; }
$line_pos = 0;
@@ -73,8 +72,10 @@ while (1)
for ($time=0 ; $time <= $T[$i] ; $time += $time_inc)
{
$line_pos += $time_inc;
next if (abs($height - (.5 * (-32) * $time ** 2.0 + $velocity * $coeff_elas ** ($i - 1) * $time)) > .25);
$curr_line = line_tab($curr_line, ($line_pos / $time_inc), "0");
if (abs($height - (.5 * (-32) * $time ** 2.0 + $velocity * $coeff_elas ** ($i - 1) * $time)) <= .25)
{
$curr_line = line_tab($curr_line, ($line_pos / $time_inc), "0");
}
}
$time = ($T[$i + 1] // 0) / 2; # we can reach 1 past the end, use 0 if that happens
last if (-16.0 * $time ** 2.0 + $velocity * $coeff_elas ** ($i - 1) * $time < $height);
@@ -82,11 +83,15 @@ while (1)
print "$curr_line\n";
}
# draw scale
print " .";
print "." x (int($line_pos + 1) / $time_inc + 1), "\n";
print " 0";
my $curr_line = "";
for my $i (1 .. int($line_pos + .9995)) { $curr_line = line_tab($curr_line, int($i / $time_inc), $i); }
for my $i (1 .. int($line_pos + .9995))
{
$curr_line = line_tab($curr_line, int($i / $time_inc), $i);
}
print "$curr_line\n";
print " " x (int($line_pos + 1) / (2 * $time_inc) - 2), "SECONDS\n\n";
}