• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
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

Views

459

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
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...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
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. 

RickGerard_0-1660353126965.png

I've uploaded the Project file.

 

This is a really interesting problem.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 12, 2022 Aug 12, 2022

Copy link to clipboard

Copied

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).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
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.

goofyPath.gif

Matching Perspective:

matching perspective.gif

 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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 16, 2022 Aug 16, 2022

Copy link to clipboard

Copied

For me as an artist, this is tough to achieve unless you provide solutions with expressions written as an example to try it out. As far as i know, many artists are not good at math or at least me. So, instead of describing the steps I sincerely request you to provide a very tiny example with expression or like the aep file attached, it would be of great help. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 13, 2022 Aug 13, 2022

Copy link to clipboard

Copied

quote

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
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.

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 21, 2022 Aug 21, 2022

Copy link to clipboard

Copied

LATEST

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?

Votes

Translate

Translate

Report

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