public void IsEqual() { var p1 = new Dir2d(1, 0); var p2 = new Dir2d(0, 1); Assert.IsFalse(p1.IsEqual(p2, 0.1)); Assert.IsTrue(p1.IsEqual(p2, Math.PI / 2)); }
public void ValueType_Dir2d() { Assert.AreEqual(new Dir2d(1, 0), Dir2d.DX); Assert.AreEqual(new Dir2d(0, 1), Dir2d.DY); var p1 = new Dir2d(1, 0); var p2 = new Dir2d(0, 1); Assert.IsFalse(p1.IsEqual(p2, 0.1)); Assert.IsTrue(p1.IsEqual(p2, Math.PI / 2)); Assert.IsTrue(p1.IsNormal(p2, 0.1)); Assert.IsFalse(p1.IsOpposite(p2, 0.1)); Assert.IsTrue(p1.IsOpposite(p2, Math.PI / 2)); Assert.IsFalse(p1.IsParallel(p2, 0.1)); Assert.IsTrue(p1.IsParallel(p2, Math.PI / 2)); Assert.AreEqual(Math.PI / 2, p1.Angle(p2)); p2 = new Dir2d(1, 0); Assert.AreEqual(1, p1.Crossed(new Dir2d(0, 1))); Assert.AreEqual(Math.Sqrt(2) / 2, p1.Dot(new Dir2d(1, 1)), 0.0000001); p2 = new Dir2d(1, 0); p2.Reverse(); Assert.AreEqual(new Dir2d(-1, 0), p2); Assert.AreEqual(new Dir2d(-1, 0), p1.Reversed()); p2 = new Dir2d(1, 0); p2.Mirror(new Dir2d(0, 1)); Assert.AreEqual(new Dir2d(-1, 0), p2); Assert.AreEqual(new Dir2d(-1, 0), p1.Mirrored(new Dir2d(0, 1))); var m2 = new Ax2d(new Pnt2d(-1, 2), new Dir2d(-1, 0)); p2 = new Dir2d(1, 0); p2.Mirror(m2); Assert.AreEqual(new Dir2d(1, 0), p2); Assert.AreEqual(new Dir2d(1, 0), p1.Mirrored(m2)); p2 = new Dir2d(1, 0); Assert.IsTrue(new Dir2d(0, 1).IsEqual(p2.Rotated(Math.PI / 2), 0.00001)); p2.Rotate(Math.PI / 2); Assert.IsTrue(new Dir2d(0, 1).IsEqual(p2, 0.0001)); //TestContext.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0},{1},{2}", gp2.x, gp2.y, gp2.z)); Trsf2d t1 = new Trsf2d(); t1.SetRotation(new Pnt2d(1, 2), Math.PI / 2); p2 = new Dir2d(0, 1); Assert.IsTrue(new Dir2d(-1, 0).IsEqual(p2.Transformed(t1), 0.0001)); p2.Transform(t1); Assert.IsTrue(new Dir2d(-1, 0).IsEqual(p2, 0.0001)); }