Question for Ray-Plane Intersection Code

32 views
Skip to first unread message

CHAN HAENG Lee

unread,
Dec 16, 2020, 7:26:39 PM12/16/20
to G3D Users
Hi. I'm enjoying the graphics codex while implementing my path tracer.

I have a question for the ray intersection with plane in G3D. I wonder why the code of ray intersection with the plane is getting another form of plane equation (flipping the distance) and then intersecting with ray.

As the comment says in Plane.h, the plan equation is "normal.Dot(x,y,z) = distance".
But when seeing the implementation of ray intersection with plane,
the public method of plane does not offer "normal.Dot(x,y,z) = distance" but "normal.Dot(x,y,z) + distance = 0". Is there any reason for this without giving the original equation?

I guess the path tracer may prefer this equation "normal.Dot(x,y,z) + distance = 0", But I don't know about it correctly.

Thanks.




Linwan Song

unread,
Jul 18, 2022, 9:33:15 PM7/18/22
to G3D Users

Hello, 

Just to follow up on this question, since you never got an answer, I believe you got _distance and d confused.

> As the comment says in Plane.h, the plan equation is "normal.Dot(x,y,z) = distance".

I believe you're referring to line 26 in Plane.h where the code says: 

Screenshot 2022-07-18 181937.png

This is implemented in the constructor in Plane.cpp where _distance = normal.dot(point):

 Screenshot 2022-07-18 181520.png

> the public method of plane does not offer "normal.Dot(x,y,z) = distance" but "normal.Dot(x,y,z) + distance = 0".

When you say this, I believe you’re actually referring to normal.Dot(x,y,z)+d=0, which we can see in this comment in Plane.h:

Screenshot 2022-07-18 182537.png

If you check the implementations of these functions in Plane.cpp, you can see that later  d = -_distance

Screenshot 2022-07-18 182638.png

So normal(x,y.z) = distance and normal(x,y,z) + d = 0 are consistent since d = -_distance

d and _distance are pretty similar so I can see how you thought they were the same. 

Best, 
Linwan
Reply all
Reply to author
Forward
0 new messages