3d parabola (projectile motion) to hit a target on an arbitrary plane

In summary: I'm not sure how to calculate the other parabolas that can hit the target, maybe specifying the rotation angle around the axis that goes through the start and end point?I tried to explain it the best I could, sorry if it wasn't clear enough.
  • #1
Arioch82
16
0
Hi everyone,

I'm a software engineer (sorry in advance if I made/will make some math mistake) and I'm trying to calculate the projectile motion from one point to hit a specific target in a 3d space so that the parabola will lie on an arbitrary plane.

Is several days that I'm trying to achieve this without any luck, I'll be glad for any help... i should really finish this work at the most in a couple of days...

Currently I've got my parabola working without rotations on the Z/X axis so I can hit any target with a parabola lying on a plane perpendicular to XZ (see attachment, the green line is the velocity vector).

What I would love to do is calculate the other parabolas that can hit my target (lying on some other planes) if possible specifying a rotation angle (around the axis that goes through start and end point maybe?)

Hope my problem is clear enough...

Anyway that's what I'm currently using.

having:

[tex]p_0 = (x_0, y_0, z_0) [/tex] as my start (launch) point (input value)

[tex]p_t = (x_t, y_t, z_t)[/tex] as my target point (input value)

[tex]v_0[/tex] velocity (input value)

[tex]g = 9.81[/tex] gravity

[tex]\vec g_v = (0, g, 0)[/tex] gravity vector

[tex]dist_{xz} = \sqrt{(x_t - x_s)^2 + (z_t - z_s)^2}[/tex] distance on the XZ plane

I define:

[tex]x_p = dist_{xz}[/tex]
[tex]y_p = y_t[/tex]

as my "target coordinate on the parabola plane" (sorry don't know how to define it in proper english, hope it will be clear enough looking at the next formula) for the parabola lying on the plane perpendicular to XZ (so gravity on the Y plane)

From here I can calculate the angle to hit my target on that plane starting from:

[tex]y_p = \frac{-g}{2{(v_0\cos\theta)}^2}x_p^2 + x_p\tan\theta + y_0[/tex]

defining:

[tex]\alpha = \frac{-g}{2v_0^2}[/tex]
[tex]\phi = \tan\theta[/tex]

developing:

[tex](\alpha x_p^2)\phi^2 + x_p\phi + (y_0 - y_p + \alpha x_p^2) = 0[/tex]

from here:

[tex]a = \alpha x_p^2[/tex]
[tex]b = x_p[/tex]
[tex]c = y_0 - y_p + \alpha x_p^2[/tex]

[tex]\theta = \arctan{ \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} }[/tex]

from the launch angle [tex]\theta[/tex] I have that the velocity vector is

[tex]v.x = \frac{x_t-x_0}{dist_{xz}} \cos\theta[/tex]

[tex]v.z = \frac{z_t-z_0}{dist_{xz}} \cos\theta[/tex]

[tex]v.y = \sin\theta[/tex]

that I can scale as I like and use hit like:

[tex]projectile(t) = p_0 + \vec v t - \frac{1}{2} \vec g_v t^2[/tex]

to get my motion and hit the target.

Now as I said this works just fine, I've my projectile hitting the target without any problem.
I think I should act on [tex]x_p, y_p[/tex] and on the gravity vector but I cannot get it to work...

Thank you in advance.

edit:
if it's not clear enough please let me know and I'll try to explain myself in a better way, unfortunatly as you could've noticed my mothertongue is not english...

edit2:
modified the first screenshot and added a new one to show the goal the I would like to reach (i got something close to it cheating on the math...)
 

Attachments

  • parabola.jpg
    parabola.jpg
    21 KB · Views: 733
  • parabola2.jpg
    parabola2.jpg
    21.6 KB · Views: 675
Last edited:
Physics news on Phys.org
  • #2
I don't understand your question too much, but I understand it has to do with rotations...
A rotation is a 3x3 matrix. You can obtain it this way. Define the 4 matrices

