If the beginning and ending y values are the same, you can describe the parabola using a parametric equation which can be derived in a few steps.
given startingHeight and apexHeight,
y(t) = A(t^2) + B(t) + C
y(0) = startingHeight
y(0.5) = apexHeight
y(1) = startingHeight
y(0) = startingHeight = A*0 + B*0 + C
C = startingHeight
y(t) = A(t^2) + B(t) + startingHeight
y(1) = startingHeight = A + B + startingHeight
0 = A+B
A = -B
y(t) = -B(t^2) + B(t) + startingHeight
y(0.5) = apexHeight = -B(0.25) + B(0.5) + startingHeight
apexHeight = B(0.5 - 0.25) + startingHeight
apexHeight - startingHeight = B(0.25)
B = (apexHeight - startingHeight)/4.0
Now that you know A,B, and C, you can write the method for y:
function y(startingHeight, apexHeight, t){
B = (apexHeight - startingHeight) / 4;
A = -B;
C = startingHeight;
return A*t*t + B*t + C;
}
x and z are easier, since they just increase linearly from start to end:
x(t) = At + B
x(0) = startX
x(1) = endX
x(0) = startX = A*0 + B
B = startX
x(t) = At + startX
x(1) = endX = A*1 + startX
A = endX - startX
x(t) = (endX - startX) * t + startX
(z has a formula identical to x - just replace all x's with z's)
function x(start, end, t){
A = (end - start);
B = start;
return A*t + B;
}
function z(start, end, t){
A = (end - start);
B = start;
return A*t + B;
}
Now you can find the 3d position of the chess piece at time t:
function parabola(xBegin, xEnd, zBegin, zEnd, yStart, yApex, t){
return [x(xBegin,xEnd,t), y(yStart,yApex,t), z(zBegin,zEnd,t)];
}
p2is exactly the apex. You need to consider them just three points in space belonging to a parabola. - John Alexiouy1 == y3- Kevin