# Get New point from a 3D Vector

## Recommended Posts

EdwardVella    100
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 on other sites
jyk    2094
If 'direction' is unit length, that equation will give you a point [i]distance[/i] units from [i]Origin[/i] in the direction of [i]direction[/i]. 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 on other sites
EdwardVella    100
[quote name='jyk' timestamp='1302691719' post='4797889']
If 'direction' is unit length, that equation will give you a point [i]distance[/i] units from [i]Origin[/i] in the direction of [i]direction[/i]. 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.
[/quote]

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.

[img]http://img814.imageshack.us/img814/5656/rectanglee.png[/img]

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

##### Share on other sites
EdwardVella    100
[quote name='jyk' timestamp='1302720460' post='4798068']
Are you getting the right results? If not, perhaps you could post the relevant code so we can take a look.
[/quote]

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.