#### Archived

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

# rotating velocity vector to match cars orientation...

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

## Recommended Posts

Hi guys, I''ve got a velocity vector on a car and as the car changes direction I want the velocity vector to align to its orientation. At the minute I''ve got the following: Vx = (Vx + dt * accn) * cosf(theta) Vz = (Vz + dt * accn) * sinf(theta) Where theta is the cars orientation angle in radians. 0 being straight ahead. This works when theta is 0, and hence is going forward with velocity Vx, but when turning the velocity slows down to a crawl, and doesn''t give me enough velocity to move. Any ideas where I''m going wrong?? Cheers,

##### Share on other sites
Ugg... well, to start, your equations are a little on the strange side. You are using the full acceleration value for both coordinates, even when you are not pointing in that direction...

Basically, you might have better luck storing the magnitude of velocity, ie speed, and an angle for the direction it is pointing in. That way all you have to do is increment the speed and keep track of what direction the car is facing.

Now, if you are looking for a realistic car sim, you would make some changes. First, a car doesn''t just start going the direction it turns. Friction tries to stop it dfrom continuing on its last path but that doesn''t always happen (skid). To do this realistically you would need to implement friction, and then you wouldn''t have to turn the vector yourself.

##### Share on other sites
yeh like "intrest86" said this will work better:

Vx = speed * cosf(theta)
Vz = speed * sinf(theta)

1. 1
Rutin
34
2. 2
3. 3
4. 4
5. 5

• 12
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
633331
• Total Posts
3011399
• ### Who's Online (See full list)

There are no registered users currently online

×