• | **Only want one part of a sin curve...?**
on May 12, 2014 at 8:14:02 pm |

I'm trying to make continuous motion using Math.sin(time) on a positions Y value. The effect I get is as expected, a yo-yo type effect (up-down-up-down). However, what I'd like ideally is only one section/direction of movement (up-(reset to starting point)-up), etc.

Basically only to ignore the 2nd half of the sine curve.

I hope this makes sense.

• | **Re: Only want one part of a sin curve...?** on May 13, 2014 at 12:15:04 am |

It would help to see your expression, but if you wrap the Math.sin() calculation in Math.abs() it will make both halves of the sine wave positive. You might then have to add a minus sign if you want the value to instead always be negative:

-Math.abs(Math.sin(xxx));

Dan

• | **Re: Only want one part of a sin curve...?** on May 13, 2014 at 5:05:37 pm |

if you just wanted the positive values on the upward swing (then jump back to the original y value and repeat), then this might work for you.:

**yAmp = 200; // max y offset value**

y = Math.abs(Math.sin(time%(Math.PI/2)))*yAmp;

value - [0,y]

Kevin Camp

Art Director

KCPQ, KZJO & KRCW