Page 1 of 1

Vector compare ?

Posted: Fri May 20, 2016 12:43 am
by srl
Hi Andrew I can't get this vector compare to return true.
Screenshot from 2016-05-20 09-01-18.png
Screenshot from 2016-05-20 09-01-18.png (291.8 KiB) Viewed 6703 times
srl

Re: Vector compare ?

Posted: Fri May 20, 2016 9:05 am
by andrew
To compare two vectors, use:
vector1.equalsFuzzy(vector2)
To compare two doubles (real or floating point numeric values):
RMath.fuzzyCompare(value1, value2)
The == operator should never be used when dealing with floating point values since floating point arithmetic is not always 100% accurate:
0.1+0.2==0.3
false
With vectors and other objects, == does not work even if two vector are exactly identical since == compares the objects for identity, not the values inside:
var a = new RVector(0,0);
var b = new RVector(0,0);
a==b
false
a==a
true

Re: Vector compare ?

Posted: Fri May 20, 2016 12:02 pm
by srl
Thanks Andrew.

As you can see I'm been on the LinuxCNC simulator. P2 makes the full arc circle work with offset.
Still more testing to be done.

srl