Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- Home
- After Effects
- Discussions
- Calculate Orientation from 3D plane equation with ...

- Calculate Orientation from 3D plane equation with ...

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

/t5/after-effects-discussions/calculate-orientation-from-3d-plane-equation-with-respect-to-origin/td-p/13131147
Aug 12, 2022
Aug 12, 2022

Copy link to clipboard

Copied

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.

TOPICS

Expressions

Community guidelines

Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

13
Replies
13

/t5/after-effects-discussions/calculate-orientation-from-3d-plane-equation-with-respect-to-origin/m-p/13131174#M208098
Aug 12, 2022
Aug 12, 2022

Copy link to clipboard

Copied

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

Community guidelines

Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

/t5/after-effects-discussions/calculate-orientation-from-3d-plane-equation-with-respect-to-origin/m-p/13131571#M208122
Aug 12, 2022
Aug 12, 2022

Copy link to clipboard

Copied

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.

Community guidelines

Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

/t5/after-effects-discussions/calculate-orientation-from-3d-plane-equation-with-respect-to-origin/m-p/13132168#M208149
Aug 12, 2022
Aug 12, 2022

Copy link to clipboard

Copied

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 guidelines

/t5/after-effects-discussions/calculate-orientation-from-3d-plane-equation-with-respect-to-origin/m-p/13132319#M208158
Aug 12, 2022
Aug 12, 2022

Copy link to clipboard

Copied

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.

Community guidelines

/t5/after-effects-discussions/calculate-orientation-from-3d-plane-equation-with-respect-to-origin/m-p/13132534#M208173
Aug 12, 2022
Aug 12, 2022

Copy link to clipboard

Copied

Community guidelines

/t5/after-effects-discussions/calculate-orientation-from-3d-plane-equation-with-respect-to-origin/m-p/13133165#M208196
Aug 13, 2022
Aug 13, 2022

Copy link to clipboard

Copied

The problem is that there are 4 points on the corners on a rectangle. Only tying 3 of them to the position of 3 of them means one of the angles is ignored, so the four corners do not represent the orientation of the virtual four-cornered plane created by the polygon.

A square or rectangle would create an orientation of 0º, 0º, 0º but any kind of trapezoid (scalene, acute, obtuse, isolees, or right), or any four sided polygon with no right angles will modify the orientation. If you also calculated the center, you could get the distance from the camera or point of view. All of those values would be required to make a 3D layer match the parallax represented by the 2D polygon.

That sounds like a problem on a final exam for a Masters Degree in Mathematics. Unfortunately, I studied Performing Arts and Music.

Community guidelines

/t5/after-effects-discussions/calculate-orientation-from-3d-plane-equation-with-respect-to-origin/m-p/13133278#M208198
Aug 13, 2022
Aug 13, 2022

Copy link to clipboard

Copied

One more note on the problem. I have created a mask or a path on a 2D layer, used Points Follow Nulls, made the nulls 3D, then parented the nulls to a 3D layer to generate all kinds of path animations that would be impossible to achieve by just animating the path. I've used the result for HUD displays. Here's a sample I through together with a 2D shape layer rectangle that follows the perspective of a 3D layer.

Goofy Path.

Matching Perspective:

It might be useful to work the other way around and have a four-sided polygon control a 3D layer's position and orientation. I think that may be what the OP is asking for.

The project file is attached if anyone is interested.

Community guidelines

/t5/after-effects-discussions/calculate-orientation-from-3d-plane-equation-with-respect-to-origin/m-p/13138618#M208468
Aug 16, 2022
Aug 16, 2022

Copy link to clipboard

Copied

Community guidelines

/t5/after-effects-discussions/calculate-orientation-from-3d-plane-equation-with-respect-to-origin/m-p/13133312#M208201
Aug 13, 2022
Aug 13, 2022

Copy link to clipboard

Copied

That sounds like a problem on a final exam for a Masters Degree in Mathematics.

Perhaps not, but at the very least it's a lot of code.

- Check, whether the underlying triangles constituting the plane are co-planar to determine if the quad is plausible eitehr using matrices or conventional vector math
- Do so for all four possible triangles to determine convexity if wanted
- Calculate the center point
- Create an inverse projection matrix for the camera or a parallel projection
- Calculate the intersections of the points to a plane aligned with the camera
- Project the intersections back into the scene and iteratively fit the plane until your precision threshold is reached