[tex]I=\left[\begin{array}{ccc}1&0&0\\0&1&0\\0&0&1\end{array}\right]\qquad
A_1=\left[\begin{array}{ccc}0&0&0\\0&0&1\\0&-1&0\end{array}\right]\qquad A_2=\left[\begin{array}{ccc}0&0&-1\\0&0&0\\1&0&0\end{array}\right]\qquad A_3=\left[\begin{array}{ccc}0&1&0\\-1&0&0\\0&0&0\end{array}\right][/tex]

If [tex]\theta[/tex] is the angle of rotation (anticlockwise) and [tex](n_1,n_2,n_3)[/tex] is the axis of rotation (such that [tex]|\mathbf{n}|^2=n_1^2+n_2^2+n_3^2=1[/tex]) then your rotation is

[tex]R=\cos\theta I+(1-\cos\theta)\mathbf{n}^T\cdot\mathbf{n}+\sin\theta(n_1A_1+n_2A_2+n_3A_3)[/tex]

where the dot is the usual row-colums multiplication of matrices. If you apply R to anything, you'll get that thing rotated in the desired way!
 
Last edited:
  • #3
Hi Petr and thank you for your reply.

unfortunatly I've already tried that one and it doesn't give me the desired result.

If you see the new screenshot attached to this post you can notice that in that way (well I'm using quaternions instead of a matrix but it should be the same) the all parabola rotates around the axis while a need the start (point with the axis displayed) and the goal (green sphere at the end of the cyan line) to be fixed so that i can launch my projectile from my start point to hit a specific target as like an "effect/curl" is applied to the parabola.

in the screenshot I'm applying a rotation around the cyan axis, I've also tried around the magenta one (direction on the XZ plane) with similar result.
The first red segment from the start point to the start of the parabola is displayed only because I'm assuming that the start point is always the first point (t=0)
 

Attachments

  • parabola3.jpg
    parabola3.jpg
    17.1 KB · Views: 565
  • #4
I dont' understand what you want to rotate.

With the coordinates of cannon and target, gravitiy and initial velocity fixed there are only two trajectories your projectile can take to hit the target. Both lie in the same plane.

If you want to achieve a trajectory similar to the parabola in your second screenshot, without using rotating projecting of some other external force like wind, etc. this is impossible.
 
  • #5
Yes i would like to achieve a trajectory like the second screenshot.
It's ok to use rotation/projection but when I try to use them my result is like the third screenshot so that it doesn't start on my start point and it doesn't hit the target (like the second screenshot)

I think is because I'm applying the rotation after calculating the point at the time [tex]t[/tex], maybe I should act on the formula before it?
 
  • #6
A parabolic orbit isa Kepler orbit with an eccentricity equal to 1. In short, it's the very rare case which is both an escape or capture orbit.

Orbits with less than escape velocity follow an http://en.wikipedia.org/wiki/Elliptic_orbit" [Broken]...
 
Last edited by a moderator:
  • #7
Whatever force you use I'm pretty sure it will not be a parabola any more, but if you want to rotate your original parabola, Petr matrices are the way to go. Explicitly you have to multiply your coordinates by the following matrix
[tex] R(\theta)=\begin{pmatrix} \Delta z^2\cos \theta + \Delta x^2 & -\Delta z\sin\thet& \Delta x\Delta z(1-\cos\theta)\\ \Delta z\sin\theta& \cos\theta&-\Delta x \sin\theta\\ \Delta x\Delta z (1-\sin\theta)&\Delta x \sin \theta& \Delta x^2\cos\theta + \Delta z^2\end{pmatrix}[/tex]

where [tex]\Delta x,\Delta z[/tex] is the difference in your coordinates normalized to 1, i.e. [tex] \Delta x^2+\Delta z^2=1[/tex]

But to really get a correct trajectory you would first have to specify the mechanism how the make your projectile go back towards the target again.
 
Last edited:
  • #8
thx for the link I'll try to understand as much as i can... as I said I'm not a physicist or a mathematician and all these names/equations are just scaring me :)

I'll be back to you after reading all those links.
Cheers
 
  • #9
