• ### What is your GameDev Story?

#### Archived

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

# ray problem

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

## Recommended Posts

i need to rotate a rays vector so that it points to a certain point. i already know how to rotate a vector by a certain amount of degrees. i thought about calculating a vector from the rays origin and the certain point using vector subtraction and then using the dotproduct to get the angle between this vector and the rays vector. then i rotate the rays vector by this angle. but i saw that this only works in 2D. in 3D i have to rotate the vector by two angles around the X and the Y axis. can somebody help me ?

##### Share on other sites
Do you need to calculate euler angles? If you don''t, you can just make a look-at matrix and multiply the ray by it.

##### Share on other sites
Actually it''s very simple:

you have
- a ray=(origin,direction)
- a point P

just fill in normalized(P-origin) for direction

There''s no need for a rotation

##### Share on other sites
yes thx, but i realized that this was not my real problem.
sorry, i already got it :-P

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 11
• 13
• 9
• 11
• ### Forum Statistics

• Total Topics
634087
• Total Posts
3015444
×