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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:20:54+00:00 2026-06-12T14:20:54+00:00

I tried to look for an answer for this problem but I guess nobody

  • 0

I tried to look for an answer for this problem but I guess nobody has needed something like this or it’s something super simple that I just can’t get my head around. So:

I have a value that changes from 45 to 20.

I’d need a value that goes from 0 to 1 in same time as 45 goes to 20. I know that 45 – 20 = 25 and that would be my 100% and hence the number 1.

I’d implement this in Lerp value like this:

public float minHeight = 10.0f;
public float maxHeight = 30.0f;
public float convertedValue;

convertedValue = ??? (Something like 45 – 20 = 25 = 100%) * 0.01;

newValue = Mathf.Lerp(minHeight, maxHeight, convertedValue);

Hopefully someone can help me. Im fairly new to coding and I was just wondering if this is possible. Thanks for your time!

  • 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-12T14:20:55+00:00Added an answer on June 12, 2026 at 2:20 pm

    I believe the calculation matching your explanation would be

    newValue = (convertedValue - minHeight) / (maxHeight - minHeight);
    

    i.e. newValue = 0 @ minHeight, and 1 @ maxHeight

    Edit

    I’ve never seen Lerp before, but apparantly it is simple linear interpolation.

    However, from MSDN

    Lerp is defined as

    value1 + (value2 - value1) * amount
    

    i.e. in your example convertedValue should be the fraction, and the answer is the interpolated result, meaning that your question / my (and Esailja’s) interpretation thereof is inverted 🙂

    i.e.

    Mathf.Lerp(10.0, 30.0, 0.5) = 20.0
    

    whereas

    InvertedLerp(10.0, 30.0, 20) = 0.5 // My / Esailja's calc
    

    🙂

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

Sidebar

Related Questions

I've tried to look for an answer to this, but none of the other
I have searched the numerous questions that look like this one, but haven't found
What should data look like before data encoding in: urllib2.Request(someurl,data) I tried [('name1','value1'),('name2','value2'),...] but
I have searched this web looking for an answer, but it seems that this
I've tried to really look this one up before asking a question but it
I have tried looking around for an answer to this, but I have been
I have tried to look everywhere for a solution but I can't seem to
I have tried to look at other topics with similar question like mine, and
I tried to make a layout look like it It looks like kinda button
I have tried this example http://www.bennadel.com/blog/1056-ColdFusion-CFPOP-My-First-Look.htm , but it retrieve emails from POP server.

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.