Notifications
Clear all
[Closed] compare two vectors
Apr 26, 2017 1:52 pm
What is the best way to test on whether two vectors match each other or not?
fn do_vectors_match v1 v2 =
(
local val = abs (dot (normalize v1) (normalize v2))
if val == 1.0 or val == 180.0 do return true
false
)
4 Replies
1 Reply
Apr 26, 2017 1:52 pm
Either of these is fine:
fn Point3Equal a b epsilon:0.0001 =
(
abs(a.x - b.x) < epsilon and
abs(a.y - b.y) < epsilon and
abs(a.z - b.z) < epsilon
)
fn Point3Equal a b epsilon:0.0001 =
(
length (a - b) < epsilon
)
alternatively you can replace the checks in the first one with close_enough