4 Replies Latest reply on Nov 6, 2010 4:56 AM by Rick Gerard

# Ellipse as Path (With Expressions)

Hi,

I'm having a little trouble figuring out how to do something. I have an ellipse and a circle. I want the ellipse's height to change size vertically and the circle to follow the path of the ellipse. And I need both of these functions to happen from sliders using expressions (so, one slider to control the ellipse's height and another to decide where the circle is on the ellipse).

Getting the ellipse to change height is easy enough. But I can't figure out how to get the circle to recognize the path of the ellipse. Is there any way to do this? Thanks,

--Saib Babcock

• ###### 1. Re: Ellipse as Path (With Expressions)

Should be easy enough.... You just feed your slider as the angle into your ellipse formula using a simple linear(). Then whatever angle you define will drive the center of the circle based on sinus/cosinus.... If you need more specific help, post the code.

Mylenium

• ###### 2. Re: Ellipse as Path (With Expressions)

Are you using masks to create your shapes?  Because that could make things harder...

• ###### 3. Re: Ellipse as Path (With Expressions)

I'm not exactly clear what you're trying to accomplish but if you have add three Expression Sliders to a layer, name them xSlider, ySlider and speedSlider you can add this expression to the position property to make the layer orbit in an elliptical path around it's original position. in 2D space.

```
dx = effect("xSlider")("Slider");
dy = effect("ySlider")("Slider");
orbitSpeed = effect("speedSlider")("Slider") * time;
value + [Math.sin(orbitSpeed)*dx, Math.cos(orbitSpeed)*dy];
```

It's a simple mod to make the expression work in 3D. You just need to add a slider called zSlider then use this expression;

```dx = effect("xSlider")("Slider");
dy = effect("ySlider")("Slider");
dz = effect("zSlider")("Slider");
orbitSpeed = effect("speedSlider")("Slider") * time;
value + [Math.sin(orbitSpeed)*dx, Math.cos(orbitSpeed)*dy, dz];
```

Or this option which would even be more interesting

```dx = effect("xSlider")("Slider");
dy = effect("ySlider")("Slider");
dz = effect("zSlider")("Slider");
orbitSpeed = effect("speedSlider")("Slider") * time;
value + [Math.sin(orbitSpeed)*dx, Math.cos(orbitSpeed)*dy, Math.cos(orbitSpeed)*dz];

```

• ###### 4. Re: Ellipse as Path (With Expressions)

A better way to work this expression is as follows:

```s = time * effect("Speed")("Slider");
x = Math.sin(s)*effect("sinX")("Slider");
y = Math.cos(s)*effect("cosY")("Slider");
z = Math.cos(s)*effect("sinz")("Slider");

value + [x, y, z]

```

A CS5 project file lives HERE.