PDA

View Full Version : Parallel line


elijah
11-18-2009, 10:30 AM
I know that for a line to be parallel , the vector ( dir ) of the line must be the same. I have a line in 3d and I need to create another parallel line above and below the existing line at a given offset. Can anybody help me or give me some idea on how to accomplish this. I thought of just adding so offset value for the given axis on the the origin of the line. But I do not know whether this is correct?

Mihail121
11-18-2009, 10:40 AM
I know that for a line to be parallel , the vector ( dir ) of the line must be the same. I have a line in 3d and I need to create another parallel line above and below the existing line at a given offset. Can anybody help me or give me some idea on how to accomplish this. I thought of just adding so offset value for the given axis on the the origin of the line. But I do not know whether this is correct?

It's not possible. Think abou it: what does "above" or "below" mean given we have three dimensions? You need just one more primitive (i.e. point) to fix a plane and then you can place additional lines. Non-zero offset of both the points will indeed result in a parallel line, although the concept of below or above will still not exist.

Reedbeta
11-18-2009, 10:43 AM
Mihail is technically correct. But, let's assume you have an "up vector" that defines what the global up/down direction is. (This might commonly be <0, 1, 0> if you use Y-up or <0, 0, 1> if you use Z-up.)

You already know a line is defined by a point and direction. To create another parallel line you keep the same direction and just move the point. So, to create a second line 5 units above the first, you would add 5 times your up vector to the point.

TheNut
11-18-2009, 12:09 PM
Calculate the cross product with the perpindicular vector to find an "up-vector". It's not guaranteed to be "up" per-say, it could just as easily point down, but you could define "up" as positive Y (or Z) and use that against the vector. Then just follow Reedbeta's instructions.

elijah
11-18-2009, 05:22 PM
Here is my pseudo code from your suggestion "TheNut" & "ReedBeta"

Given
LINE = A + t * D

From the Line we can get
SP = Start Point
EP = End Point

UPVECTOR = SP x EP

What do I do now after getting the UPVECTOR. To get 5 times UPVECTOR * 5 ? Then what do I do next ???

Reedbeta
11-18-2009, 05:30 PM
That calculation for upvector won't necessarily work. For now just use either <0, 1, 0> or <0, 0, 1> as your up vector, depending on whether Y or Z is up in your system.

Then just add it to A, the origin point of the line.