|
-
Mar 1st, 2005, 07:38 PM
#1
Thread Starter
Ex-Super Mod'rater
Motion at an Angle 2D (For the Games FAQ)
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
Mar 2nd, 2005, 12:16 PM
#2
PowerPoster
Re: Motion at an Angle 2D (For the Games FAQ)
Very nice tutorial.
I'd add the name of that type of 2D graph into the FAQ -- that really helped my understanding learning that Cartesian and I think Polar (???) are the same yet the way Polar works more closely related a game (usually). As you have a point and a distance or an angle and a distance on a polar plane.
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
-
Mar 2nd, 2005, 12:30 PM
#3
Re: Motion at an Angle 2D (For the Games FAQ)
Don't forget to convert the A and B angles to radians
Cos(A * Pi/180)
Sin(A * Pi/180)
-
Mar 2nd, 2005, 08:22 PM
#4
Thread Starter
Ex-Super Mod'rater
Re: Motion at an Angle 2D (For the Games FAQ)
 Originally Posted by Jacob Roman
Don't forget to convert the A and B angles to radians
Cos(A * Pi/180)
Sin(A * Pi/180)
Good point yea, but mind I'd expect you'd work in radians from the start anyway if its a game cos having loads of * Pi/180 is gonna slow things down .
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
Mar 4th, 2005, 08:37 AM
#5
transcendental analytic
Re: Motion at an Angle 2D (For the Games FAQ)
Note that your trigs are going to slow down much more, and generally in a game you try to avoid polar cordinates as much as possible for that reason, as last resort you use a table of precalculated values on the trigs. For objects in motion you store the cartesian velocity vector, and add the velocity to the position each frame. Polar cordinates also make motion unrealistic. Otherwise if you insist on rotation, especially repeated with the same angle values, then you can save the calculation of trigs by using the same matrix for every rotation, and usually you can do with that unless you have angular accelartion.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jan 7th, 2008, 07:31 AM
#6
New Member
Re: Motion at an Angle 2D (For the Games FAQ)
Quick question: So how do you find out the angle from dX and dY? Last thing I knew there wasn't a sin/cos/tan inverse function...
-
Jan 7th, 2008, 09:29 AM
#7
Re: Motion at an Angle 2D (For the Games FAQ)
There is an ArcTangent function. To avoid losing sign I use this
Code:
Option Explicit
Public Const PI As Double = 3.14159265358979
Public Const PI½ As Double = 1.5707963267949
Public Function ATan2(ByVal Dy As Double, ByVal Dx As Double) As Double
If Dx = 0 Then
ATan2 = PI½ * Sgn(Dy)
Else
ATan2 = Atn(Dy / Dx)
If Dx < 0 Then ATan2 = ATan2 + PI
End If
End Function
Works fine as Single too in most cases
-
Jan 11th, 2008, 11:32 AM
#8
New Member
Re: Motion at an Angle 2D (For the Games FAQ)
I think Pi can be calculated near enough with Abs(4) or something like that in VB6.
Small thing bugging me is the use of dx and dy. The d means small change in but the change could be up to infinity. Just me being picky though (I see it too often in calculus to see it anywhere else )
-
Jan 11th, 2008, 03:12 PM
#9
New Member
Re: Motion at an Angle 2D (For the Games FAQ)
Aye, but of course ordinary keyboards don't come with triangles for big changes :P
-
Jan 12th, 2008, 05:18 AM
#10
New Member
Re: Motion at an Angle 2D (For the Games FAQ)
Too true but "small change in" is used for differentiation and by small change it means small - too small for trig in movement.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|