Aufgrund von Umarbeiten des s3 Storage wird es in GitLab, in nächster Zeit, mögliche Performance-Einbußen geben. Näheres dazu unter: https://maintenance.itc.rwth-aachen.de/ticket/status/messages/43/show_ticket/6670

Commit 9e590070 authored by Jean Meurice's avatar Jean Meurice

Updated Vector types's equals()

parent de67ae35
......@@ -102,4 +102,8 @@ public final class Geometry {
new Vec3(0, 0, 1));
}
public static boolean equalsThreshold(double a, double b, double threshold){
return a < b + threshold && a > b - threshold;
}
}
......@@ -80,6 +80,7 @@ public class Vec2 {
return this.x * p.x + this.y * p.y;
}
@Override
public boolean equals(Object obj) {
if (obj == null)
return false;
......@@ -87,11 +88,11 @@ public class Vec2 {
return true;
if (!(obj instanceof Vec2))
return false;
return equals((Vec2) obj);
return equals((Vec2) obj, 0.000001);
}
public boolean equals(Vec2 p) {
return p.x == x && p.y == y;
public boolean equals(Vec2 p, double threshold) {
return Geometry.equalsThreshold(p.x, x, threshold) && Geometry.equalsThreshold(p.y, y, threshold);
}
public int hashCode() {
......
......@@ -91,6 +91,7 @@ public class Vec3 {
return this.x * p.x + this.y * p.y + this.z * p.z;
}
@Override
public boolean equals(Object obj) {
if (obj == null)
return false;
......@@ -98,11 +99,13 @@ public class Vec3 {
return true;
if (!(obj instanceof Vec3))
return false;
return equals((Vec3) obj);
return equals((Vec3) obj, 0.000001);
}
public boolean equals(Vec3 p) {
return p.x == x && p.y == y && p.z == z;
public boolean equals(Vec3 p, double threshold) {
return Geometry.equalsThreshold(p.x, x, threshold)
&& Geometry.equalsThreshold(p.y, y, threshold)
&& Geometry.equalsThreshold(p.z, z, threshold);
}
public int hashCode() {
......
......@@ -85,6 +85,7 @@ public class Vec4 {
return this.x * p.x + this.y * p.y + this.z * p.z + this.w * p.w;
}
@Override
public boolean equals(Object obj) {
if (obj == null)
return false;
......@@ -92,11 +93,14 @@ public class Vec4 {
return true;
if (!(obj instanceof Vec4))
return false;
return equals((Vec4) obj);
return equals((Vec4) obj, 0.000001);
}
public boolean equals(Vec4 p) {
return p.x == x && p.y == y && p.z == z && p.w == w;
public boolean equals(Vec4 p, double threshold) {
return Geometry.equalsThreshold(p.x, x, threshold)
&& Geometry.equalsThreshold(p.y, y, threshold)
&& Geometry.equalsThreshold(p.z, z, threshold)
&& Geometry.equalsThreshold(p.w, w, threshold);
}
public int hashCode() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment