Activity › Forums › Adobe After Effects Expressions › 2d position to sphere
-
Peter Menich
April 2, 2008 at 9:44 pmHey Dan,
After a bit of giggery pokery this works!
xRot = degreesToRadians(linear(value[0],0,thisComp.width, -90, 270));
zRot = degreesToRadians(linear(value[1],0,thisComp.height, -180, 0));Thanks to you and Darby for all your help.
-
Jorge Hernández
August 28, 2009 at 3:01 amI have no knowledge whatsover about trigonometry, algebra, or whatever you call the transformations and equations being worked out here, so I will simply ask and hope to be delivered ^_^
Can I complicate things a bit further?
What modifications should be necessary so that, from the viewer’s default POV:
1. At 0,0,0, the satellite object is right in front of the center object.
2. with x<0 the satellite orbits towards the left, and with x>0 it orbits towards the right. Similarly, with y>0 it orbits upwards, while with y<0 it orbits downwards. I.e., a value of x= ±180 brings the satellite right behind the object, and a value of y=±90 brings the satellite to either of the two poles.
3. x, y values behave like rotation degrees, and thus can loop. I.e., x or y =±360 makes a full 360° orbit, and with values >360 or <-360 the satellite keeps orbiting in the same direction. 4. z value adds or subtracts from the radius specified in the center object's slider.
-
Filip Vandueren
August 28, 2009 at 3:16 pmThats pretty easy actually.
I assume you\’re deriving the x,y,z from the position of a null?
Position your sattelite at the exact same. Position as the planet.
Add this expression to anchorpoint:
z=thisComp.layer(\”Null 1\”).position[2];
value+[0,0,z];then directly pickwhip the satellite\’s xrotation to the nulls X- position
and the yrotation to the y-position. -
Jorge Hernández
October 27, 2009 at 9:38 amI see now I did not even say thanks. Thanks! Works like a charm.
As slight change for added intuitiveness was pickwhip the satellite\’s xrotation to the nulls yposition
and the yrotation to the xposition, and setting it to negative with a minus in front.I was not trying to deriving the x,y,z from the position of a null, but from the position values of the satellite itself, so that once an initial value was set, scrolling over its position values changed its position in the orbit. Still I can perfectly put up with an additional controller object.
Thanks again!
-
Geert Schaap
August 22, 2020 at 8:41 pmFirst post here, I’m probably aware that i might cross some rules…
I’m trying to wrap my head around the trigonometry involved to compute the 3D coordinates on a sphere from a 2D (x/y) point. I understand that trigonometry is a subject given on schools in the US, but i’m afraid that my school didn’t touch the subject at all. I got myself a Brilliant subscription and so far so good (not fully used to the english trigonometry terms though!)
So, to get the corresponding coordinates in need to calculate the following (if I’m correct):
Theta: tan ( y-coordinate / x-coordinate )
Phi: sin ( y-coordinate / radiant)x = radiant * cos(theta) * sin(Phi)
y = radiant * sin(theta) * sin(phi)
z = radiant * cos(phi)so then in the expression menu I put the following:
x = transform.position[0];
y = transform.position[1];
r = 250
phi = Math.sin(y,r);
theta = Math.atan2(y,x);[r*Math.cos(theta)*Math.sin(phi), r*Math.sin(theta)*Math.sin(phi), r*Math.cos(phi)]
For some reason the coordinates sometimes match, and sometimes completely shift positions.
I think I might’ve gotten to cocky after getting a few good answers on the brilliant puzzels …If somebody could point me in the right direction, I would be very thankful!
Kind regards,
-
Dan Ebberts
August 23, 2020 at 2:52 pm>compute the 3D coordinates on a sphere from a 2D (x/y) point.
What do you mean by that, exactly?
Dan
-
Geert Schaap
August 24, 2020 at 9:00 amHey Dan,
thanks for replying and taking the effort to look into my attempt at trigonometry!
So I got the x and y position of a point on a circle, and i’d like to compute the x, y and z position of that point on a sphere with the same radius of the circle with the same origin point. So lack in other words: trying to make an 3d representation of an 2D image of a circle with a point on it.
Here’s an example on an image.
So the expression used show relatively good results with the given point in the above example. The expression is applied to the position of the point itself. The point is parented to the center of the sphere.
But when I input points outside of that quadrant of the circle, the positions seems to shift more drastically. (I changed the radius in the expression to -250 to make the objects appear in front of the AE composition). Here’s another example image:
It looks like i’m missing some important information to be able to compute the exact x, y and z position of the given point.
If you could point me in the right direction I would be very grateful!
Kind regards,
x = transform.position[0];
y = transform.position[1];
r = -250
phi = Math.sin(y,r);
theta = Math.atan2(y,x);[r*Math.cos(theta)*Math.sin(phi), r*Math.sin(theta)*Math.sin(phi), r*Math.cos(phi)]
-
Dan Ebberts
August 24, 2020 at 5:23 pmI think something like this will give you the z:
x = position[0];
y = position[1];
r = 250;d = Math.min(Math.sqrt(x*x + y*y),r);
a = Math.acos(d/r);
z = -r*Math.sin(a);Dan
-
Geert Schaap
August 25, 2020 at 9:13 amThat seems to do the trick!
I’m going to see if I can back track the steps to wrap my head around it!
Thanks again!
Reply to this Discussion! Login or Sign Up

