how can i test if a point is on a plane, is it with a distance equal to 0?
Python Script please…
rs.IsPointOnPlane not exist?
how can i test if a point is on a plane, is it with a distance equal to 0?
Python Script please…
rs.IsPointOnPlane not exist?
Edit: Adding tolerance as @Jess explained:
DistanceToPlane(plane, point)
Returns the distance from a 3D point to a plane.
import rhinoscriptsyntax as rs
point = rs.GetPoint("Point to test")
if point:
plane = rs.WorldXYPlane()
distance = rs.DistanceToPlane(plane, point)
if abs(distance) <= rs.UnitAbsoluteTolerance():
print "Your point is on WorldXY plane"
else:
print "Distance to WorldXY plane: ", distance
I would use this:
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Plane_DistanceTo.htm
(not fast enough…)
I would use some tolerance, otherwise the point test may always fail
tolerance =0.00001
if abs(distance) <= tolerance :
Thank you, but why there is:
IsPointOnSurface,
IsPointOnMesh,
IsPointOnCurve,
but no IsPointOnPlane?
it’s strange, no?
Yeah, it’s not in vb Rhinoscript either. I guess since a RhinoCommon method exists for simple stuff like this, that they haven’t made implementing it a priority.
Yep -
import rhinoscriptsyntax as rs
import Rhino
pt=rs.GetPoint()
wxy_plane=Rhino.Geometry.Plane.WorldXY
#use whatever tolerance you want
tol=Rhino.RhinoMath.SqrtEpsilon
if abs(wxy_plane.DistanceTo(pt))<tol:
print "Point is on World XY plane"
else:
print "Point is NOT on World XY plane"
One important point to note is that with this function, the distance is signed relative to the plane normal - so it could be negative if the point is “behind” the plane. This is unusual for distance functions in Rhino which are most often unsigned (always positive)