View unanswered posts | View active topics It is currently Fri Dec 27, 2024 9:10 am



Reply to topic  [ 14 posts ] 
 Calculating Trajectory? 
Author Message
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post 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
Profile
User avatar

Joined: Mon Aug 17, 2009 3:00 am
Posts: 242
Location: The Great White North
Reply with quote
Post 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
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Calculating Trajectory?
Points.


Mon Feb 01, 2010 1:24 am
Profile
User avatar

Joined: Mon Aug 17, 2009 3:00 am
Posts: 242
Location: The Great White North
Reply with quote
Post Re: Calculating Trajectory?
Including air resistance, or not?


Mon Feb 01, 2010 2:34 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Calculating Trajectory?
It would be nice, but not a high "need" priority.


Mon Feb 01, 2010 12:34 pm
Profile
Banned
User avatar

Joined: Tue Feb 27, 2007 4:05 pm
Posts: 2527
Reply with quote
Post 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
Profile YIM
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post 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
Profile
DRL Developer
DRL Developer

Joined: Tue Aug 11, 2009 5:09 am
Posts: 395
Reply with quote
Post 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
Profile
User avatar

Joined: Mon Jun 29, 2009 2:40 am
Posts: 610
Location: Deep below The Map of Mars
Reply with quote
Post Re: Calculating Trajectory?
This something like what you want?
Attachment:
File comment: WIP v.5
Beta Smart Mortar.rte.zip [1.04 MiB]
Downloaded 178 times

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
Profile
Banned
User avatar

Joined: Tue Feb 27, 2007 4:05 pm
Posts: 2527
Reply with quote
Post Re: Calculating Trajectory?
Seriously, can we see a NLOS targeting reticle now? :(


Mon Feb 01, 2010 8:08 pm
Profile YIM
Forum Moderator
User avatar

Joined: Fri Feb 02, 2007 3:53 pm
Posts: 1896
Location: in my little gay bunker
Reply with quote
Post Re: Calculating Trajectory?
I believe Capnbubs has something like that on his Crobo artillery crab


Mon Feb 01, 2010 8:30 pm
Profile
User avatar

Joined: Sat Nov 03, 2007 9:44 pm
Posts: 1916
Location: Flint Hills
Reply with quote
Post Re: Calculating Trajectory?
Image
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
Profile
User avatar

Joined: Mon Jun 29, 2009 2:40 am
Posts: 610
Location: Deep below The Map of Mars
Reply with quote
Post 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
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post 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
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 14 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.060s | 14 Queries | GZIP : Off ]