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 9284507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:55:16+00:00 2026-06-18T18:55:16+00:00

I have this as my lerp function: Vec2f lerp(float t, Vec2f a, Vec2f b){

  • 0

I have this as my lerp function:

  Vec2f lerp(float t, Vec2f a, Vec2f b){
      return (1-t)*a + t*b;
  }

And I have the following code below, which I was hoping that would result in a “tween”:

    Vec2f a(0,0);
    Vec2f b(3,4);
    Vec2f c(5,4);
    Vec2f d(5,0);

    if( i < 100 ){
        if(i <= 30){
            ball.pos = lerp(i, a, b);
        }
        else if(i > 30 && i < 80){
            ball.pos = lerp(i, b, c);
        }
        else {
            ball.pos = lerp(i, a, d);
        }
    } i += 1;

But what I get is a “discontinuous tween”, that is instead of starting at the last point where the lerp from A to B ends, it starts somewhere else, and some goes for the other lerps. What am I doing wrong?

  • 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-18T18:55:17+00:00Added an answer on June 18, 2026 at 6:55 pm

    t has to be between 0 and 1 in your interpolation function, but you are passing values between 0 and 100. Change your calls to lerp(i/100.0f, a, b) and so on. (It is important that you specify the 100.0 as a floating point literal, NOT an integer literal!)

    As DarenW correctly points out, you have to cover the range from 0 to 1 for every segment for the desired effect, i.e. in your case, lerp(i/30.0f, a, b), lerp((i-30)/50.0f, a, b), etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have this result set below; am trying to insert the red numbers into post_position
I have this css code which is only supported in Firefox. /* Green header
I have this code behind a winforms which simply has a listbox as its
I have this code that activates the jquery draggable in a management system files
I have this code: $('.couch-hide').click(function() { $(this).animate({right:0},1000, 'easeOutBounce'); }); I am trying to get
I have this piece of code that is challenging all my knowledge of C.
i have this function that transforms image to trapezoid using PHP GD: function perspective($i,$gradient=0.9,$rightdown=true,$background=0xFFFFFF)
I have this form set up to submit some text, the code below works
I have this code for converting a byte[] to float[] . public float[] ConvertByteToFloat(byte[]
I have this function: public static string Join(this IEnumerable<string> strings, string separator) { return

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.