betel said:
Whatever force you use I'm pretty sure it will not be a parabola any more, but if you want to rotate your original parabola, Petr matrices are the way to go. Explicitly you have to multiply your coordinates by the following matrix
[tex] R(\theta)=\begin{pmatrix} \Delta z^2\cos \theta + \Delta x^2 & -\Delta z\sin\thet& \Delta x\Delta z(1-\cos\theta)\\ \Delta z\sin\theta& \cos\theta&\Delta x \sin\theta\\ \Delta x\Delta z (1-\sin\theta)&\Delta x \sin \theta \Delta x^2\cos\theta + \Delta z^2\end{pmatrix}[/tex]

where [tex]\Delta x,\Delta z[/tex] is the difference in your coordinates normalized to 1, i.e. [tex] \Delta x^2+\Delta z^2=1[/tex]

But to really get a correct trajectory you would first have to specify the mechanism how the make your projectile go back towards the target again.

hi betel,

thanks for the matrix as I said I've already tried it with quaternions, rotation around the cyan axis in the screenshot (but as you can see it didn't work), I'll give the matrix a try.

What do you mean with "specify the machanism..."?
Because I think that's my main problem (also with the quaternion approach)...
 
  • #10
If you only have gravity acting your cannot shoot your projectile sideways and have it come back to the target.
If you know what is driving the projectile back you can calculate the trajectory. But in general this trajectory will not be a rotated parabola.
 
  • #11
Watch out.
1. I corrected some typos.
2. For the matrix to work the line conneting target and start has to go through the origin. Anyway the calculations will be much easier if you choose the start point to be the origin.
 
  • #12
betel said:
If you only have gravity acting your cannot shoot your projectile sideways and have it come back to the target.
If you know what is driving the projectile back you can calculate the trajectory. But in general this trajectory will not be a rotated parabola.

ok, I think that's fundamental, that's why I was thinking about rotating the gravity vector too so that it always lie on the parabola plane.

Otherwise I do not have any wind or external force but I have no problem to add one.

I don't care if is not exactly a parabola, so now the question is:

how can i calculate the trajectory in that case so to hit my target?

Thanks again
 
  • #13
Then the matrix above will work. If your start point is not the origin you have to shift everything before applying the matrix.
[tex]\vec v' = R(\theta)(\vec v - \vec v_0)+\vec v_0[/tex] and [tex] \vec v_0[/tex] are the coordinates of your start point.
 
  • #14
betel said:
Then the matrix above will work. If your start point is not the origin you have to shift everything before applying the matrix.
[tex]\vec v' = R(\theta)(\vec v - \vec v_0)+\vec v_0[/tex] and [tex] \vec v_0[/tex] are the coordinates of your start point.

ok, I've applied that matrix, is going better as the parabola now starts on my start point but it's still not hitting the target... (see screenshot)

I think now is matter of "recalcute the trajectory" that you were speaking about?
I'm applying the matrix on every [tex]projectile(t)[/tex] not on the formula before to find the angle/velocity_vector to hit the target (or the gravity, or anything else), is it correct, isn't it?

thanks again for your help

edit:
maybe is because:
betel said:
2. For the matrix to work the line conneting target and start has to go through the origin.

in my case is not true?

I'm applying the matrix translating the point to the origin first and then translating it back as you also wrote in your last post
 

Attachments

  • parabola4.jpg
    parabola4.jpg
    15.5 KB · Views: 609
Last edited:
  • #15
I checked it by hand and the parabola should start and end at the correct points
Did you choose (0,0,0) as coordinates for your start point?
Did you use the uptodate version of the matrix? Did you normalize [tex]\Delta x,\Delta z[/tex]?

Your original trajectory will be something like
[tex]\vec v(t)=\begin{pmatrix} x(t)\\0\\z(t)\end{pmatrix}[/tex]
You get your new trajectory if you apply the Rotationmatrix to this vector.
 
  • #16
yes the formulas in my code are exactly the same you wrote here.

the start point doesn't need to be on the origin.
I found out that it works correctly only if the Y for start point and end point are the same and also one of X or Z is the same too (so like X and Y are the same or Z and Y are the same, if it's only Y it won't work)

