Jump to content
  • Advertisement
Sign in to follow this  
EdwardVella

Get New point from a 3D Vector

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,
i want to make sure the equation i am using is correct.

Scenario:
I made a ray cast to retrieve the distance from a point of origin, with a given direction vector and with those two i have the new distance. In order to calculate the new distance.

is this equation correct.


New Vector = Origin + direction * distance

Share this post


Link to post
Share on other sites
Advertisement
If 'direction' is unit length, that equation will give you a point distance units from Origin in the direction of direction. So if that's what you're after, then yes, that looks right.

More generally, the distance will be in units of |distance|, which will be 1 if 'distance' is unit length.

Share this post


Link to post
Share on other sites

If 'direction' is unit length, that equation will give you a point distance units from Origin in the direction of direction. So if that's what you're after, then yes, that looks right.

More generally, the distance will be in units of |distance|, which will be 1 if 'distance' is unit length.


Let me expand on what i am doing, to make sure we are on par. I'm working with steering behaviours, and i need to check how far a "vehicle" is away from a wall. I need to get the 3 points in the green circles in terms of Vectors. Each line green, orange and blue are all direction vectors of type Vector 3D. the point of origin is a vector 3D point as well, the distance is a normal decimal number that i had retrieved using ray calculations.


rectanglee.png

Share this post


Link to post
Share on other sites
Are you getting the right results? If not, perhaps you could post the relevant code so we can take a look.

Share this post


Link to post
Share on other sites

Are you getting the right results? If not, perhaps you could post the relevant code so we can take a look.


right now im still building my code, i still need to compile it to give me a good value. hopefully by tomorrow i will get the code up and running. But i took a look at some other code of a similar project and my equation and that one matched.now i just need to check it out. will get back to you ASAP. thanks for all the help :)

EDIT: Sorry for the late reply, it works well.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!