Go to Post Careful what words you use here; we take them literally. - DonRotolo [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #13   Spotlight this post!  
Unread 09-01-2006, 15:39
Matt Adams's Avatar
Matt Adams Matt Adams is offline
b(o_o)d
FRC #1525 (Warbots)
Team Role: Engineer
 
Join Date: Dec 2003
Rookie Year: 2000
Location: Arlington Hts. IL
Posts: 375
Matt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond repute
Send a message via AIM to Matt Adams
Post Re: Calculating Angle to fire at

Ah, I love the lunch break. If this is correct, which I'm pretty sure it is, I'm proud to say I did it myself. if it's not, then you get what you paid for.


Given:
X (desired position in horizontal direction),
Y (desired position in vertical direction)
Vo (firing velocity)

Find: Launch Angle, A

Starting with your two basic projectile motion equations:

X = Vo * cos(A) * t
Y = Vo * sin(A) * t - 1/2 * g * t^2

First, solve for t to eliminate it from the equation.

t = x / (Vo * cos(A) )

Substituting:

y = (x * Vo * sin(A)) / (Vo * cos(A)) - (g * x^2)/(2 * Vo^2 * cos^2(A))


Trig Identity: tan(A) = sin(A) / cos(A)

y = (x * tan(A) ) - (g * x^2) / (2 * Vo^2 * cos^2(A))


(x * tan(A) - y ) * (2 * Vo^2 * cos^2(A)) = g * x^2

(2 * Vo^2 * x * sin(A) * cos(A)) - (2 * Vo^2 * cos^2(A) * y) = g * x^2


Simplify some more:
(2 * x * sin(A) * cos(A)) - (2 * cos^2(A) * y) = (g * x^2) / (Vo^2)

Fancy Trig:

(x * sin(2A)) - (2 * cos^2(A) * y) = (g * x^2) / (Vo^2)

Little More Fancy Trig:

(x * sin(2A)) + (-y)(1+cos(2A)) = (g * x^2) / (Vo^2)

Not So Fancy Math:

(x * sin(2A)) + (-y * cos(2A)) = (((g * x^2) / (Vo^2)) +y)


Pretty Fancy Trig Identity: (if there's a mistake, it's bad application here!)
a * sin(A) + b * cos (A) = sqrt(A^2 + B^2) * sin(A + T)

Where T:
arctan(b/a) if a>=0;
pi + arctan(b/a) if a<0

I simplified this with the common(?) matlab function atan2 which is a 'smart' arc tan function that takes the sign of the x and y components into account when returning an angle.

Note, however, that since A in our case is X, it should never be negative, assuming you're aiming in front of you...


Using Pretty Fancy Trig Identity Above:

sqrt(x^2 + y^2) * sin(2A + atan2(-y/x)) = (((g * x^2) / (Vo^2)) +y)


Finally, when you put this in terms of A:

A = 1/2 * (asin( (((g * x^2) / (Vo^2)) +y) / sqrt(x^2 + y^2) ) - atan2(-y/x))


The reason I feel pretty comfortable about this, because when you set Y=0, you get your basic range equation:

2A = asin(g * X / Vo^2))

That's that!

Sources:
http://en.wikipedia.org/wiki/Trigonometric_identity
http://hyperphysics.phy-astr.gsu.edu/hbase/traj.html



Matt
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Viewing Angle of Camera Joe Johnson Technical Discussion 10 14-01-2005 14:11
Calc. Triangle Angle or Side Based on Ellipses? indieFan Math and Science 1 07-06-2004 21:25
Serious VCU Fire Joe Matt Chit-Chat 3 26-03-2004 19:04
PBASIC ARCTAN function Greg Ross Programming 14 11-05-2003 12:28
45 degree PVC angle fittings: which? archiver 2001 2 23-06-2002 22:53


All times are GMT -5. The time now is 04:19.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi