# Thread: Start point, End point => Direction

1. ## Start point, End point => Direction

hi all, question: how can I obtein the direction (vector) from a start point to an end point? I need to give the result as input of the raycast node..

vashts

2. I reply to myself.. as I thought, given point A and point B, the direction from A to B is B - A.. so, I may use a subtract (vector) node and put the ending point in node's A input and starting point in node's B input.. the output is the input of a normalize node, and that may be the direction I'm looking for..

..can you confirm it?

vashts

3. You are correct, a direction for raytrace function is in
world coordinates, so you need world position.

Denis.

4. ok, but it doesn't work. I've tried to insert a direction (costant) node and its values are in degrees. how can I convert my normalized vector to a direction-like node?

vashts

5. well, I explain better my situation.

I have a NULL from which I need to trace rays; points hitted by a ray in a defined range are colored with a defined color, points out of that range aren't.

so, I've added an Item Info node, selected the NULL and used the world position output; I've added a Spot Info node and used World Spot output; those 2 outputs are respectively the input B and A of a Subtract (vector) node. the Result is the input of a Normalize node, whose Result output is the input of Direction of a RayCast node. the Position input of RayCast is given by World Position of Item Info node. the output of RayCast node is the Input of a Gradient node, and so on.
I think I'm wrong from normalize to raycast: the normalized output isn't in degrees format.. am I right? if so, how to solve it?

vashts

6. the normalization is for having a length of 1 m for the input dir,
the raytrace functions need always a normalized vector,
so in the normalize node, the input and the output are vectors.

The direction is not an angle but a vector defined by 2 point positions,
(B - A) like you said.

Denis.

7. well, at the end it gave me weird results, so I've done in another way.

denis: what do you think about creating a simple direction node? inputs: starting point, ending points; output: (normalized) direction. all vectors.

vashts

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•