Notifications
Clear all

[Closed] How to align a plane from 4 points?

Hi all, i need a help please:
How to align a plane from 4 points?
I found this script but only for 3 points:

thePlane = Plane()
p1 = point pos:[40,-10,30]
p2 = point pos:[20,30,40]
p3 = point pos:[-10,-20,30]
ctrl = transform_script()
thePlane.transform.controller = ctrl
ctrl.addNode “p1” p1
ctrl.addNode “p2” p2
ctrl.addNode “p3” p3
txt = “v1 = normalize (p2.pos-p1.pos)

txt += “v2 = normalize (p3.pos-p1.pos)

txt += “nv1 = normalize (cross v1 v2)

txt += “nv2 = normalize(cross nv1 v1)

txt += “matrix3 v1 nv2 nv1 ((p1.pos+p2.pos+p3.pos)/3)”
ctrl.setExpression txt

Thank, thanks in advance.

2 Replies
 3ak

any 3 points always form a plane, but not 4. You need to check if all of your 4 points are in the same plane and only then align your plane.
possible check:
if dot (cross (p2 – p1) (p3 – p1)) p4 == 0 then all your points are in one plane. And you can take any 3 from these 4 points to align your plane (use your script for example)

3ak, thanks for the explanation