PDA

View Full Version : Start point, End point => Direction



vashts
04-07-2007, 09:01 AM
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

vashts
04-07-2007, 09:30 AM
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

dpont
04-07-2007, 09:37 AM
You are correct, a direction for raytrace function is in
world coordinates, so you need world position.

Denis.

vashts
04-07-2007, 10:02 AM
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

vashts
04-07-2007, 10:09 AM
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

dpont
04-07-2007, 10:19 AM
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.

vashts
04-11-2007, 08:53 AM
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