ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Mechanical cam slot rotation - calculating pointOnPath distance to null point?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
George Umanov
Mechanical cam slot rotation - calculating pointOnPath distance to null point?
on Feb 11, 2019 at 2:58:55 am

Hey guys,

I'm wondering if it's possible to use the function "pointOnPath" to find the point along a path that is closest to a specific null.
My ultimate goal is to rotate a "cam-slotted plate" in such a way that the cam pin always stays within the slot inside the plate.
(See photos below for a visual guide.)

Initial position


Rotated input lever (cam pin) by -25 degrees


The yellow null is parented to the "cam pin" (upper brown circle).
The green path is the path within the slot that the pin should move along.
The blue null is the pointOnPath - point along the green path.

The idea is to create a function that will rotate the slotted plate by the degrees required where the distance between yellow null and blue null will be (almost) zero.

The range of motion for the plate is physically limited to 0 through approx -36. It stays stationary at 0 degrees when the cam pin rotates in the positive direction, due to the slot shape.

I believe this may be possible by iterating through the possible rotations (0 to -36) while constantly checking for the distance between yellow null and approx 100 possible positions for the blue null? and when the distance is close to 0, use that rotation amount. I'm just not experienced in writing functions from scratch..

Any help is much appreciated!
Thank you


Return to posts index

George Umanov
Re: Mechanical cam slot rotation - calculating pointOnPath distance to null point?
on Feb 11, 2019 at 3:06:57 am

Forgot to link to the AE files

http://curious.ninja/wp-content/uploads/misc/cam-slot.zip


Return to posts index

Alex Printz
Re: Mechanical cam slot rotation - calculating pointOnPath distance to null point?
on Feb 11, 2019 at 4:40:07 pm

Sounds like a good challenge;lately I've been working with recursive searches and subdividing+calculating bezier curves so I might take a stab at this; but in the meantime, the shorthand would be to use the rotation as an input and filter it through a pre-defined output curve; I do this by translating a property into a 'time' value and referencing the keys.

Try pasting this keyframe data into your KA350 - CAM PLATE rotation property; go into the curves editor and convert them all to auto-ease and make the first one an easy-ease key. Adjust the slopes of the keys as necessary.



Adobe After Effects 8.0 Keyframe Data

Units Per Second 25
Source Width 336
Source Height 562
Source Pixel Aspect Ratio 1
Comp Pixel Aspect Ratio 1

Transform Rotation
Frame degrees
0 0
39 -2.7894
149 -14.8612
250 -27.8363

Expression Data
valueAtTime(linear(thisComp.layer("Cam input lever").rotation,0,-36,key(numKeys).time,key(1).time))
End of Expression Data


End of Keyframe Data


Alex Printz
Mograph Designer


Return to posts index


George Umanov
Re: Mechanical cam slot rotation - calculating pointOnPath distance to null point?
on Feb 11, 2019 at 11:17:13 pm

Well.. that's pretty impressive.
Thank you for the quick solution!

This trick will come in handy for rotating several other parts of the mechanism as well ☺

Let me know if you get anywhere with the pointOnPath method - although this seems to work nicely, so don't waste too much time.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]