# Thread: Limiting output of a parametric function

1. ## Limiting output of a parametric function

Hey, all! I hope this is the right thread. (i searched parametric and found several posts in this calc thread)

I am making a game with some particle effects. The effect in question generates 100 particles at once. Each particle gets a random value we'll call zVel.
Then their velocity is given a value based on zVel.

velocity.X = width * (float)Math.Sin(Zvelocity);
velocity.Y = height * (float)Math.Cos(Zvelocity);

This all works perfectly. All the variables do what they're supposed to do etc...

Visually it "plots" particles along the ellipse starting at the Y axis. zVel > 0 goes to the right and up and around. < 0 goes left, up then around.
The arbitrary limits for zVel are 0 and PI. PI creates a half circle, but the effect is mirrored. (polar I think?)

So now we have an ellipse that shoots out nicely, but now I need the particles on the bottom to be bigger and as they go around, get smaller.

For this new function, this means as zVel moves away from zero, the the output (Scale) needs to decrease. Further I need to be able to limit the output by two other variables Min and Max.

So as zVel approaches -PI or +PI (absolut val of Top), I need the Scale to approach Min and as zVel approaches 0(Bottom), I need zVel to approach Max.

Here's my code sample that is closest. Obviously there's a potential of dividing by zero, so that's wrong at least.

top = PI;
bottom = 0;
min = 0; //min particle size
max = 1; //max particle size

scale *= (PI - max) / (Abs(Zvelocity) + (max/min));

Any help or explanations on limiting equations would be great!

2. Sounds like you want to use

$scale=min+(max-min)|\frac{zVel}{\pi}|.$

This starts as $min$ and approaches $max$ as $zVel$ approaches $\pi$ or $-\pi$.

3. Thanks so much for the speedy help!
It's working great now!