Skip to content

Commit 42d24a1

Browse files
committed
Adding Plane.DistanceTo() method
1 parent e3f48f5 commit 42d24a1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

RaysAndStuff/Plane.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ public bool RayIntersection(Vector3 Start, Vector3 Dir, ref float t, ref Vector3
3636
return (false);
3737
}
3838

39+
// RETURNS THE DIST TO PT FROM PLANE (+ in dir of normal, - in opposite dir)
40+
float DistanceTo(Vector3 P)
41+
{
42+
return -(Vector3.Dot(Normal, P) + D);
43+
}
44+
3945
public readonly Vector3 Normal;
4046
public readonly float D;
4147
}

0 commit comments

Comments
 (0)