Problem Statement:
In this activity you will animate a truck driving forward on a road in one-point perspective. The pre-placed blocks give x-values in terms of the variable x for every shape within a loop that counting by x. The equations for the lines starting at the vanishing point through the midpoint of each ellipse(wheel) is given. Use these equations to write expressions in terms of x for the y-values of the ellipses. Then find equations for the red lines generated by the board blocks, and use these equations to find expressions for the y-values of each of the quadrilaterals.
/* Code generated by RoboBlockly v2.0 */
#include <chplot.h>
double x;
CPlot plot;
// y1 = -5x + 216
// y2 = -3x + 144
// y3 = -0.8181818182x + 65.45454546
// y4 = -1.363636364x + 85.09090909
for(x = 0; x <= 3; x += 0.5) {
//plot.backgroundImage("roadViewWithSun.png");
plot.strokeColor("black");
plot.fillColor("#666666");
// y = -3.75x + 171
plot.ellipse(44 - x * 1.5, (44 - x * 1.5) * -3.75 + 171, 4 - x * 0.75, 6 - x * 1, 0);
// y = -1.578947368x + 92.84210526
plot.ellipse(55 - x * 3.5, (55 - x * 3.5) * -1.578947368 + 92.84210526, 4 - x * 0.75, 6 - x * 1.25, 0);
// y = -4.4x + 194.4
plot.ellipse(41 - x * 0.9, (41 - x * 0.9) * -4.4 + 194.4, 2 - x * 0.75, 3 - x * 0.75, 0);
plot.fillColor("#c0c0c0");
plot.quad(42 - x * 1.1, (42 - x * 1.1) * -5 + 216, 42 - x * 1.1, (42 - x * 1.1) * -3 + 144, 58 - x * 4.1, (58 - x * 4.1) * -0.8181818182 + 65.45454546, 58 - x * 4.1, (58 - x * 4.1) * -1.363636364 + 85.09090909);
plot.quad(42 - x * 1.1, (42 - x * 1.1) * -3 + 144, 40 - double(x)/1.5, (40 - double(x)/1.5) * -3 + 144, 50.5 - x * 2.5, (50.5 - x * 2.5) * -0.8181818182 + 65.45454546, 57.85 - x * 4.1, (57.85 - x * 4.1) * -0.8181818182 + 65.45454546);
plot.quad(40 - double(x)/1.5, (40 - double(x)/1.5) * -5 + 216, 40 - double(x)/1.5, (40 - double(x)/1.5) * -3 + 143.5, 42 - x * 1.1, (42 - x * 1.1) * -3 + 144, 42 - x * 1.1, (42 - x * 1.1) * -5 + 216);
delaySeconds(0.001);
}
plot.label(PLOT_AXIS_XY, "");
plot.grid(PLOT_OFF);
plot.tics(PLOT_AXIS_XY, PLOT_OFF);
plot.axis(PLOT_AXIS_XY, PLOT_OFF);
plot.axisRange(PLOT_AXIS_XY, 0, 72);
plot.ticsRange(PLOT_AXIS_XY, 6);
plot.sizeRatio(1);
plot.plotting();