Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: UE 4.20
more ▼

asked Oct 25 '18 at 09:54 AM in C++ Programming

avatar image

17 1 2 7

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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;

more ▼

answered Oct 25 '18 at 10:59 AM

avatar image

Ali Akbar
686 2 5 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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

B*Input = 20,20,20*0.8 = 16,16,16.

Integer Example





So your formula is: B*Input

more ▼

answered Oct 25 '18 at 10:13 AM

avatar image

66 5 5

avatar image THIECK Oct 25 '18 at 10:47 AM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question