I've looked everywhere, I've asked everyone, but it's something nobody has a clear answer to. I want to know how to represent a 3D line! I know a 2D line is y = mx + c but what about a 3D line?? Anyone who has any clues, please please tell me! Would be so much appreciated. Also, does anyone know how to determine if two 3D lines intersect?

Thanks for the link there! Will give that a read when I get time. Hopefully, it's what I'm after.

Wheezy?

Okay, well I've learned I can determine whether two lines intersect and at what point using the substitution method, by satisfying both equations. I want to duplicate this in software and it's impossible! I just don't know what to do.

Member Avatar for iamthwee

Okay, well I've learned I can determine whether two lines intersect and at what point using the substitution method, by satisfying both equations. I want to duplicate this in software and it's impossible! I just don't know what to do.

Duplicate what?

What is it you want to do?

A 2D line can be represented by:-

x + y = <number>

A 3D line can be represented by:-

x + y + z = <number>

Given two lines in 3 dimensional space, the point of intersection can be found by elimination (i.e simultaneous equations).

To solve a system of simultaneous equations with software, as you put it, you would have to represent the system using matrices and then solve it using gaussian elimination or some other strategy thereof.

If you mean, how do I draw lines in 3d space, that is something different, although the math is generally the same. Remember 3D lines don't exist, the illusion of 3D created by using clever math with simple 2D lines.

A 3D line can be represented by:-

x + y + z = <number>

No, that's a plane. A 3D line can be represented with two points on the line. For example, (0,3,4) and (3,2,1). Alternately, you can represent a 3D line with a point on the line and a point (or 'vector') representing the direction the line is going. For example, (0,3,4) and (3,-1,-3). Then the formula (0+3t, 3-1t, 4-3t) will compute points on the line based on the real number t. I think the second form tends to be more convenient, if you're representing a 'line', and not a line segment.

Member Avatar for iamthwee

No, that's a plane.

Damn and it seemed so intuitive. I must admit I assumed two 3D lines that intersect could be based on the same logic of a 2D line, with just an extra variable i.e the z component.


So how then would you find the point of intersection for two lines in 3D space? If you're defining one line in 3D space to be defined by two points, e.g (0,3,4) and (3,-1,-3).


Can you show me an example.

I just assumed you have two lines given by the equations:-

2x -  3y + z   = 7
5x + 8y -  3z = 4

And then you would use gaussian elimination to find the point of intersection, assuming of course the two lines actually intersect. Is this logic completely bogus?

Hmmm, goes to show how little I understand this! I think I'm not entirely sure what I was asking.

Turns out I'm after a 3D line segment/3D triangle intersection algorithm i.e. an algorithm to determine if a line segment intersects a triangle in 3D space, and where the intersection occurs. Surprisingly, there is not much written on this topic!

So how then would you find the point of intersection for two lines in 3D space?

You don't unless you're lucky.

And then you would use gaussian elimination to find the point of intersection, assuming of course the two lines actually intersect. Is this logic completely bogus?

The intersection of those two planes forms a line.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.