Skip to content
Snippets Groups Projects
mostly_equal.cpp 566 B
Newer Older
Brandon Lai-Cheong's avatar
Brandon Lai-Cheong committed
#include <stdlib.h>
#include <point.h>
#include <triangle.h>

#define DEBUG_EPSILON 0.0001

Brandon Lai-Cheong's avatar
Brandon Lai-Cheong committed
bool mostlyEqual(float a, float b)
{
    return abs(a - b) < DEBUG_EPSILON;
Brandon Lai-Cheong's avatar
Brandon Lai-Cheong committed
}

bool mostlyEqual(const Point &a, const Point &b)
{
    return mostlyEqual(a.x, b.x) && mostlyEqual(a.y, b.y) && mostlyEqual(a.z, b.z);
Brandon Lai-Cheong's avatar
Brandon Lai-Cheong committed
}

// mostly equal
bool Triangle::operator==(const Triangle &other) const {
	return mostlyEqual(points[0], other.points[0]) &&
		mostlyEqual(points[1], other.points[1]) &&
		mostlyEqual(points[2], other.points[2]) &&
		mainTriangleId == other.mainTriangleId;
Brandon Lai-Cheong's avatar
Brandon Lai-Cheong committed
}