ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# orient a 3d layer between multiple 3d nulls

FAQ   •   VIEW ALL
 orient a 3d layer between multiple 3d nulls on Jul 23, 2014 at 3:44:37 am

is it possible to orient a 3d layer between multiple 3d nulls. it seems like there should be a way to orient a 3D layer between 3 nulls.

 Re: orient a 3d layer between multiple 3d nullson Jul 23, 2014 at 2:29:26 pm

[Jason McKee] "is it possible to orient a 3d layer between multiple 3d nulls. it seems like there should be a way to orient a 3D layer between 3 nulls."

In the meantime, try these expressions.

Position:
```// applied to the position parameter, this expression computes the triangular centroid of a plane defined by three points p1 = thisComp.layer("Null 1").transform.position; p2 = thisComp.layer("Null 2").transform.position; p3 = thisComp.layer("Null 3").transform.position; // the centroid is the average of these points centroid = div(p1+p2+p3,3); ```

Orientation:
```// applied to the orientation parameter, this expression looks down the normal of the a plane defined by three points from its centroid p1 = thisComp.layer("Null 1").transform.position; p2 = thisComp.layer("Null 2").transform.position; p3 = thisComp.layer("Null 3").transform.position; // the centroid is the average of these points centroid = div(p1+p2+p3,3); // the normal vector of a plane is (p2-p1) x (p3-p1) n = normalize(cross(p2-p1,p3-p1)); // use lookAt to get the orientation necessary to look along the normal vector from the centroid lookAt(centroid,centroid+n)```

Walter Soyka