Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I have a fixed initial velocity V(Vx,Vy,VZ) and a spot on higher ground E(Ex,Ey,Ez), my character must jump up there and he stands still at S(Sx,Sy,Sz). How Can I find the closest point to the character that can make him achieve the jump (same height of the character)?And If the spot Is not available how can check other solutions?

share|improve this question
    
What does "(same height of the character)" mean? That the spot you're looking for must have $z$-coordinate $S_z$? Also, what's the relevance of the information that the character is currently standing still? Presumably the character will change velocity to move to the desired spot, and then also to achieve the initial velocity specified? –  joriki Sep 29 '12 at 15:59
    
Same heght stands for same plane of the character. Let assume that our character is in S(Sx,Sy,Sz) so the right jump spot must be J(Jx,Sy,Jz) so Sy e Jy must be equal on the same plane. The char is still because I must process the force in two steps: first move to jump spot and stop, Then when I say "Yes you can" jump with our fixed V :D –  Kahel Sep 29 '12 at 16:38
add comment

1 Answer

I guess if you wanted to include friction you would have mentioned it, so I'll assume that friction is supposed to be neglected.

Then the character's trajectory will be a parabola. The parabola traverses each $y$ coordinate $0$, $1$ or $2$ times. Thus, it makes no sense to ask for the closest point to the character from which to jump: Either there is no such point, or one such point, or, if there are two such points, we can ask which is closer.

The trajectory of a jump from $(J_x,S_y,J_z)$ with initial velocity $(V_x,V_y,V_z)$ (assuming that your capital 'Z' is a typo) is

$$ \vec r(t)=\pmatrix{J_x\\S_y\\J_z}+t\pmatrix{V_x\\V_y\\V_z}-\frac12gt^2\pmatrix{0\\1\\0}\;. $$

We can determine the time $t_E$ at which the target at $(E_x,E_y,E_z)$ is reached from the $y$ component:

$$ S_y+t_EV_y-\frac12gt_E^2=E_y\;, $$

$$ t_E=\frac{V_y\pm\sqrt{V_y^2+2(S_y-E_y)g}}g\;. $$

These solutions are real iff the kinetic energy $\frac12mV_y^2$ is greater or equal to the potential energy $mg(E_y-S_y)$ required to jump to the higher spot. We can then obtain $J_x$ and $J_z$ from

$$ J_\alpha+t_EV_\alpha=E_\alpha\;, $$

$$ J_\alpha=E_\alpha-t_EV_\alpha=E_\alpha-\frac{V_\alpha}g\left(V_y\pm\sqrt{V_y^2+2(S_y-E_y)g}\right)\;. $$

The easiest way to determine which of the two solutions is closer to $(S_x,S_y,S_z)$ is probably to compute them both and compare the distances.

Note that the $-$ sign yields a solution where the character reaches the target while moving upwards, whereas the $+$ sign yields a solution where the character reaches the target while moving downwards.

share|improve this answer
    
Thanks a lot, will try to implement this and let you know if works. Finger crossed :D –  Kahel Sep 29 '12 at 18:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.