Pārlūkot izejas kodu

Add `equals` to `Point` classes (#686)

Guilherme Recchi Cardozo 6 gadi atpakaļ
vecāks
revīzija
9593226809
4 mainītis faili ar 16 papildinājumiem un 0 dzēšanām
  1. 4 0
      h2d/col/IPoint.hx
  2. 4 0
      h2d/col/Point.hx
  3. 4 0
      h3d/col/IPoint.hx
  4. 4 0
      h3d/col/Point.hx

+ 4 - 0
h2d/col/IPoint.hx

@@ -37,6 +37,10 @@ class IPoint {
 		return new Point(x + p.x, y + p.y);
 	}
 
+	public inline function equals( other : IPoint ) : Bool {
+		return x == other.x && y == other.y;
+	}
+
 	public inline function dot( p : IPoint ) {
 		return x * p.x + y * p.y;
 	}

+ 4 - 0
h2d/col/Point.hx

@@ -37,6 +37,10 @@ class Point {
 		return new Point(x + p.x, y + p.y);
 	}
 
+	public inline function equals( other : Point ) : Bool {
+		return x == other.x && y == other.y;
+	}
+
 	public inline function dot( p : Point ) {
 		return x * p.x + y * p.y;
 	}

+ 4 - 0
h3d/col/IPoint.hx

@@ -23,6 +23,10 @@ class IPoint {
 		this.z = z;
 	}
 
+	public inline function equals( other : IPoint ) : Bool {
+		return x == other.x && y == other.y && z == other.z;
+	}
+
 	public inline function load( p : IPoint ) {
 		this.x = p.x;
 		this.y = p.y;

+ 4 - 0
h3d/col/Point.hx

@@ -45,6 +45,10 @@ class Point {
 		return new Point(y * p.z - z * p.y, z * p.x - x * p.z,  x * p.y - y * p.x);
 	}
 
+	public inline function equals( other : Point ) : Bool {
+		return x == other.x && y == other.y && z == other.z;
+	}
+
 	public inline function lengthSq() {
 		return x * x + y * y + z * z;
 	}