Results 1 to 7 of 7

Thread: Start point, End point => Direction

  1. #1
    Super Member vashts's Avatar
    Join Date
    Jul 2003
    Location
    Tornavento, Italy
    Posts
    365

    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
    My website: Geba.it
    LightWave Italian Community: LWITA.com

  2. #2
    Super Member vashts's Avatar
    Join Date
    Jul 2003
    Location
    Tornavento, Italy
    Posts
    365
    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
    My website: Geba.it
    LightWave Italian Community: LWITA.com

  3. #3
    Member
    Join Date
    May 2006
    Location
    France
    Posts
    3,908
    You are correct, a direction for raytrace function is in
    world coordinates, so you need world position.

    Denis.

  4. #4
    Super Member vashts's Avatar
    Join Date
    Jul 2003
    Location
    Tornavento, Italy
    Posts
    365
    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
    My website: Geba.it
    LightWave Italian Community: LWITA.com

  5. #5
    Super Member vashts's Avatar
    Join Date
    Jul 2003
    Location
    Tornavento, Italy
    Posts
    365
    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
    My website: Geba.it
    LightWave Italian Community: LWITA.com

  6. #6
    Member
    Join Date
    May 2006
    Location
    France
    Posts
    3,908
    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.
    Last edited by dpont; 04-07-2007 at 10:22 AM.

  7. #7
    Super Member vashts's Avatar
    Join Date
    Jul 2003
    Location
    Tornavento, Italy
    Posts
    365
    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
    My website: Geba.it
    LightWave Italian Community: LWITA.com

Bookmarks

Posting Permissions

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