View Full Version : Finding a point in a particular direction

mattbolton

01-13-2004, 08:19 AM

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

Lightwolf

01-13-2004, 08:41 AM

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

mattbolton

01-13-2004, 02:16 PM

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.

Powered by vBulletin® Version 4.2.3 Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.