## Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.

## Adobe Support Community

• How to loop a linear function

# How to loop a linear function

New Here ,
Jun 10, 2021 Jun 10, 2021

Copy link to clipboard

Copied

I have an image of a car tire rim. The lighting is different on all the "spokes". Ultimately, I want the tire to look like the lighting is the same as it rotates. I am trying to set it up so that when I rotate the tire, the opacity of a duplicated layer, that is rotated at -72degrees (there are 5 rims, 5/360=72), changes from 0 to 100 and then loops as the rotation of the layer continues. I am not sure if this is possible or if I am just not using the right combination of expressions in the correct order. This is what I have >

src=transform.rotation;
loopOut("cycle");
linear(src, -72, 0, 0, 100)

I hope this makes sense and that I provided as much information as I could. Thanks in advance!!!

TOPICS
Expressions

Views

121

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

## 2 Correct answers

Adobe Community Professional , Jun 10, 2021 Jun 10, 2021
The algorithm is awkward and won't work. You need to split up the problem into two areas; the rotation and the opacity. For rotation, start with the loopOut method - loopOut("cycle"); Ensure your keyframes allow for seamless looping. A first keyframe of -72 and the second keyframe with a value of 288 (for a clockwise rotation) will suffice. On the Opacity Property, an Expression such as this should work - src=transform.rotation; linear(src, -72, 288, 0, 100) The issue now, is whether the r...

Likes

New Here , Jun 10, 2021 Jun 10, 2021
Hi Roland! Thank you for the reply!! This helped a ton! I didn't even think about seperating the expressions in Rotation and Opacity. I added this expression to the rotation, which "resets" the value back to -72 if it is over 0 and now it's working perfectly! src=thisComp.layer("Rot").transform.rotation; d = Math.floor(src / 72) + 1; num = (72 * d); src - num Opacity:src=transform.rotation; linear(src, -72, 0, 0, 100) Now in my car rig, I have control over the changing the position of the car o...

Likes

3 Replies 3
Adobe Community Professional ,
Jun 10, 2021 Jun 10, 2021

Copy link to clipboard

Copied

The algorithm is awkward and won't work. You need to split up the problem into two areas; the rotation and the opacity.

For rotation, start with the loopOut method -

loopOut("cycle");

Ensure your keyframes allow for seamless looping. A first keyframe of -72 and the second keyframe with a value of 288 (for a clockwise rotation) will suffice.

On the Opacity Property, an Expression such as this should work -
src=transform.rotation;
linear(src, -72, 288, 0, 100)

The issue now, is whether the results are what you were expecting. Regardless, the structure is valid and robust and I am hopeful you will be able to tweak the values to suit your needs. HTH

Motion Graphics Brand Guidelines & Motion Graphics Responsive Design Solutions
Development | Consulting | Training

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Jun 10, 2021 Jun 10, 2021

Copy link to clipboard

Copied

LATEST

Hi Roland! Thank you for the reply!! This helped a ton! I didn't even think about seperating the expressions in Rotation and Opacity. I added this expression to the rotation, which "resets" the value back to -72 if it is over 0 and now it's working perfectly!

src=thisComp.layer("Rot").transform.rotation;
d = Math.floor(src / 72) + 1;
num = (72 * d);
src - num

Opacity:

src=transform.rotation;
linear(src, -72, 0, 0, 100)

Now in my car rig, I have control over the changing the position of the car on the ground, the wheels auto-rotate and the lighting of the rims looks like it's always the same.

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Jun 10, 2021 Jun 10, 2021

Copy link to clipboard

Copied

I have not seen your comp but if it is anything like what I think it is I would use MiniMax to even out the lighting on the wheel that rotates, create a solid or a shape layer to use for a gradient overlay to bring back the lighting, use Set Matte or Track matte to knock out the spokes on the wheel and simply add 2 keyframes, on and 0Âº and one at 72Âº and LoopOut ().

I did this with two shape layers:

I don't know how you are going to rotate the wheel and not have the lighting change and bounce back. I would probably mask out the whole wheel and just set keyframes at 0Âº and 360Âº, then use loopOut().

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Resources
Troubleshooting FAQs
After Effects Community Recap
Getting started with After Effects