3 Replies Latest reply on Jul 28, 2017 10:59 AM by adamtlv

# Expressions 101 - rotation and postion

I just don't understand this basic expression and why it's causing this result. I wanted to make a circle rotate properly along a path, like a ball rolling. I started to play around and when I pick whip my rotation to the separated position dimension of X and start adjusting the X position, it works, but why? All that is in the expression is "transform.xPosition" so I am not understanding where in that tiny expression that if the position moves the object should rotate equally. I feel like to do that would entail a much more extensive expression. Any help explaining this is greatly appreciated!

• ###### 1. Re: Expressions 101 - rotation and postion

You got lucky ; )
I bet your ball was just over 100px in diameter?  Ideally about 115?

Your expression says: make my rotation equal my x position movement.

ball moves 360 pixels to the right = ball rotates 360 degrees clockwise.

For the ball to rotate without slipping or skidding it's circumference would need to equal the distance it moved.

Diameter = circumerefence / Pi    = 360 / 3.14    = 114.6 pixels.

Your homework, should you choose to accept it...

make an expression that rolls without slipping or skidding for a ball of any size : )

• ###### 2. Re: Expressions 101 - rotation and postion

OK... to answer my own question : )

The key thing to note is that a pick-whipped expression basically  just copies the values from one property to another - and those values are unitless. They are interpreted in terms of the units of the property to which they are applied. So in your case X pixels of movement is interpreted as X degrees of rotation.

You need to work out what proportion of a circle's circumference is the distance moved, which is:

distance / (Pi x diameter) . Having got the proportion, you can x 360 to calculate the degrees.

In expression speak:

dia = 300;

transform.position[0] / (Math.PI * dia) * 360

Notes:

1. Change the number 300 to whatever your circle diameter is.

2. No need to separate the dimensions. The '[0]' at the end of transform.position says 'use the first ('X') value'.

Here is the site to learn all about expressions from the master:

http://www.motionscript.com/index.html