Notifications
Clear all

[Closed] Point3 along a ray ?

Hi All !

My question is, can we get a point3 value along a ray ?

I’ll explain myself :

I have NODEA that shoots a ray to NODEB , The ray have a lenght, but can I get a position based on a given lenght ?

 
 
r = ray NODEA.pos NODEB.pos
at lenght 10 on ray r get position 

I just started to play with rays today, and I don’t have Bobo’s DVDs at home yet ( I had it at work but I changed studios so I don’t have acces to it anymore )

I’m trying to make a POINT follow another POINT at a given distance:scream:

3 Replies

Probably do it with vectors like so:

 
magnatude = 35 
nodea = $Point01

nodeB = $Point02

nodeC = $Point03 ; nodeC.wirecolor = red

NormalizedVector = normalize(nodeB.pos - nodeA.pos)

NewVector = (NormalizedVector * magnatude) + nodeA.pos

nodeC.pos = NewVector


Cheers

Dan

You misunderstood the Ray value. A RAY contains a start position AND DIRECTION. You cannot construct a ray from two positions – the second argument to the constructor is the direction vector.

If you have two positions, you don’t even need a Ray to find the length along the direction they define.

If A is the starting point and B is the end point, then the vector defined by the two is

 theVector = B-A

This vector will have a length equal to the distance between them and direction pointing from A to B.

So if you want to find a point at a given distance along the line connecting A to B, you just need a normalized vector (also called unit vector) which has the same direction and a length of 1.0.

 theUnitVector = normalize theVector

You can multiply a vector by a scalar (integer or float value) to get a new vector with the desired length. Thus,

 theNewVector = theUnitVector * 10

This is a vector that starts at 0,0,0 and has a length of 10 and is parallel to the direction defined by A->B. In order to find the position of 10 units along the line from A to B, just add theNewVector to the position A:

theNewPos = A + theNewVector

In short,

 theNewPos = A + (normalize (B-A)) * 10

This is exactly what djlane wrote, but with some more theory to explain it.

If you want more, see my signature

1 Reply
(@ericdlegare)
Joined: 11 months ago

Posts: 0

Well thanks a lot

You can count on me for this Thanks again !