Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8174517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:28:49+00:00 2026-06-06T22:28:49+00:00

I am using some easing functions in C# which give Ease In and Ease

  • 0

I am using some easing functions in C# which give Ease In and Ease out effects. However, what I am trying to achieve with these easing functions does not give an observable effect.

For eg:

int x=2;
while(x<200)
SetSomething(x = EaseIn(x, 1, EasingType.Quadratic));

The speed with which SetSomething executes doesn’t give enough time to notice the effect of SetSomething. For eg: The value starts from 2 -> 4 -> 16 -> 256

I was trying to achieve the following kind of graphs, but with smaller values (not greater than 200):
http://theinstructionlimit.com/wp-content/uploads/2009/07/easing.png

Easing functions implementation is here: http://theinstructionlimit.com/wp-content/uploads/2009/07/Easing.cs

Even if I get the quadratic values in a smaller range < 200, I need atleast a very small pause-like effect in each iteration of the loop to notice the effect easing. This small pause can also be follow a quadratic curve (i.e for easing: the pause duration might be more first and then lesser pause durations)

What should I do for the same? How do I get quadratic graph in range < 200 and this pause like effect in each iteration?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T22:28:50+00:00Added an answer on June 6, 2026 at 10:28 pm

    You are taking the result of Easing as new x. This is very strange!

    Also, x is supposed to be the linearStep. linearStep is a double but your x is an int. Make your x a double and increment it by an appropriate ammount.

    const double step = 1.5; // Choose an appropriate value here!
    
    for (double x = 2.0; x <= 200.0; x += step) {
        double y = Ease(x, 1.0f, EasingType.Quadratic);
        SetSomething(y); 
    }
    

    UPDATE

    Your design is very procedural. I would prefer an object-oriented approach. switch-statements can often be replaced by a polymorphic (object-oriented) approach.

    public abstract class Curve 
    {
        public float EaseIn(double s);
        public float EaseOut(double s);
        public static float EaseInOut(double s);
    }
    
    public class StepCurve : Curve
    {
        public override float EaseIn(double s)
        {
            return s < 0.5 ? 0.0f : 1.0f;
        }
    
        public override float EaseOut(double s)
        {
            return s < 0.5 ? 0.0f : 1.0f;
        }
    
        public override float EaseInOut(double s)
        {
            return s < 0.5 ? 0.0f : 1.0f;
        }
    }
    
    public class LinearCurve : Curve
    {
        public override float EaseIn(double s)
        {
            return (float)s;
        }
    
        public override float EaseOut(double s)
        {
            return (float)s;
        }
    
        public override float EaseInOut(double s)
        {
            return (float)s;
        }
    }
    
    public class SineCurve : Curve
    {
        public override float EaseIn(double s)
        {
            return (float)Math.Sin(s * MathHelper.HalfPi - MathHelper.HalfPi) + 1;
        }
    
        public override float EaseOut(double s)
        {
            return (float)Math.Sin(s * MathHelper.HalfPi);
        }
    
        public override float EaseInOut(double s)
        {
            return (float)(Math.Sin(s * MathHelper.Pi - MathHelper.HalfPi) + 1) / 2;
        }
    }
    
    public class PowerCurve : Curve
    {
        int _power;
    
        public PowerCurve(int power)
        {
            _power = power;
        }
    
        public override float EaseIn(double s)
        {
            return (float)Math.Pow(s, _power);
        }
    
        public override float EaseOut(double s)
        {
            var sign = _power % 2 == 0 ? -1 : 1;
            return (float)(sign * (Math.Pow(s - 1, _power) + sign));
        }
    
        public override float EaseInOut(double s)
        {
            s *= 2;
            if (s < 1) return EaseIn(s, _power) / 2;
            var sign = _power % 2 == 0 ? -1 : 1;
            return (float)(sign / 2.0 * (Math.Pow(s - 2, _power) + sign * 2));
    
        }
    }
    

    With these definitions you can change the Ease method to

    public static float Ease(double linearStep, float acceleration, Curve curve)
    {
        float easedStep = acceleration > 0 ? curve.EaseIn(linearStep) :
                          acceleration < 0 ? curve.EaseOut(linearStep) :
                          (float)linearStep;
        return MathHelper.Lerp(linearStep, easedStep, Math.Abs(acceleration));
    }
    

    You can completely drop the methods with the switch-statements. You would draw a Cubic curve with

    var curve = new PowerCurve(3);
    for (double x = 2.0; x <= 200.0; x += step) {
        double y = Ease(x, 1.0f, curve);
        SetSomething(y); 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using some of the methods, I am able to check the orientations to which
Assuming I'm using some graphic API which allows me to draw bezier curves by
I am using some pre-written JavaScript from polldaddy. They have a JavaScript option which,
I'm using some semi-transparent PNGs as background-images on various websites. These are usually something
I'm currently trying to create a page with dynamically generated images, which are not
I am using some NHibernate 1.2 code with NHibernate 2.0 and its giving me
I am using some third party library to connect to a server via async
I'm using some code from here to determine when determining when the last finger
I'm using some code to build up tables using JQuery, but in Firefox 3.5.3
I have some elements and I'm using some jQuery plugins. I want to see

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.