PlanePlane Angle python

i would like to return by a script the angle between two planes, since this morning, i tried 5 or 6 kind of script, with rs.angle(), and rs.angle2, but it doesn’t match as i want.
my last script:

def AnglePlanPlan(planT,planM):
    #uplanMDomain=rs.SurfaceDomain(planM,0)
    #vplanMDomain=rs.SurfaceDomain(planM,1)
    ptplanT=rs.EvaluatePlane(planT,[0,0])
    ptplanM=rs.EvaluatePlane(planM,[0,0])
    inter=rs.PlanePlaneIntersection(planT,planM)
    ptmid=(inter[0]+inter[1])/2
    lineinter=rs.AddLine(inter[0],inter[1])
    inter90=rs.RotateObject(lineinter,ptmid,90,planM.ZAxis)
    normal=rs.VectorCreate(inter[0],inter[1])
    rotateplane=rs.RotatePlane(planM,90,rs.CurveEndPoint(inter90)-rs.CurveStartPoint(inter90))
    #rs.AddRectangle(rotateplane,500,500)
    inter1A=rs.PlanePlaneIntersection(planT,rotateplane)
    inter2A=rs.PlanePlaneIntersection(planM,rotateplane)
    angle=rs.Angle(ptmid,inter1A[1],rotateplane)
    print angle
    return angle[0]

def Plan(surf):
    Usurfdomain=rs.SurfaceDomain(surf,0)
    Vsurfdomain=rs.SurfaceDomain(surf,1)
    u=(Usurfdomain[0]+Usurfdomain[1])/2
    v=(Vsurfdomain[0]+Vsurfdomain[1])/2
    eval=rs.EvaluateSurface(surf,u,v)
    vect=rs.SurfaceNormal(surf,[u,v])
    plan=rs.PlaneFromNormal(eval,vect)
    return plan

def TAutomatique():
    edge=rs.GetEdgeCurves('sélectionne le bord de surface à tenoner!',min_count=1,max_count=1)
    if edge== None:return
    surf=rs.GetSurfaceObject('selectionne la surface à mortaiser!')
    if surf==None:return
    planT=Plan(edge[0][1])
    planM=Plan(surf[0])
    angle=AnglePlanPlan(planT,planM)
    print angle
    rs.DeleteObject(edge[0][0])
    pass
   
if __name__ == "__main__":
    TAutomatique()

in fact i have 2 planar surfaces, and i want to return the angle between this 2 surfaces.
rs.angle2() always return the smallest angle, and rs.angle() return the angle on a plane, and it’s here where i stopped, i don’t find the good way for the construction of this plane, to return every time and every configuration the good angle
image

Hi @onlyforpeace,

The angle between planes is equal to the angle between their normal vectors. Google has a lot of info on this. Or you can just use Vector3d.VectorAngle.

https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Vector3d_VectorAngle.htm

– Dale

Ok, I’ll try it…

I don’t understand … the image below shows two symmetrical surfaces, so their angle to the horizontal surface is the same, but reversed, when I run my script, it sends me the same angle … 70,26°.

image

I would like to be able to return this difference, once 70,26° for one and 109,74° for the other.

Hi,

Could it be the normal of the surface plane is symmetrical?
If both planes point ‘up’ the angle for both is 70,26°

Does this make sense?

-Willem

I was thinking one +70 and the other -70 no?