Hello Everyone,
I am having an issue with a point plane distances, and was wondering if anyone could help me.
To start, a plane is defined by a unit normal, and a distance from the origin Plane(Vec2,float) while a point is simply a point in space Vec2.
To get the distance between a point and a plane, usually something like this is done:
float distance = dot( plane_normal , point ) + plane_distance_from_origin. So far so good. The issue lies with the following example. Say we have:
This also assumes that top left is the origin.
Plane plane1(Vec2(1,0),0)
Plane plane2(Vec2(1,0),50)
Plane plane3(Vec2(-1,0),350)
Plane plane4(Vec2(-1,0),400)
and a Point at (200,0)
The following would be the distances
point to plane1 = dot( Vec2(1,0) , Vec2(200,0)) + 0 = 200 //Correct distance
point to plane2 = dot( Vec2(1,0) , Vec2(200,0)) + 50 = 250 //WRONG!! incorrect distance. S/B 150
point to plane3 = dot( Vec2(-1,0), Vec2(200,0)) + 350 = -200 + 350 = 150 //Correct distance
point to plane4 = dot( Vec2(-1,0), Vec2(200,0)) + 400 = -200 + 400 = 200 //Correct distance
My issue is with "point to plane2" distance. I am not sure how to deal with this problem. Could someone please suggest a solution, or give me a source.
Thank you very much.
Mike
↧