2
0
Эх сурвалжийг харах

Updated h2d.col.Line with angle() and length() methods (#749)

Kryvosheya Sergij 5 жил өмнө
parent
commit
5e1e0807d3
1 өөрчлөгдсөн 15 нэмэгдсэн , 0 устгасан
  1. 15 0
      h2d/col/Line.hx

+ 15 - 0
h2d/col/Line.hx

@@ -54,4 +54,19 @@ class Line {
 		return hxd.Math.sqrt(distanceSq(p));
 	}
 
+	/**
+	 * The angle between a line and the x-axis
+	 */
+	public inline function angle():Float {
+		var dx = p2.x - p1.x;
+		var dy = p2.y - p1.y;
+		return hxd.Math.atan2(dy, dx);
+	}
+
+	public inline function length():Float {
+		var dx = p2.x - p1.x;
+		var dy = p2.y - p1.y;
+		return hxd.Math.distance(dx, dy);
+	}
+
 }