IsVectorParallelToPlane

what is the simpler way to verify if a vector or a line is parallel to WorldXYPlane?

i Can substract Z coordinates of the start and the end point of the line, if it’s equal to 0 the line is parallel.

Something like this might work for you:



210304_PlaneVectorParallelCheck_00.gh (5.1 KB)

Note that Plane.DistanceTo returns the signed distance, so you can also use it to figure out which side of the plane the vector is pointing.

1 Like

ok…:wink:

i don’t understand the syntax… you don’t have to import scriptcontext? for rhinocommon?
because you are in GH?

I don’t use enought scripting to learn rhinocommon… there is so much methods for so much entities… how can you find solution… “Chapeau Bas les artistes!!!”

Plane.DistanceTo method ask for test points… where Pln.Origin + vec is point?

You can also check the vector to see if it is perpendicular to the plane’s normal within tolerance:

import rhinoscriptsyntax as rs
import scriptcontext as sc

#makes a plane at 45 degrees along Y axis
pt_0=rs.coerce3dpoint([0,0,0])
pt_1=rs.coerce3dpoint([1,0,1])
pt_2=rs.coerce3dpoint([0,1,0])
plane=rs.PlaneFromPoints(pt_0,pt_1,pt_2)

#makes a parallel vector
vp_0=rs.coerce3dpoint([0,0,10])
vp_1=rs.coerce3dpoint([10,0,20])
vectA=vp_1-vp_0

#makes a non-parallel vector
vp_2=rs.coerce3dpoint([0,0,10])
vp_3=rs.coerce3dpoint([10,0,10])
vectB=vp_3-vp_2

atol=sc.doc.ModelAngleToleranceRadians
#compare
print vectA.IsPerpendicularTo(plane.Normal,atol)
print vectB.IsPerpendicularTo(plane.Normal,atol)
1 Like

Not when you’re calling properties/methods directly on an input object (e.g. the Pln variable in this case).

Correct, I get the plane’s origin point and move this out by the input vector using the + operator. This is the same as calling the Point3d.Addition method, but terser (and more elegant IMO).