public void Clone() { ConvexPolyhedron convexPolyhedron = new ConvexPolyhedron( new[] { new Vector3(0, 0, 0), new Vector3(1, 0, 0), new Vector3(0, 2, 0), new Vector3(0, 0, 3), new Vector3(1, 5, 0), new Vector3(0, 1, 7), }); ConvexPolyhedron clone = convexPolyhedron.Clone() as ConvexPolyhedron; Assert.IsNotNull(clone); for (int i = 0; i < clone.Vertices.Count; i++) { Assert.AreEqual(convexPolyhedron.Vertices[i], clone.Vertices[i]); } Assert.AreEqual(convexPolyhedron.GetAabb(Pose.Identity), clone.GetAabb(Pose.Identity)); Assert.AreEqual(convexPolyhedron.InnerPoint, clone.InnerPoint); Assert.AreEqual(convexPolyhedron.GetSupportPoint(new Vector3(1, 1, 1)), clone.GetSupportPoint(new Vector3(1, 1, 1))); Assert.AreEqual(convexPolyhedron.GetAabb(Pose.Identity).Minimum, clone.GetAabb(Pose.Identity).Minimum); Assert.AreEqual(convexPolyhedron.GetAabb(Pose.Identity).Maximum, clone.GetAabb(Pose.Identity).Maximum); }
public void Clone() { ConvexPolyhedron convexPolyhedron = new ConvexPolyhedron( new[] { new Vector3F(0, 0, 0), new Vector3F(1, 0, 0), new Vector3F(0, 2, 0), new Vector3F(0, 0, 3), new Vector3F(1, 5, 0), new Vector3F(0, 1, 7), }); ConvexPolyhedron clone = convexPolyhedron.Clone() as ConvexPolyhedron; Assert.IsNotNull(clone); for (int i = 0; i < clone.Vertices.Count; i++) Assert.AreEqual(convexPolyhedron.Vertices[i], clone.Vertices[i]); Assert.AreEqual(convexPolyhedron.GetAabb(Pose.Identity), clone.GetAabb(Pose.Identity)); Assert.AreEqual(convexPolyhedron.InnerPoint, clone.InnerPoint); Assert.AreEqual(convexPolyhedron.GetSupportPoint(new Vector3F(1,1,1)), clone.GetSupportPoint(new Vector3F(1, 1, 1))); Assert.AreEqual(convexPolyhedron.GetAabb(Pose.Identity).Minimum, clone.GetAabb(Pose.Identity).Minimum); Assert.AreEqual(convexPolyhedron.GetAabb(Pose.Identity).Maximum, clone.GetAabb(Pose.Identity).Maximum); }
public void SerializationBinary() { var a = new ConvexPolyhedron( new[] { new Vector3(0, 0, 0), new Vector3(1, 0, 0), new Vector3(0, 2, 0), new Vector3(0, 0, 3), new Vector3(1, 5, 0), new Vector3(0, 1, 7), }); // Serialize object. var stream = new MemoryStream(); var formatter = new BinaryFormatter(); formatter.Serialize(stream, a); // Deserialize object. stream.Position = 0; var deserializer = new BinaryFormatter(); var b = (ConvexPolyhedron)deserializer.Deserialize(stream); for (int i = 0; i < b.Vertices.Count; i++) { Assert.AreEqual(a.Vertices[i], b.Vertices[i]); } Assert.AreEqual(a.GetAabb(Pose.Identity), b.GetAabb(Pose.Identity)); Assert.AreEqual(a.InnerPoint, b.InnerPoint); Assert.AreEqual(a.GetSupportPoint(new Vector3(1, 1, 1)), b.GetSupportPoint(new Vector3(1, 1, 1))); }
public void EmptyConvexPolyhedron() { ConvexPolyhedron convexPolyhedron = new ConvexPolyhedron(Enumerable.Empty<Vector3F>()); Assert.AreEqual(0, convexPolyhedron.Vertices.Count); Assert.AreEqual(Vector3F.Zero, convexPolyhedron.InnerPoint); Assert.AreEqual(new Aabb(), convexPolyhedron.GetAabb(Pose.Identity)); }
public void EmptyConvexPolyhedron() { ConvexPolyhedron convexPolyhedron = new ConvexPolyhedron(Enumerable.Empty <Vector3>()); Assert.AreEqual(0, convexPolyhedron.Vertices.Count); Assert.AreEqual(Vector3.Zero, convexPolyhedron.InnerPoint); Assert.AreEqual(new Aabb(), convexPolyhedron.GetAabb(Pose.Identity)); }
public void OnePoint() { Vector3F point = new Vector3F(1, 0, 0); ConvexPolyhedron convexPolyhedron = new ConvexPolyhedron(new[] { point }); Assert.AreEqual(1, convexPolyhedron.Vertices.Count); Assert.AreEqual(point, convexPolyhedron.InnerPoint); Assert.AreEqual(new Aabb(point, point), convexPolyhedron.GetAabb(Pose.Identity)); }
public void OnePoint() { Vector3 point = new Vector3(1, 0, 0); ConvexPolyhedron convexPolyhedron = new ConvexPolyhedron(new[] { point }); Assert.AreEqual(1, convexPolyhedron.Vertices.Count); Assert.AreEqual(point, convexPolyhedron.InnerPoint); Assert.AreEqual(new Aabb(point, point), convexPolyhedron.GetAabb(Pose.Identity)); }
public void TwoPoints() { Vector3 point0 = new Vector3(1, 0, 0); Vector3 point1 = new Vector3(10, 0, 0); ConvexPolyhedron convexPolyhedron = new ConvexPolyhedron(new[] { point0, point1 }); Assert.AreEqual(2, convexPolyhedron.Vertices.Count); Assert.AreEqual((point0 + point1) / 2, convexPolyhedron.InnerPoint); Assert.AreEqual(new Aabb(point0, point1), convexPolyhedron.GetAabb(Pose.Identity)); }
public void ThreePoints() { Vector3 point0 = new Vector3(1, 1, 1); Vector3 point1 = new Vector3(2, 1, 1); Vector3 point2 = new Vector3(1, 2, 1); ConvexPolyhedron convexPolyhedron = new ConvexPolyhedron(new[] { point0, point1, point2 }); Assert.AreEqual(3, convexPolyhedron.Vertices.Count); Assert.AreEqual((point0 + point1 + point2) / 3, convexPolyhedron.InnerPoint); Assert.AreEqual(new Aabb(new Vector3(1, 1, 1), new Vector3(2, 2, 1)), convexPolyhedron.GetAabb(Pose.Identity)); }
public void TwoPoints() { Vector3F point0 = new Vector3F(1, 0, 0); Vector3F point1 = new Vector3F(10, 0, 0); ConvexPolyhedron convexPolyhedron = new ConvexPolyhedron(new[] { point0, point1 }); Assert.AreEqual(2, convexPolyhedron.Vertices.Count); Assert.AreEqual((point0 + point1) / 2, convexPolyhedron.InnerPoint); Assert.AreEqual(new Aabb(point0, point1), convexPolyhedron.GetAabb(Pose.Identity)); }
public void ThreePoints() { Vector3F point0 = new Vector3F(1, 1, 1); Vector3F point1 = new Vector3F(2, 1, 1); Vector3F point2 = new Vector3F(1, 2, 1); ConvexPolyhedron convexPolyhedron = new ConvexPolyhedron(new[] { point0, point1, point2 }); Assert.AreEqual(3, convexPolyhedron.Vertices.Count); Assert.AreEqual((point0 + point1 + point2) / 3, convexPolyhedron.InnerPoint); Assert.AreEqual(new Aabb(new Vector3F(1, 1, 1), new Vector3F(2, 2, 1)), convexPolyhedron.GetAabb(Pose.Identity)); }
public void SerializationBinary() { var a = new ConvexPolyhedron( new[] { new Vector3F(0, 0, 0), new Vector3F(1, 0, 0), new Vector3F(0, 2, 0), new Vector3F(0, 0, 3), new Vector3F(1, 5, 0), new Vector3F(0, 1, 7), }); // Serialize object. var stream = new MemoryStream(); var formatter = new BinaryFormatter(); formatter.Serialize(stream, a); // Deserialize object. stream.Position = 0; var deserializer = new BinaryFormatter(); var b = (ConvexPolyhedron)deserializer.Deserialize(stream); for (int i = 0; i < b.Vertices.Count; i++) Assert.AreEqual(a.Vertices[i], b.Vertices[i]); Assert.AreEqual(a.GetAabb(Pose.Identity), b.GetAabb(Pose.Identity)); Assert.AreEqual(a.InnerPoint, b.InnerPoint); Assert.AreEqual(a.GetSupportPoint(new Vector3F(1, 1, 1)), b.GetSupportPoint(new Vector3F(1, 1, 1))); }