Game Development Community

Projecting a point from 2 vectors/point and a distance.

by Matthew Jones · in Technical Issues · 03/05/2006 (5:58 pm) · 3 replies

This is a tongue twister for me. ANd this is not a homework assignment. :)

Heres what I have:
2 points in 3d space. (a,b)
The distance between those 2 points. (Dis)
A normalized percentage of another distance.(scaler)

I need to "project" (for the lack of a better word) a point along the LINE that the 2 POINTS (a,b) make. The point need to be further than point B by the amount of scale (scaler).

The result would need to yield the NEW POINT in 3d space.

I am not sure even what the math process would be called. And I have no clue were to begin. But I know its what I need.

Any help is appriciated.
Matthew Jones

#1
03/05/2006 (6:01 pm)
Create a vector between your two points.
Make this a unit vector.
Multiply this unit vector times your scalar distance.
Add the vector to your point B.
#2
03/06/2006 (11:26 am)
Just putting what Stephen said in torquescript :
vect = VectorSub(a,b);
vect = VectorNormalize(vect);
vect = VectorScale(vect,scalar);
vect = VectorAdd(b,vect);

HTH
#3
03/06/2006 (4:13 pm)
Oh man thanks Stephan. I am going to post a few more things as soon as I can get them together, If you don't mind checking back on this, maybe tommorrow.

Not using Torque at all on this one, but thanks anyway Bruno.

Matt