x

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"

How to Normalize a Vector in c++

Coming from Blueprints, I'm trying to Normalize a Vector.

https://api.unrealengine.com/INT/BlueprintAPI/Math/Vector/Normalize/index.html

Based on Google, it seems like the way to do it is to check SafeNormal and then Normalize. However, I'm unsure how they are specifically stored since the two functions return a bool. Is the normalize a void function itself?

https://api.unrealengine.com/INT/API/Runtime/Core/Math/FVector/GetSafeNormal/index.html https://api.unrealengine.com/INT/API/Runtime/Core/Math/FVector/Normalize/index.html

 bool UTest::Normalize(FVector Input, float Tolerance, FVector &Output) { 
 if (Input.GetSafeNormal(Tolerance))
 {
 bool Result = Input.Normalize(Tolerance);
 }
 Output = Input;
 return Result;
 }
 

Would this work? The question more importantly that I'd have would be is the Normalized Vector now Stored in Temp? What does tolerance really mean in terms of how Units reflect on the result?

Product Version: UE 4.20
Tags:
more ▼

asked Nov 01 '18 at 07:10 PM in C++ Programming

avatar image

magfund
219 13 12 13

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first
     Input.GetSafeNormal(Tolerance);
     Input.Normalize(Tolerance);
     Output = Input;

This worked.

I used this inside Blueprints and compared with the standard Normalize provided by KismetMathLibrary. With Tolerance of 1.0, the equal operation returns true even when comparing them with a 100th unit as a tolerance.

more ▼

answered Nov 01 '18 at 08:04 PM

avatar image

magfund
219 13 12 13

(comments are locked)
10|2000 characters needed characters left
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