Formula needed to describe this pattern.
I need a formula where Y evaluates to 1 while X is in the range 1-5, and then Y exponentially increases for X > 5. I don''t care about X < 1 since I will only be using it in my application if it is an integer greater than 0. I tried Y = (X * (X-5)) + 5
But that is only true for X = 1 and X = 4.
Any ideas? Thanks.
If X is an integer you''ll need something like
(X-1)*(X-2)*(X-3)*(X-4)*(X-5)
and then do some compensating for the extra factor introduced.
Can''t you just use an if...else though?
"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
(X-1)*(X-2)*(X-3)*(X-4)*(X-5)
and then do some compensating for the extra factor introduced.
Can''t you just use an if...else though?
"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
I could do Y = (X * (X-6)) + 6 and then
IF (Y < 1) Y = 1;
but I was hoping to have one formula do it all for me.
IF (Y < 1) Y = 1;
but I was hoping to have one formula do it all for me.

What is your application?
Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
Just define it piece-wise. The formula you are asking for is not derivable at x=5, so none of the basic continuously derivable functions will fit.
Cédric
Cédric
I have a "spinner" button, that as I hold down on the mouse and move sideways it increments the amount in a textbox next to it. So at lower movement speeds, I want the incrementation to be very precise, while at higher movement speeds to increase rapidly.
Actually, Paradigm Shifter provided a solution that will work for the bottom half anyway.
Y = (X-1)*(X-2)*(X-3)*(X-4)*(X-5) + 1
A little lengthy, but better than multiple IF statements.
[edited by - matthewb on January 7, 2003 1:25:10 PM]
Y = (X-1)*(X-2)*(X-3)*(X-4)*(X-5) + 1
A little lengthy, but better than multiple IF statements.
[edited by - matthewb on January 7, 2003 1:25:10 PM]
After modifying Paradigm Shifter''s formula to this, it does what I need it to. Thanks.
Y = ((X-1)*(X-2)*(X-3)*(X-4)*(X-5))/(2*X) + 1
Y = ((X-1)*(X-2)*(X-3)*(X-4)*(X-5))/(2*X) + 1
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement