#### Archived

This topic is now archived and is closed to further replies.

# Radians and Vectors

This topic is 5586 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi All, I was hoping to get a little clarification on this ... I just recently started game programming after several years of application programming. Needless to say, some of the concepts have been rather different than any appdev I've done. My question is this ... When would you use Radians over Vectors and vice versa. For more clarification, I often see questions in the forum asking about reflection angles. Most of the time, the answers are in the form of some sort of vector math. However, i recently created a test app that demonstrates reflection angles, but I used radians ... so all my "ship" object had to keep was a velocity, and a degree to plot it's direction. I found that thinking in terms of angles was very easy, and the math for reflection angles was very simple (I'm quite proud to say that I figured out that math on my own ;-) ). So I ask, what's so good about Vectors ... I must be missing something, but everything I've seen, I haven't quite been able to grasp. Just another small clarification, this is purely 2d stuff ... I haven't even wandered into 3d land yet ;-)[/edit] Thanks in advance for your answers Joel Martinez http://www.codecube.net/ [edited by - joelmartinez on February 7, 2003 11:55:50 AM]

##### Share on other sites
Um, you would never use radians over vectors. They are two completely different things. Radians are one form of measure for angles, and vectors are mathematical constructs that contain both magnitude and direction (i.e., the angle is a part of the vector). Usually in physics, the angles are measured in degrees rather than radians, but there''s really no reason to do it this way, as either way is just as good.

Now, as for reflection angles, you don''t really need vectors at all, if you''re talking about elastic collisions, anyway, since the angle of reflection is the same as the angle with which an object hits a wall (or whatever).

##### Share on other sites
The thing is, you ARE working with vectors, only using polar coordinates. So your question should be when to use polar over cartesian coordinates and vice versa. A simple example when cartesian coordinates is easier is adding vectors. How do you represent the position of your objects? How do you update their positions? My guess is you already use cartesian coordinates for this...

##### Share on other sites
Hi,
Thanks for your response (both of you) ... to answer your questions

-How do you represent the position of your objects?
this.X
this.Y
this.Direction (angle)

-How do you update their positions?
double radian = Math.Sin(Math.Pi * this.Direction) / 180;double nX = this.Velocity * radian;double nY = -(this.Velocity * radian)this.X += (int)nX;this.Y += (int)nY;

And I figure out the reflection angle like so:
double rAngle = (wallangle - player1.Direction) + wallangle;//keep the angle within boundsif (rAngle <= 1) rAngle += 360;if (rAngle > 360) rAngle -= 360;player1.Direction = rAngle;

So in what situation would a "Vector" become handy as I haven''t come across one yet (that''s not saying much though as I''ve only been game programming for about a month).

Thanks

Joel Martinez
http://www.codecube.net/

• 12
• 9
• 13
• 41
• 15