in the previous screenshot as you can see it's an uphill shoot (the magenta line is the distance on the XZ plane while the cyan one is the axis connecting start and end point)

maybe it depends on the way i calculate the angle/velocity vector? (see first post)
 
  • #17
Any point on the line between the start and the target should be left untouched by the rotation, so the parabolar should always go through the target point.
[tex] R(\theta)=\begin{pmatrix} \Delta z^2\cos \theta + \Delta x^2 & -\Delta z\sin\thet& \Delta x\Delta z(1-\cos\theta)\\ \Delta z\sin\theta& \cos\theta&-\Delta x \sin\theta\\ \Delta x\Delta z (1-\cos\theta)&\Delta x \sin \theta& \Delta x^2\cos\theta + \Delta z^2\end{pmatrix}
\begin{pmatrix} \Delta x\\0\\\Delta z\end{pmatrix}=
\begin{pmatrix}
\Delta x^3 + \Delta z^2\Delta x\cos\theta+\Delta x\Delta z^2(1-\cos\theta)\\
0\\
\Delta z^3 + \Delta x^2 \Delta z\cos\theta+\Delta x^2\Delta z(1-\cos\theta)
\end{pmatrix}=
\begin{pmatrix}
\Delta x(\Delta x^2+\Delta z^2)\\
0\\
\Delta z(\Delta x^2+\Delta z^2)\\
\end{pmatrix}=
\begin{pmatrix}
\Delta x\\
0\\
\Delta z\\
\end{pmatrix}[/tex]

So if your parabola is not hitting the target something is wrong with either the rotation or the parabola. Can you please post the formula for the trajectory of you r projectile? Then we can check if there is something wrong in there.
 
Last edited:
  • #18
Ok, i just noticed a typo in my matrix. the 3,1 component has to be changed to contain [tex]\cos\theta[/tex] instead of sin. The correct matrix is [tex]
R(\theta)=\begin{pmatrix} \Delta z^2\cos \theta + \Delta x^2 & -\Delta z\sin\thet& \Delta x\Delta z(1-\cos\theta)\\ \Delta z\sin\theta& \cos\theta&-\Delta x \sin\theta\\ \Delta x\Delta z (1-\cos\theta)&\Delta x \sin \theta& \Delta x^2\cos\theta + \Delta z^2\end{pmatrix}
\begin{pmatrix} \Delta x\\0\\\Delta z\end{pmatrix}[/tex]
 
  • #19
betel said:
Ok, i just noticed a typo in my matrix. the 3,1 component has to be changed to contain [tex]\cos\theta[/tex] instead of sin. The correct matrix is [tex]
R(\theta)=\begin{pmatrix} \Delta z^2\cos \theta + \Delta x^2 & -\Delta z\sin\thet& \Delta x\Delta z(1-\cos\theta)\\ \Delta z\sin\theta& \cos\theta&-\Delta x \sin\theta\\ \Delta x\Delta z (1-\cos\theta)&\Delta x \sin \theta& \Delta x^2\cos\theta + \Delta z^2\end{pmatrix}
\begin{pmatrix} \Delta x\\0\\\Delta z\end{pmatrix}[/tex]

great now it works with any X and Z but the Y coordinate always needs to be the same between start and target point otherwise it won't hit the target.

what do you mean with

betel said:
Any point on the line between the start and the target should be left untouched by the rotation, so the parabolar should always go through the target point.

my trajectory formula is on the first post.
what I'm doing is applying that matrix to [tex]projectile(t)[/tex].

I've also noticed that you apply it to

[tex]\vec v(t)=\begin{pmatrix} x(t)\\0\\z(t)\end{pmatrix}[/tex]

with Y=0, any reason for that? (my start and target can be at any Y and the shoot can be uphill, downhill, straight...)

and I don't understand in the last couple of post why you're multiplying the matrix with

[tex]\begin{pmatrix} \Delta x\\0\\\Delta z\end{pmatrix}[/tex]

did you mean [tex]\vec v(t)[/tex] translated to the origin with these [tex]\Delta[/tex] or do you actually mean the axis vector used in the matrix?
 
  • #20
