- #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...)
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
Last edited: