# The Industry's Foundation for High Performance Graphics

1. ## point intersection?

Its been a couple of years since I had my advanced calc, so I don't remember this, and I've been trying to figure it out but this is easier...

okay, I have points A and B, and a plane in between them, how do I calculate the point along the vector defined from A to B that intersects the plane?

If you can give me general formulas I would be most appreciative.

For example lets say we have A=(-5, 2, -15); C=(15,4,-25) and a plane defined by x=5;

Obviously by hand we can see that it intersects at B=(5, 3, -20), but what is the general formula?

2. ## Re: point intersection?

Code :
```
int LinePlaneIntersect( CVector&amp; a, CVector&amp; b, CPlane&amp; plane, CVector&amp; result ){
double quot, t;
plane.normal.Normalize();
t    = (plane.place-a)*plane.normal;
quot = b*plane.normal;

if( DOUBLE_EQ( quot, 0.0 ) ) {
if( DOUBLE_EQ( t, 0.0 ) )
return LPI_INSIDE;
else return LPI_PARALLEL;
}
t    = t/quot;
result = a+b*t;
return LPI_CUT;
}```
a is the place vector of the line, b the direction vector.
DOUBLE_EQ checks wether two doubles are about the same (with a little delta due to imprecision).
Returns LPI_INSIDE if the line is inside the plane. LPI_PARALLEL if the line is parallel to the plane. LPI_CUT otherwise.

I have a vector class, that's why I can simply calculate with these vectors. The theory stays the same however, even if you haven't it (yeah... sorry.)

[This message has been edited by Michael Steinberg (edited 04-15-2001).]

3. ## Re: point intersection?

http://astronomy.swin.edu.au/pbourke...try/planeline/

No code, but 2 ways to tackle the problem. It's also simple to turn into code.

Thanks again Paul Bourke! Great site. Always helps me when I'm too lazy to pick up a textbook.

[This message has been edited by ffish (edited 04-16-2001).]

4. ## Re: point intersection?

Has my code not been good?

5. ## Re: point intersection?

actually I feel stupid that I didn't come back and close the discussion; about 5 minutes after I posted that I figured it out, so though I didn't end up using your code, I'm sure that its good, however given my own datatypes and such and the fact that I figured it out before I had a chance to read your post, I didn't end up using them. Sorry, but thanks.

6. ## Re: point intersection?

Your code was good Michael. I just posted a reference that I use fairly often for lots of different geometry related problems.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•