Your projectile(t) is a scalar. I don't know how you apply the matrix to it.

The formula works only for y=0, because you stated that start and target lie in the xz plane. So the differenc in the y direction is 0. For any y you can either change your coordinates or calculate the general matrix from Petr's formula.

I write [tex]\Delta x[/tex] to indicate the difference between start and target. Written in the vector this means the axis vector.
 
  • #21
betel said:
Your projectile(t) is a scalar. I don't know how you apply the matrix to it.

The formula works only for y=0, because you stated that start and target lie in the xz plane. So the differenc in the y direction is 0. For any y you can either change your coordinates or calculate the general matrix from Petr's formula.

I write [tex]\Delta x[/tex] to indicate the difference between start and target. Written in the vector this means the axis vector.

projectile(t) is a 3D point.

yes I stated it in the wrong way, I meant any plane parallel to XZ.
I cannot change my coordinates so i need the general matrix form Petr's formula but i don't understand the [tex]n^t n[/tex] part... this is a noob question bu isn't that still a vector?
 
  • #22
[tex] \vec n = \frac{1}{|\vec x_{target}-\vec x_{start}|}(\vec x_{target}-\vec x_{start})[/tex] and [tex]\vec n^T\vec n[/tex] is a 3x3 matrix.

If your target and start always have the same y coordinate you can still use the same formula.
 
  • #23
betel said:
[tex] \vec n = \frac{1}{|\vec x_{target}-\vec x_{start}|}(\vec x_{target}-\vec x_{start})[/tex] and [tex]\vec n^T\vec n[/tex] is a 3x3 matrix.

If your target and start always have the same y coordinate you can still use the same formula.

