2 Replies Latest reply on Feb 17, 2017 6:34 AM by Rick Gerard

    How to move a triangle along the chord of one circle and the center of another


      I am quite new to After Effects. I am trying to move a triangle along the chord of one circle and the center of another. Moving the smaller circle from the bigger one is not an issue, but how to transform the triangle to change shape between the circles is an issue for me. Please see the image below which gives a better idea of what I want to achieve. I would really appreciate some help.


      Screen Shot 2017-02-17 at 11.47.46 AM.png

        • 1. Re: How to move a triangle along the chord of one circle and the center of another
          Mylenium Most Valuable Participant

          Animate a mask or shape layer to form the triangle. If this in any way needs to be mathematically exact, than a more complex approach using other methods and involving expressions will be required.



          • 2. Re: How to move a triangle along the chord of one circle and the center of another
            Rick Gerard Adobe Community Professional & MVP

            From your explanation this looks like a very difficult problem to solve mathematically. Unfortunately the polygon tool in After Effects does not let you set the length of the individual sides of a triangle. What you can do is break the link between x and y scale values and animate the scale of the triangle layer so that it follows the contour of the circle. This will require 2 keyframes for position for the small circle and the triangle, three keyframes for scale on the triangle and some modification of the temporal curve using the graph editor to make things line up.


            Start by creating a single circle shape layer anywhere in the composition using the Ellipse tool and holding down the shift key to create a perfect circle. The size does not matter right now. When the circle is created name the layer Circle 1 and press the u key twice to reveal all of the modified properties of the layer. Select the size and set it to 200 then tab down to Ellipse 1>Transform Ellipse 1>Position and set both x and y to zero. This will center your circle on the anchor point.


            Now duplicate the Circle 1 layer using the keyboard shortcut Ctrl/Cmnd + d. The size property will still be visible on layer so change it to 300 and if you like change the color.


            Now create a new shape layer on top using the Polygon tool. Press the U key twice to reveal all modified properties, zero out the Polystar 1 position property, reveal all of the Polystar path properties and change the number of sides to 3, rotate it 90º using Polystar 1 rotation, then adjust the outer radius to about 172 to make the side of the triangle the same size as the larger circle's diameter. You can set some guides or use the grid display and the magnification ratio to 400% or 800% to fine tune the size so it exactly matches the diameter of the larger circle. Now adjust the Polystar 1>Position property to precisely line up the vertical edge of the triangle with the anchor point.


            The next step is to move the small circle (Circle 2) into it's starting position at the apex of the triangle. Again a magnification ration of 400% or 800% and a guide centered on the apex of the triangle will help you line things up perfectly.


            With no layers selected press the u key once to close all of the modified properties in the timeline then hold down Alt/Option and press p to set an initial keyframe for all layers position. Select the triangle layer and press Shift + Alt/Option + s to set a scale keyframe for the triangle layer. You should now see all of the properties we are going to animate in the timeline.


            Move down the timeline and move Circle 2 (small circle) to it's ending position by dragging the x value in the position property. Then move the triangle into it's final position by doing the same.


            Here comes the fun part. Unlink the scale property on the Triangle layer by clicking on the little chain link icon ∞ in the timeline and then adjust the Y scale value until the vertical side if the triangle lines up with the outside of the larger circle. Again using a high Magnification Ratio makes this easier. Also, when you get close to the right value by dragging the y scale value in the timeline you can press the Ctrl/Cmnd key to give you more control over the values. When you get the height of the triangle adjusted edit the X value of scale to move the apex of the triangle to the center of Circle 1 (small circle).


            The last step is to position the CTI (current time indicator) about half way between the start and ending keyframes and set a new keyframe for Y scale. Match up the vertical size with the outside of the circle then open up the graph editor. Make sure you have edit value graph selected. When you select the Triangle scale property you'll see two lines. The green one is the Y value. Choose the pencil tool (type g) then hold down the Alt/Option tool to bring up the convert point tool (it looks like a sideways v) and drag out a bezier handle to create a smooth curve. Drag the CTI through the timeline to check verify that the vertical side of the triangle accurately follows the outside of Circle 1. You will probably have to break the tangent on the Y curve by using the convert point tool and grabbing the left handle.


            This will take you about 10 minutes. Here's a completed project file for you: Dropbox - funky triangle.aep 
            (note: your browser will probably add a .txt extension to the .aep file. If it does just delete the .txt and it should open.) 


            You could control the scale with an expression and do the research to come up with the right formulas for scale if you like, but this should be plenty accurate for video.


            Initial keyframes:

            Screen Shot 2017-02-17 at 5.32.45 AM.png

            Before adjusting scale graph:

            Screen Shot 2017-02-17 at 5.32.15 AM.png

            Adjusted scale graph:

            Screen Shot 2017-02-17 at 6.33.52 AM.png