Place and orient layer on a plane formed by three points

Moderators: Disciple, zlovatt

Post Reply
Posts: 1
Joined: June 12th, 2004, 5:31 am
Location: Brussels


When I import data from a 3D soft or from a 3D tracker into AE, I need to place and orient a layer to some nulls coming from the 3D data. Instead of adjusting this manually you can use the following expression. Remember that this expression uses three nulls/lights/layers that should be placed on top of the layer to be placed.

Position expression:

Code: Select all

a = thisComp.layer(thisLayer, -1).position;
b = thisComp.layer(thisLayer, -2).position;
c = thisComp.layer(thisLayer, -3).position;


This places the layer in the middle of the three points.

You then have to add an expression for the orientation :

Code: Select all

a = thisComp.layer(thisLayer, -1).position;
b = thisComp.layer(thisLayer, -2).position;
c = thisComp.layer(thisLayer, -3).position;

n = cross ((a-b),(a-c));
orientation+lookAt(a, n)

This will orient the layer to be parallel with the plane formed by the three points. You'll need to manually adjust the Z orientation though.

Any feedback or suggestions to make it better are really apreciated.

Donat Van Bellinghen
Posts: 7
Joined: June 17th, 2004, 1:58 pm

I wish I had looked at this a couple of weeks ago as we were doing a lot of camera tracking and had to do exactly what this script is designed for, eyeing it in manually is no fun at all!!
As soon as I get a chance I'll try it out and let you know how it goes.
Glenn Stewart
1k Studios
Posts: 1
Joined: August 3rd, 2007, 11:15 am

Hi Donat

I've been trying to use this expression. It seems straight forward.
But when I apply it to a layer with 3 null points in space, the plane does not intersect the 3 null points.
Furthermore, if I change the order of the nulls the Normal changes. I don't get this... the normal would be the same whatever the order, at worst it would reverse direction, but not the orientation.
I cant figure out where its going wrong. The Maths are sound, so why doesn't this work for me. Grrrr!
I could have really used this today.
Any chance of a teeny weeny project example to put my hurting brain at its ease.
Posts: 128
Joined: December 7th, 2007, 10:11 am


I've check this expression and it worked for me !
I've used the same scenario you've described: 3 Null layers in 3D space in order to position and orient a solid according to them, and it worked great.

Note however for a few things:
1. You have to put the 3D layer JUST below the 3 Nulls.
2. Perhaps your layer is too small and that is why it doesn't intersect the 3 Null points ?
3. Try using square pixels.

Post Reply