ok got the full rotation matrix, and it works great!
(at this point i think I've made some naive error on my quaternions test...)

writing the matrix here just as a reference, someone else could need it.

[tex]
R(\theta)=\begin{pmatrix} (1-\cos\theta)\Delta x^2 + \cos\theta & (1-\cos\theta)\Delta y \Delta x + \sin\theta \Delta z & (1-\cos\theta)\Delta z \Delta x - \sin\theta \Delta y \\ (1-\cos\theta)\Delta x \Delta y - \sin\theta \Delta z & (1-\cos\theta)\Delta y^2 + \cos\theta & (1-\cos\theta)\Delta z \Delta y + \sin\theta \Delta x \\ (1-\cos\theta)\Delta x \Delta z + \sin\theta \Delta y & (1-\cos\theta)\Delta y \Delta z - \sin\theta \Delta x & (1-\cos\theta)\Delta z^2 + \cos\theta \end{pmatrix}
[/tex]also I would love to understand why

If [tex]\theta[/tex] is the angle of rotation (anticlockwise) and [tex](n_1,n_2,n_3)[/tex] is the axis of rotation then your rotation is

[tex]R=\cos\theta I+(1-\cos\theta)\mathbf{n}^T\cdot\mathbf{n}+\sin\theta( n_1A_1+n_2A_2+n_3A_3)[/tex]

I know why the [tex]A_1, A_2, A_3[/tex] matrix are like that but I don't know from where do you get that formula.
do you have any quick explanation/link on this?

Thank you

edit:
I solved the bug and removed it from the post
 
Last edited:
  • #24
Usually one chooses rotation matrices by fixing the axis arbitrarily and choosing the angle between 0 and +180. This avoid double covering.
The following relation holds
[tex] R_{\vec n}(\theta)=R_{-\vec n}(180-\theta)[/tex]
This way you can express rotation for bigger angles by smaller ones. Take some sticks and paper and try to visualize it, that helps.

In your case if your want to rotate by more than 180 degrees you have to swap the sign in front of all cosine, i.e. replace [tex]\cos\theta\to-\cos\theta[/tex]

I think this should work. I usually never bother to actually rotate something. Existence is enough for me.
 
  • #25
betel said:
Usually one chooses rotation matrices by fixing the axis arbitrarily and choosing the angle between 0 and +180. This avoid double covering.
The following relation holds
[tex] R_{\vec n}(\theta)=R_{-\vec n}(180-\theta)[/tex]
This way you can express rotation for bigger angles by smaller ones. Take some sticks and paper and try to visualize it, that helps.

In your case if your want to rotate by more than 180 degrees you have to swap the sign in front of all cosine, i.e. replace [tex]\cos\theta\to-\cos\theta[/tex]

I think this should work. I usually never bother to actually rotate something. Existence is enough for me.

Hi betel,

the problem was in my formula, i made a mistake on rewriting everything in the code, it works ok!

I'm struggling to find the minimum velocity to hit the target right now.
I'm trying to work it out from the first formula in the first post but I'm stucked on it... any ideas about that?

Thank you again for your support
 
  • #26
What are you actually computing this for?

Again. Your rotated curves are no valid trajectories for any real world projectile.

You will get the minimal velocity if the projectile hits the target at the top of the parabola.
 
  • #27
betel said:
What are you actually computing this for?

Again. Your rotated curves are no valid trajectories for any real world projectile.

You will get the minimal velocity if the projectile hits the target at the top of the parabola.

yes I know, I'm currently using a trajectory with X and Z component from the rotated curve and Y from the standard (non-rotated) projectile trajectory.
It gives me something more realistic/close to what I'm trying to achieve (is not a standard projectile).

my projectile can hit the target in any point of the parabola, what I'm trying to calculate now is: giving a start and a target point which is the minimum velocity that let me hit the target following the formulas in first post (basically when the determinant in the formula to calculate [tex]\theta[/tex] is 0]
 
  • #28
You can calculate the speed as function of angle. Or vice versa.

You have the following for your trajectory. (for simplicity the start coordinates are at the origin)
[tex] x(t) = v t\cos \phi, z(t) = v t \sin\phi - \frac{1}{2}g t^2[/tex]
Now you can replace t by x in the equation for z. This gives
[tex] z(x) = x \tan\phi - \frac{g}{2v^2\cos^2\phi}x^2[/tex]
Now for the minimal trajectory we want that the projectile just reaches the target, so it hits at the top of the parabola, i.e. the maximum of z w.r.t x is at x=xt. So
[tex]z'(x)= \tan\phi-\frac{g}{v^2\cos^2\phi} x\overset{!}{=}0\quad \LeftRightarrow\quad x = \frac{v^2}{g}\sin\phi\cos\phi[/tex]
If you now set x=xt you have v in terms of [tex]\phi[/tex]
 
  • #29
Forgot the second equation: of course at this point the projectile needs to have reached the hight of the target, so
[tex] z_t= x_t \tan\phi - \frac{g}{2v^2\cos^2\phi}x_t^2[/tex]
Using the previous result
[tex] z_t = \frac{1}{2g}v^2\sin^2\phi, x_t=\frac{v^2}{g}\sin\phi\cos\phi[/tex]
with these two equations you can solve for the minimal velocity and the corresponding angle.
 
Last edited:
  • #30
well the problem is that i don't have the angle...

I was thinking starting from here:

Arioch82 said:
[tex]y_p = \frac{-g}{2{(v_0\cos\theta)}^2}x_p^2 + x_p\tan\theta + y_0[/tex]

defining:

[tex]\alpha = \frac{-g}{2v_0^2}[/tex]
[tex]\phi = \tan\theta[/tex]

developing:

[tex](\alpha x_p^2)\phi^2 + x_p\phi + (y_0 - y_p + \alpha x_p^2) = 0[/tex]

from here:

[tex]a = \alpha x_p^2[/tex]
[tex]b = x_p[/tex]
[tex]c = y_0 - y_p + \alpha x_p^2[/tex]

[tex]\theta = \arctan{ \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} }[/tex]

now my minimum velocity should be when

[tex]b^2 - 4ac = 0[/tex]

doing some substitution

[tex]x_p^2 - 4(\frac{-g}{2v_0^2} x_p^2)(y_0 - y_p + \frac{-g}{2v_0^2} x_p^2)[/tex]

but from here i get the [tex]v_0^4[/tex] and i don't know how to continue to be honest...
 
  • #31