So it is doable, just not with two lines of code and of course you may have additional matrix conversions simply from AE's 3D space vs. layer space plus you need safeguards if the points aren't co-planar.

Mylenium

Community guidelines

karthik25626987732b
AUTHOR

New Here
,

/t5/after-effects-discussions/calculate-orientation-from-3d-plane-equation-with-respect-to-origin/m-p/13137387#M208397
Aug 16, 2022
Aug 16, 2022

Copy link to clipboard

Copied

Sorry about the points error. I have updated points and applied your above expression to the blue plane in the attached render.

Seems like working fine but, as points are not coplanar, is it necessary to add 4th point "D" to the calculation above to get orientation precision. PFL attached.

Community guidelines

/t5/after-effects-discussions/calculate-orientation-from-3d-plane-equation-with-respect-to-origin/m-p/13138604#M208465
Aug 16, 2022
Aug 16, 2022

Copy link to clipboard

Copied

Hi Dan,

Hope your doing well.

I tried your solution in the attached aep file.

Calculated Orientation with your expression for 2 plane equations below.

x+2y-z=5;

x-4y+z=3

Calculated equation for Line of Intersection for above 2 equations and came up with below parameter for x,y,z

to calculate 2 points to draw a line using createPath().

x=t+4;

y=t;

z=3t-1;

Problem is that the intersection line is a little off and not exactly on the Intersection.

Don't know where it went wrong.

Request you to have a look at it. I have shared a snapshot and aep file as well.

Community guidelines

/t5/after-effects-discussions/calculate-orientation-from-3d-plane-equation-with-respect-to-origin/m-p/13139826#M208505
Aug 17, 2022
Aug 17, 2022

Copy link to clipboard

Copied

I downloaded your comp, and I'm not sure what is supposed to happen. The only expression that looks at another layer is the expression for Path on Layer 3. None of the other expressions pull any data from any other layer. If you change the position or rotation values of layer 4 or 5, the path on layer 3 does not move.

The only thing your vector math expression does is fix the orientation property of layers 4 and 5. The orientation is tied to no other layer or property. The expressions do nothing that simply setting an orientation value could not do.

It would really help if you would tell us what you are trying to accomplish.

Community guidelines

Explorer
,

LATEST
/t5/after-effects-discussions/calculate-orientation-from-3d-plane-equation-with-respect-to-origin/m-p/13148650#M208875
Aug 21, 2022
Aug 21, 2022

Copy link to clipboard

Copied

Am trying to do the below in after effects 3D. Intersection of Planes.

https://www.geogebra.org/m/QUbAFBa9

I have couple of Plane equations and i have to find out line of intersection of those.

Equations used in this example are from below link.

https://www.youtube.com/watch?v=o7CfCDkRwfY

x+2y-z=5 && x-4y+z=3

My Workaorund is like below.

1. Create 4 sample x,y array and pipe those in equation to find z.

[500,500], [-500,500], [-500,-500], [500,-500]

2.We have four [x,y,z] for an equation now and i can use create path to create a plane. But, i need to show two planes intersecting (i.e cutting through) just like 3D layers cut through, but create path is 2D system.

3.So, using Dans expression and 4 coordinate points now i can orient a plane which matches the plane created using createPath().

4.Next job is Line of intersection, made 2 nulls by following that youtube session and used create path to draw a line.

5. Now the next problem is that plane always just orients from origin [0,0,0], what would be the logic to shift in position according to equation.??

Thanks for you time Rick, It would be of great help if u can provide the logic for position offset for plane just like how it looks in that geogebra link. The plane is not at origin. what makes the shift and which direction it ll shift? What is the logic?

Community guidelines

Make your promotional social content with Adobe Express.

Get started quickly with free templates:

Related to **video creation**

Resources

Troubleshooting FAQs

After Effects Community Recap

Getting started with After Effects

Using the Community
Experience League
Terms of Use
Privacy Policy
Cookie preferences
AdChoices
Language:

- Deutsch
- English
- Español
- Français
- 日本語コミュニティ
- Português
- 한국어

Copyright © 2022 Adobe. All rights reserved.