Skip to main content
Participant
August 12, 2022
Question

Calculate Orientation from 3D plane equation with respect to origin.

  • August 12, 2022
  • 3 replies
  • 2146 views

Hi there,

Plane equation used to generate 4 points is : 1x + 2y + 8z = 4.

Generated 4 points like attached and made a plane using createPath() for reference.

 

What i actually need is a orientation or rotation value to apply to a 3D solid layer transform rotation or orientation so that it matches with that reference shape created by createPath() using 4 points.

 

Rendered a small clip for reference.

This topic has been closed for replies.

3 replies

Dan Ebberts
Community Expert
Community Expert
August 12, 2022

In your preview, all your points seem to have the same value, so I'm assuming that's not correct. Assuming the points define a rectangle and the layer's anchor point is at the center of the rectangle, you should be able to use a little vector math and get an orientation expression like this:

A = [-385,-385,-46.2];
B = [385,-385,-46.2];
C = [385,385,46.2];

Vx = normalize(A-B);
Vy = normalize(C-B);
Vz = cross(Vx,Vy);

center = toWorld(anchorPoint);

lookAt(center + Vz, center)

but it depends on a number of assumptions that may not be correct...

Community Expert
August 13, 2022

Dan, if I create a shape layer rectangle, then convert it to a Bezier Path, then use Points Follow nulls and make the nulls 3D, I can get the path to follow the nulls even when moved in 3D space.

 

If I create a new 3D layer and add your expression to the Orientation, then tie 3 of the nulls to the A, B, and C values in your expression, I can kind of control the Orientation of the 3D layer but it is off. I thought you would need 4 points to establish the plane. 

I've uploaded the Project file.

 

This is a really interesting problem.

Dan Ebberts
Community Expert
Community Expert
August 13, 2022

Rick, I'm not sure what's going on there. It looks like the nulls aren't all in the same plane, and I'm not sure what AE does in that case. I assume it must have to draw the shape in a single plane, so I don't know how it would figure out where that should be. You only need three points to define a plane (as long as they're not all on the same line).

Community Expert
August 12, 2022

I have no idea how to write the calculations in Javascript, but I found the basic math involved in that kind of calculation. You will have to figure out how to make those calculations with Javascript.

 

toComp and toWorld will reveal the 2D position of a 3D layer, but I don't think there is any way to use those functions to take the 3D position of a point (a 3D null's position) and combine it with at least two other points to generate X, Y, and Z, or Orientation values. If anyone would know, it would be Dan Ebberts. 

Mylenium
Legend
August 12, 2022

You need to construct a matrix and decompose the angles from it or calculate the angles from the imaginary edges of the triangles of the plane.

 

Mylenium