Ok, I'm just going through your explicit calculation but I noticed I misunderstood you at the start concering the coordinates.
My projectile goes from (0,0,0) to (xt,0,zt)
Yours goes from (x1,y1,z1) to (x2,y2,z2) and after your redefinition (0, 0,0) to (xp, yt,0).
 
  • #32
betel said:
Ok, I'm just going through your explicit calculation but I noticed I misunderstood you at the start concering the coordinates.
My projectile goes from (0,0,0) to (xt,0,zt)
Yours goes from (x1,y1,z1) to (x2,y2,z2) and after your redefinition (0, 0,0) to (xp, yt,0).

well actually i think is more something like

(x1,y1) to (xp, yp) where yp = yt anyway, is xp that changes as a "proportion" of x2 and z2

to have everything in a way that works in 3D
 
  • #33
My idea was wrong. Easy to check in the even leveled case.

Yours seems to be correct though. Just solve the quadratic for v^2 and then do the square root again and you get.

[tex] v= \sqrt{g(y_p-y_0+\sqrt{(y_0-y_p)^2+x_p^2})}[/tex]

You would have really made your life much more easy if you had chosen (0,0,0) as the start and zt=0. It is much faster to later transform the coordinate system.
 
Last edited:
  • #34
Arioch82 said:
Hi Petr and thank you for your reply.

unfortunatly I've already tried that one and it doesn't give me the desired result.

If you see the new screenshot attached to this post you can notice that in that way (well I'm using quaternions instead of a matrix but it should be the same) the all parabola rotates around the axis while a need the start (point with the axis displayed) and the goal (green sphere at the end of the cyan line) to be fixed so that i can launch my projectile from my start point to hit a specific target as like an "effect/curl" is applied to the parabola.

in the screenshot I'm applying a rotation around the cyan axis, I've also tried around the magenta one (direction on the XZ plane) with similar result.
The first red segment from the start point to the start of the parabola is displayed only because I'm assuming that the start point is always the first point (t=0)

Ok, so you want to rotate the parabola taking initial and final points fixed. This should be the solution:

1) the direction of the rotation must be the one connecting the initial and final points:

[tex]\mathbf{n}=\frac{\mathbf{x}_f-\mathbf{x}_i}{|\mathbf{x}_f-\mathbf{x}_i|}[/tex]

2) use this n and the angle you want, to construct the rotation R, like I said in my previous post, or with quaternions if you like.

3) Don't just do a linear rotation

[tex]\mathbf{x}'=R\mathbf{x}[/tex]

but do instead an affine rotation

[tex]\mathbf{x}'=\mathbf{x}_i+R(\mathbf{x}-\mathbf{x}_i)[/tex]

EDIT: oops I saw too late that the thread went on for 3 pages, and that the solution was already there...
 
  • #35
betel said:
My idea was wrong. Easy to check in the even leveled case.

Yours seems to be correct though. Just solve the quadratic for v^2 and then do the square root again and you get.

[tex] v= \sqrt{g(y_p-y_0+\sqrt{(y_0-y_p)^2+x_p^2})}[/tex]

You would have really made your life much more easy if you had chosen (0,0,0) as the start and zt=0. It is much faster to later transform the coordinate system.

Thank you betel, that works perfectly, I know that with (0,0,0) my life would be much easier but know I've got a general system to target a point from everywhere.

Thanks to Petr too!

I've also found out that my quaternion wasn't working because I wasn't applying an affine rotation but a linear one.
Using the affine it works great with quaternions too (as it should obviously be) :)

Thank you guys for your help, really, everything works just fine now!
 
Last edited:

Similar threads

  • Introductory Physics Homework Help
Replies
6
Views
520
Replies
2
Views
696
Replies
2
Views
3K
Replies
4
Views
994
  • Introductory Physics Homework Help
Replies
6
Views
999
Replies
7
Views
2K
Replies
14
Views
960
  • Advanced Physics Homework Help
Replies
6
Views
743
  • Introductory Physics Homework Help
Replies
10
Views
1K
  • Introductory Physics Homework Help
Replies
1
Views
1K
Back
Top