use a stricter tolerance to check for equal points

add method IsEqual to Vector3 class to support user-defined tolerance
This commit is contained in:
wmayer
2016-08-15 14:09:26 +02:00
parent e2345374ca
commit aea769af3d
9 changed files with 70 additions and 28 deletions

View File

@@ -225,7 +225,7 @@ void Rotation::setValue(const Vector3d & rotateFrom, const Vector3d & rotateTo)
else {
// We can use any axis perpendicular to u (and v)
Vector3d t = u % Vector3d(1.0, 0.0, 0.0);
if(t.Length() < FLT_EPSILON)
if(t.Length() < Base::Vector3d::epsilon())
t = u % Vector3d(0.0, 1.0, 0.0);
this->setValue(t.x, t.y, t.z, 0.0);
}
@@ -361,11 +361,11 @@ Rotation Rotation::slerp(const Rotation & q0, const Rotation & q1, double t)
neg = true;
}
if ((1.0 - dot) > FLT_EPSILON) {
if ((1.0 - dot) > Base::Vector3d::epsilon()) {
double angle = (double)acos(dot);
double sinangle = (double)sin(angle);
// If possible calculate spherical interpolation, otherwise use linear interpolation
if (sinangle > FLT_EPSILON) {
if (sinangle > Base::Vector3d::epsilon()) {
scale0 = double(sin((1.0 - t) * angle)) / sinangle;
scale1 = double(sin(t * angle)) / sinangle;
}