Results 1 to 3 of 3

Thread: Finding a point in a particular direction

  1. #1
    Registered User mattbolton's Avatar
    Join Date
    Apr 2003
    Location
    KS, USA
    Posts
    208

    Finding a point in a particular direction

    Say I have a point at <1,1,0> and I want to find the point 3 units away in a particular direction described by <0,-90,0>, or any other arbitrary direction. I know it's simple, I have done this before, but for the life of me I can't come up with it today.
    Thanks,

    Matt

  2. #2
    obfuscated SDK hacker Lightwolf's Avatar
    Join Date
    Feb 2003
    Location
    Stuttgart, Germany
    Posts
    13,569
    Hi Matt...

    Let p be a point at (x,y,z)
    Let d be a direction vector (i,j,k)

    Now, let's say you want to find a point q that's n units away from p in the direction of d

    1) make d into a unit vector du (iu,ju,kiu)
    du = d / mag(d)
    ->
    mag(d) = sqrt(i * i + j * j + k * k)
    ->
    iu = i / mag(d)
    ju = i / mag(d)
    ku = i / mag(d)

    2) so, q = p + du * n
    or
    p(x) = p(x) + i / mag(d) * n
    p(y) = p(y) + j / mag(d) * n
    p(z) = p(z) + k / mag(d) * n

    Not a 100% mathematically correct description, but I hope you get my drift...

    Cheers,
    Mike

  3. #3
    Registered User mattbolton's Avatar
    Join Date
    Apr 2003
    Location
    KS, USA
    Posts
    208
    Thanks for your help, but I am expecting to see some trigonometry in there I think.
    If I have a light at <1,1,0> and it is pointing back at the origin <0,0,0>, the angle vector is <-90,45,0>.
    Since the light is exactly 1 unit away from the origin, I would expect the formula to return <0,0,0> as being one unit away in the direction that the light is pointing, and <-1,-1,0> as being 2 units away, etc.
    I think the problem I have is that the angle vector of the light is not the same as a "direction" vector?
    I'll have to sit down and think about it some more I'm afraid.
    Last edited by mattbolton; 01-13-2004 at 02:37 PM.

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
  •