Author |
Message |
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
Calculating Trajectory?
This doesn't quite fit in with Lua, but I didn't know where else to ask this. How do you calculate trajectory in CC, using the variables:
1. Initial X and Y position of projectile 2. Initial launch angle 3. Gravitational accleration 4. Initial X and Y velocity of projectile 5. Final X and Y position of projectile
Edit: Forgot a variable.
|
Mon Feb 01, 2010 12:38 am |
|
|
Dr. Evil
Joined: Mon Aug 17, 2009 3:00 am Posts: 242 Location: The Great White North
|
Re: Calculating Trajectory?
Heh. I'm working on the exact same thing. EDIT: Kind of. With or without air resistance? EDIT: Also, what output are you looking to get? Points of the arc, or the equation of the arc?
|
Mon Feb 01, 2010 1:17 am |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
Re: Calculating Trajectory?
Points.
|
Mon Feb 01, 2010 1:24 am |
|
|
Dr. Evil
Joined: Mon Aug 17, 2009 3:00 am Posts: 242 Location: The Great White North
|
Re: Calculating Trajectory?
Including air resistance, or not?
|
Mon Feb 01, 2010 2:34 am |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
Re: Calculating Trajectory?
It would be nice, but not a high "need" priority.
|
Mon Feb 01, 2010 12:34 pm |
|
|
ProjektTHOR
Banned
Joined: Tue Feb 27, 2007 4:05 pm Posts: 2527
|
Re: Calculating Trajectory?
This would be nice, because then I would assume lua-fied targeting reticles for NLOS weapons would be possible. Also, just checking but you already know the math to calculate parabolic arcs, right? You just need it in lua terms?
|
Mon Feb 01, 2010 2:11 pm |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
Re: Calculating Trajectory?
Solving for distance only (as in, assuming a horizontal surface) is actually pretty easy:
θ=arcsin(rg/v^2)/2
angle = arcsin ( distance * gravity / velocity squared ) / 2
|
Mon Feb 01, 2010 3:58 pm |
|
|
Abdul Alhazred
DRL Developer
Joined: Tue Aug 11, 2009 5:09 am Posts: 395
|
Re: Calculating Trajectory?
I used this article to solve this problem for an actor in a mod I'm working on. It works fairly well even if the difference in Pos.Y between actor and target is a few hundred pixels.
|
Mon Feb 01, 2010 5:21 pm |
|
|
PhantomAGN
Joined: Mon Jun 29, 2009 2:40 am Posts: 610 Location: Deep below The Map of Mars
|
Re: Calculating Trajectory?
This something like what you want? The math has been heavily refined, but it deals with horizontal and vertical displacement. It's part of a lua-based mod I'm working (slowly) on.
|
Mon Feb 01, 2010 6:18 pm |
|
|
ProjektTHOR
Banned
Joined: Tue Feb 27, 2007 4:05 pm Posts: 2527
|
Re: Calculating Trajectory?
Seriously, can we see a NLOS targeting reticle now?
|
Mon Feb 01, 2010 8:08 pm |
|
|
p3lb0x
Forum Moderator
Joined: Fri Feb 02, 2007 3:53 pm Posts: 1896 Location: in my little gay bunker
|
Re: Calculating Trajectory?
I believe Capnbubs has something like that on his Crobo artillery crab
|
Mon Feb 01, 2010 8:30 pm |
|
|
Azukki
Joined: Sat Nov 03, 2007 9:44 pm Posts: 1916 Location: Flint Hills
|
Re: Calculating Trajectory?
Obviously some room for improvement, but well done, phantom. I've got some suggestions for those improvements. It doesn't, and should, consider obstructions, and take the quicker trajectory by default when it's unobstructed. If both paths are obstructed, don't fire, I guess? Maybe you should try casting an obstacle ray of the same vector as the velocity at the position of the projectile every 100 milliseconds or so into the trajectory? Or something like that? Also, if you want it to be really a really smart mortar, when the target is a dynamic object, use target lead to fire where it's going to be when the projectile strikes, rather than where it is now. Maybe also add the initial velocity of the turret to the projectile, and consider that? And consider air resistance, and lifetime of the projectile. This would pretty much make a perfect AI aiming system. But that's a bit overkill for one mod. For data, implementing it into the entire game would be great though. Considering obstruction would be reasonable for it though.
|
Tue Feb 02, 2010 12:15 am |
|
|
PhantomAGN
Joined: Mon Jun 29, 2009 2:40 am Posts: 610 Location: Deep below The Map of Mars
|
Re: Calculating Trajectory?
It actually already does the math for both possible paths and choses the faster one, all in one pile of calculations. You're right about the obstacles though. Air resistance is ignored because the projectile itself just ignores it too. It would not be hard to work in. The turret's not supposed to move, but the mod does include a portable version. I'll have to do some more math to fix that, you're right.
|
Tue Feb 02, 2010 1:31 am |
|
|
Mind
Joined: Thu Mar 06, 2008 10:54 pm Posts: 1360 Location: USA
|
Re: Calculating Trajectory?
Piipu already did this with grenades. It's somewhere in Epic CC Moments.
Just sayin
|
Tue Feb 02, 2010 7:16 pm |
|
|
|