public void NormalizeTest() { var vector = new KtVector2D(Degrees.Create(45)) * 20; vector.Normalize(); Assert.AreEqual(vector, new KtVector2D(Math.Sqrt(2) / 2, Math.Sqrt(2) / 2)); }
public void AngleBetweenTest() { var vector = new KtVector2D(3, 2); var vector2 = new KtVector2D(2, 3); Assert.AreEqual(vector.AngleBetween(vector2), Degrees.Create(-(Math.Atan2(2, 3) - Math.Atan2(3, 2)) * 180 / Math.PI)); Assert.AreEqual(vector2.AngleBetween(vector), Degrees.Create((Math.Atan2(2, 3) - Math.Atan2(3, 2)) * 180 / Math.PI)); }
public void RotateTest() { var vector = new KtVector2D(1, 0); vector.Rotate(Degrees.Create(45)); Assert.AreEqual(vector, new KtVector2D(Math.Sqrt(2) / 2, Math.Sqrt(2) / 2)); var vector2 = new KtVector2D(-1, 1); vector2.Rotate(Degrees.Create(-135)); Assert.AreEqual(vector2, new KtVector2D(Math.Sqrt(2), 0)); }
private static Angle InteriorAngle(this CircularStack <KtPoint2D> points, KtPoint2D point) => points.Aggregate(Degrees.Create(0.0), (total, c) => total + c.InteriorAngle(point));
public void DirectionTest() { var vector = new KtVector2D(3, 2); Assert.AreEqual(vector.Direction, Degrees.Create(Math.Atan2(2, 3) * 180 / Math.PI)); }
public void KtVector2DTest1() { var vector = new KtVector2D(Degrees.Create(45)); Assert.AreEqual(vector, new KtVector2D(Math.Sqrt(2) / 2, Math.Sqrt(2) / 2)); }
public static Angle TotalInternalAngle(this CircularStack <KtPoint2D> points, KtPoint2D point) => points.Aggregate(Degrees.Create(0), (total, c) => total + (c?.Next?.Value - point).ToKtVector2D().AngleBetween((c?.Value - point).ToKtVector2D()));
public override Angle Complementary() => Degrees.Create(Value + 0.5);
public override Angle Complementary() => Degrees.Create(Value + Math.PI);