Get value between 2 point based on percentage

Both points are float values and point A could be any numbers from 0.0 to 1.0, point B is a fixed value if this helps. now i want to find the value between point A and Point B by a given percentage.

  • If by 0.7 i want a number that 70% of the way from point A to point B how should i do that?

here is what i currently do when point A starts from 0.0 :

float value = GivenPercent * MaxValue;

EDIT for clarification :
An example of what I’m looking for would be if the given percentage was 40% i need to find the 40% of the way from A to B and A could be 0.6, B could be 1.0, so 0% will be 0.6 and 100% will be 1.0.

Let’s establish some basic premise:

Vector Example

A=0%= Vector 0,0,0

B=100%=Vector 20,20,20

Input =0.8=Expected Vector 16,16,16

BInput = 20,20,200.8 = 16,16,16.


Integer Example

A=0

B=50

Input=0.675

Binput=500.675=33.75


So your formula is:
B*Input

Thanks for answer but it wasn’t what I’m looking for, i know the formula when A is 0 as shown in my question, what i wanted was how do i calculate it if A was a non-zero value. if A value is 0.4 then 0 percent will be 0.4.

Use Lerp (linear interpolation)

float A = ...;
float B = ...;
float t = 0.7f; // 70%
float Result = FMath::Lerp(A, B, 0.7f);

Or you can code your formula by hand

float t = 0.7f;
float Result = A + (B - A) * t;