Parallel line

6475908f9503cf68fb9e462214ca4d73
0
elijah 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

Please log in or register to post a reply.

2b97deded6213469bcd87b65cce5d014
0
Mihail121 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.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 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.

6837d514b487de395be51432d9cdd078
0
TheNut 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.

6475908f9503cf68fb9e462214ca4d73
0
elijah 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 ???

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 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.