#### Archived

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

# Moving in a specific direction.

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

## Recommended Posts

Ok, here''s my problem: I am trying to move a given point (say (0.0f, 50.0f, -20.0f) for example) in a specific direction (such as (1.15f, 0.0f, 0.0f)) for a certain length (like 40.0f). Are you following me? So, in summary, the information I have is? 1. The starting point - (0.0f, 50.0f, -20.0f). 2. The direction to move - (1.15f, 0.0f, 0.0f). 3. The distance to move - 40.0f. Note: Theses values can be anything, these ones are just examples. What I''m trying to find is the x,y,z position of the point after it has moved (i.e. the ending point). Does the direction need to be normilized first (i.e. between 0 and 1). 1.15f on the x axis makes the direction point down on an angle. 0.0f points horizontal foward and 1.57f points straight down on the x axis. I don''t need to actually move the point (i.e. its not for moving the camera or an object). I just want to find out what that ending point is. I''m not sure what the math is behind this, or what combination of D3DX functions need to be used to do this. If anyone knows how to do this I would love to hear from you. I have tried a few methods and they all give me strange ending points that are obviously wrong.

##### Share on other sites
yes, you need to normalize the direction. then use this formula:

pos_final = pos_initial + normalized_dir * distance_to_move

##### Share on other sites
Hey, thanks... That works perfect!

1. 1
Rutin
69
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633431
• Total Posts
3011834
• ### Who's Online (See full list)

There are no registered users currently online

×