lace / vg

Vector-geometry toolbelt for 3D points and vectors

Home Page:https://vgpy.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Floating point error when calculating angle?

Jaime02 opened this issue · comments

Code:

import numpy as np
import vg
vec1 = np.array((1, 3, 3))
vec2 = np.array((1, 3, 3))
print(vg.angle(vec1, vec2))

Expected result: 0, right?

Hi, thanks for the question.

>>> import numpy as np
>>> import vg
>>> vec1 = np.array((1, 3, 3))
>>> vec2 = np.array((1, 3, 3))
>>> print(vg.angle(vec1, vec2))
1.2074182697257333e-06

That's 0.0000012 degrees which in floating-point land is pretty close to zero. What are you expecting?

I expected to get a 0, but nevermind, I will round the result.