Expressions/Scripts/Presets

Moderators: Disciple, zlovatt

Donat
Topic Author
Posts: 1
Joined: Sat Jun 12, 2004 5:31 am
Location: Brussels
Contact:

### Place and orient layer on a plane formed by three points

Hi,

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:

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

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

You then have to add an expression for the orientation :

``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
----
Donat Van Bellinghen

glennser
Posts: 7
Joined: Thu Jun 17, 2004 1:58 pm

### If only I'd looked at this a couple of weeks ago

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

dkvfx
Posts: 1
Joined: Fri Aug 03, 2007 11:15 am

### Re: Place and orient layer on a plane formed by three points

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.

kobyg
Posts: 128
Joined: Fri Dec 07, 2007 10:11 am

### Re: Place and orient layer on a plane formed by three points

dkvfx,

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.

Koby.

### Who is online

Users browsing this forum: No registered users and 1 guest