0
101 Nov 18, 2009 at 18:30

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?

#### 5 Replies

0
102 Nov 18, 2009 at 18:40

@elijah

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.

0
167 Nov 18, 2009 at 18:43

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.

0
179 Nov 18, 2009 at 20:09

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.

0
101 Nov 19, 2009 at 01:22

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 ???

0
167 Nov 19, 2009 at 01:30

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.