Public Group

# Combining Directional Speed

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

## Recommended Posts

Hello, I am trying to combine directional speed. For example if a gameobject is has a speed of 10 and a direction of 90 degrees (i use radians but for the purposes of example simplicity im using degrees) and I try to apply downward speed (for example 15 speed, 270 degrees for example), this should end up with a speed of 5 at 270 degrees. But how would i actually calculate this? And on a side-note how would i go from speed/direction to x and y speed and the other way around? Thank You. [Edited by - Hacktank on April 16, 2010 5:17:10 PM]

##### Share on other sites

Vectors can be represented in polar coordinates or rectangular coordinates.

Your representation (angle,radius) is polar coordinates. You can use the law of cosines to add vectors in that representation if you choose, but it is much,much easier to convert the representation to rectangular (x,y) and add them in that representation.

To do the conversion, given (angle,radius) = (theta,phi)

the opposite conversion is
theta=atan2(y,x);

to add two vectors in rectangular,
x=x1+x2;
y=y1+y2;

##### Share on other sites

Vectors can be represented in polar coordinates or rectangular coordinates.

Your representation (angle,radius) is polar coordinates. You can use the law of cosines to add vectors in that representation if you choose, but it is much,much easier to convert the representation to rectangular (x,y) and add them in that representation.

To do the conversion, given (angle,radius) = (theta,phi)

the opposite conversion is
theta=atan2(y,x);

to add two vectors in rectangular,
x=x1+x2;
y=y1+y2;

##### Share on other sites
Thank you, very thorough and helpful answer.

1. 1
2. 2
3. 3
Rutin
12
4. 4
5. 5

• 26
• 10
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633695
• Total Posts
3013382
×