public void SignedAngle() { Assert.AreEqual(VectorE.SignedAngle(Vector2.up, Vector2.up), 0); Assert.AreEqual(VectorE.SignedAngle(Vector2.up, Vector2.right), 90); Assert.AreEqual(VectorE.SignedAngle(Vector2.up, Vector2.down), 180); Assert.AreEqual(VectorE.SignedAngle(Vector2.up, Vector2.left), -90); }
private static Vector2 GetBisector(Vector2 previous, Vector2 current, Vector2 next, out float angle) { Vector2 toPrevious = (previous - current).normalized; Vector2 toNext = (next - current).normalized; angle = VectorE.Angle360(toPrevious, toNext); Assert.IsFalse(float.IsNaN(angle)); return(toPrevious.RotateCW(angle / 2)); }
public void SignedAngle() { Assert.AreEqual(0, VectorE.SignedAngle(Vector2.up, Vector2.up)); Assert.AreEqual(45, VectorE.SignedAngle(Vector2.up, Vector2.one)); Assert.AreEqual(90, VectorE.SignedAngle(Vector2.up, Vector2.right)); Assert.AreEqual(135, VectorE.SignedAngle(Vector2.up, new Vector2(1, -1))); Assert.AreEqual(180, VectorE.SignedAngle(Vector2.up, Vector2.down)); Assert.AreEqual(-45, VectorE.SignedAngle(Vector2.up, new Vector2(-1, 1))); Assert.AreEqual(-90, VectorE.SignedAngle(Vector2.up, Vector2.left)); Assert.AreEqual(-135, VectorE.SignedAngle(Vector2.up, new Vector2(-1, -1))); }