[BUG?] Vector3.Dot() product returns -1.47
Hello. Just faced some strange behaviour of Vector3.Dot().
It can be reproduced by this code:
Vector3 v3cTest = Vector3.forward;
v3cTest = Quaternion.AngleAxis(45f, Vector3.up) * v3cTest;
v3cTest = Quaternion.AngleAxis(45f, Vector3.up) * v3cTest;
float testDot = Vector3.Dot(v3cTest, Vector3.forward);
Just run debugger and watch v3cTest value. It will be like this: testDot = Vector3.Dot( (1.0, 0.0, 0.0), (0.0, 0.0, 1.0)); So you 'll expect 0 but result will be -1.47.
Maybe i'm doing somthing wrong?
Yes, you are doing something wrong. Read your answer again. It's not -.147. It's really 0 with a rounding error.
$$anonymous$$ost people renormalize after doing math, if it really, really matters (which it almost never does.)
Sorry, i still don't understand. Are you sure that its a roundng error?
I mean, function returns really weird result without warning and stuff... so any logic that comes after will be broken.
I solved this problem via replacing vector rotations with more simple math but still .
I didn't see the screenshot before.
-1.47513973E-07f is -0.000000147513973
I'd say that's close enough to 0.
Answer by Leight · Oct 09, 2016 at 11:55 AM
@doublemax Okay its just -1.47 * 1/(10^7)? And its was near but not 0 because of double rotation. Got it, Thanks for explanation!
Your answer
Follow this Question
Related Questions
Taking continuously damage on a surface 0 Answers
SOME slider don't accept SOME variables... WHY??? 0 Answers
Need help with a script execution fault 0 Answers