Activity › Forums › Adobe After Effects › I think I need an expression for this:
-
I think I need an expression for this:
Posted by Riccardo Sinti on January 8, 2006 at 1:39 amI have a circle which travels around the circumference of a larger circle. I want to scale the larger circle and have the smaller circle remain revolving around the circumference without also scaling.
How can I achive this?Thanks
Riccardo Sinti replied 20 years, 4 months ago 4 Members · 9 Replies -
9 Replies
-
Joe Chao
January 8, 2006 at 4:26 amYou can surely achieve it by means of expressions. Here are my suggestions:
1. Creat 2 circles. The bigger one will be named as
-
Riccardo Sinti
January 8, 2006 at 4:53 pmThanks for the expression but it is not working as I need it to.
Sure enough this lets me scale the big ball while the small ball remains the same size and locks the small ball to the perimeter of the big ball, great.
But I can’t get the rotation to work. Rotating the big ball makes the small ball travel inside the perimeter of the big ball.
I think I need a full semester course in expressions including remedial math trigonometry. -
Filip Vandueren
January 8, 2006 at 6:18 pmYour small ball is probably still parented to the big ball.
break the parent-link.
Joe’s script takes care of the parenting, unless your bigball is again parented to something else.
BTW: the last line of Joes script should also be “[a+x,b-y]”, otherwise the ball would turn counter-clockwise.if the bigball is indeed parented and it needs to be parented, use this script:
bb=thisComp.layer("bigball");
dia=400;
bb.toComp(bb.anchorPoint-[0,dia/2]);
this will even work if the bigball is a 3D layer and rotated at any angle in space.
Just keep the small ball unparented and 2D -
Riccardo Sinti
January 8, 2006 at 6:43 pmNo that still doesn’t work, I want the small circle to look like it is rolling along the perimiter of the big circle.
with this expression the center of the small ball is locked to the perimeter.
If I try to move the small ball anchor point so that it is edge to edge witht the big ball it doesn’ stick to the edges while rotating.
I guess I forget to mention that. -
Filip Vandueren
January 8, 2006 at 8:57 pmSo the two lock together like cogwheels, correct ?
But when the big ball scales, the small ball doesn’t, though they will keep touching.
Then, when the big ball rotates, they still match in ‘contact’ speed ? (oh-oh 😉 )Hmmm…
This is a tougher problem.There is no direct relation or formula between the current diameter of the big ball an the current angle at which it has rotated.
The expression would have to re-calculate all the previous frames, every frame, so it could become quite slow.What are you trying to achieve ? perhaps there’s a better way.
-
Sam Moulton
January 9, 2006 at 10:59 amI had a similar project recently for my client that build transmissions for robotic systems. I don’t know much about trig but simple algebra might work…
you can get the position of the SmallWheel adding the radius of the LargeWheel to the radius of the SmallWheel. The radius of the large wheel must be corrected for scale. The expression looks like this –
offset = thisComp.layer(“LargeWheel”).width/2 * thisComp.layer(“LargeWheel”).scale[0]/100 + width/2;
[value[0] + offset, value[1]]Now you can add a null to the project named Rotate and use parenting so that rotating the null will move the small wheel around the large one.
to make the SmallWheel roll around the edge of the large wheel divide the diameter of the large wheel by the small wheel after correcting the diameter of the large wheel for scale to get the gear ratio between the wheels. The rotation of the null is then multiplied by the ratio of the two wheels. I don’t remember enough trig to approach the problem from the same direction that Riccardo did, but simple ratios work for meshing gears and they work fine here too
scaleCorrection = thisComp.layer(“LargeWheel”).scale[0]/100;
ratio = thisComp.layer(“LargeWheel”).width * scaleCorrection / width;
nTurns = thisComp.layer(“Rotate”).rotation;
r = nTurns * ratiothis will work perfectly as long as all the layers are at the default position and everything is square pixels including the comp. to change position of the wheels just nest the comp in another one.
If you get lost I can e-mail you a comp…
gee, this is fun…
-
Joe Chao
January 9, 2006 at 11:59 amI have just been back from work. Well, it seems I made a mistake in my expression. Thank you, Filip.
Now, I think what Riccardo wanted is to make the two circles work like a couple of gears. So I adjusted my expressions, now they look to be working better.
1. Creat 2 circles. The bigger one will be named as
-
Sam Moulton
January 9, 2006 at 5:20 pmI just looked at the question again and Ricards’s solution. If you want to drive the little wheel by the big wheel rotation instead of a null you can just change the rotation expression to use the opposite of the rotation of the big wheel. That looks like this:
scaleCorrection = thisComp.layer(“LargeWheel”).scale[0]/100;
ratio = thisComp.layer(“LargeWheel”).width * scaleCorrection / width;
nTurns = thisComp.layer(“LargeWheel”).rotation;
r = – nTurns * ratioThen you could use the null for Position for both the wheels and then you would not have to nest the comp.
the only thing that will foul up solving the problem this way is animating the scale at the same time that the layers are rotating.
-
Riccardo Sinti
January 10, 2006 at 9:22 pmWOW thanks for all the interest in this problem.
The project is over and I used brute force keyframing to keep the small ball attached to the big ball, but when I get a moment I will try to wrap my head around these expressioins to understand just how you figured out how to do them.Thanks Very Much
Reply to this Discussion! Login or Sign Up