Exemplo n.º 1
0
        public void From3Points_Should()
        {
            var plane = Plane.From3Points(Vector3.Zero.AsPointF(), Vector3.UnitZ.AsPointF(), Vector3.UnitX.AsPointF());

            Assert.Zero(plane.D);
            Assert.Zero(Vector3.Cross(Vector3.UnitY, plane.Normal).Length());
        }
Exemplo n.º 2
0
        public void CalculateIntersectionPoint_Should()
        {
            var plane = new Plane(Vector3.UnitY, new PointF(0, 1, 0));

            var point = plane.CalculateIntersectionPoint(new Line(PointF.Zero, 0.5f * Vector3.UnitY));

            Assert.AreEqual(Vector3.UnitY, point.Value.AsVector());
        }
Exemplo n.º 3
0
        public void Init_Should()
        {
            var plane = new MinecraftSharp.Infrastructure.SimpleMath.Plane(Vector3.UnitX, PointF.Zero);

            Assert.AreEqual(Vector3.UnitX, plane.Normal);
            Assert.Zero(plane.D);


            var random = new Random();

            for (int i = 0; i < 1e6; i++)
            {
                var normal = new Vector3((float)random.NextDouble(), (float)random.NextDouble(),
                                         (float)random.NextDouble());
                normal = Vector3.Normalize(normal);
                plane  = new Plane(Vector3.Normalize(normal), normal.AsPointF());

                Assert.AreEqual(normal.Length(), Math.Abs(plane.D), 10e-5);
            }
        }