Пример #1
0
        public void Hull_of_Box3_with_empty_Box3_is_original_Box3()
        {
            var a = new Box3(minCorner: new Vector3(2.72, 3.14, 1.23), dimensions: new Vector3(1.0, 2.0, 3.0));

            var c = Box3.Hull(a, Box3.Empty);

            ExpectAlmostEqualBoxes(a, c, _tolerance);

            c = Box3.Hull(Box3.Empty, a);
            ExpectAlmostEqualBoxes(a, c, _tolerance);
        }
Пример #2
0
        public static Vector3 Corner(this Box3 @this, Interval.EndType end)
        {
            switch (end)
            {
            case Interval.EndType.Min:
                return(@this.MinCorner);

            case Interval.EndType.Max:
                return(@this.MaxCorner);

            default:
                throw new ArgumentOutOfRangeException("end", end, "Illegal EndType " + end.ToString());
            }
        }
Пример #3
0
        public void Hull_of_two_Box3_is_correct()
        {
            var a = new Box3(minCorner: new Vector3(2.72, 3.14, 1.23), dimensions: new Vector3(1.0, 2.0, 3.0));
            var b = new Box3(minCorner: new Vector3(3.5, 2.5, 3.21), dimensions: new Vector3(2.0, 1.5, 1.0));

            var c = Box3.Hull(a, b);

            Expect(c.MinCorner.X, Is.EqualTo(2.72).Within(_tolerance));
            Expect(c.MinCorner.Y, Is.EqualTo(2.5).Within(_tolerance));
            Expect(c.MinCorner.Z, Is.EqualTo(1.23).Within(_tolerance));

            Expect(c.MaxCorner.X, Is.EqualTo(5.5).Within(_tolerance));
            Expect(c.MaxCorner.Y, Is.EqualTo(5.14).Within(_tolerance));
            Expect(c.MaxCorner.Z, Is.EqualTo(4.23).Within(_tolerance));
        }
Пример #4
0
        public static Interval Range(this Box3 @this, Vector3.Axis axis)
        {
            switch (axis)
            {
            case Vector3.Axis.X:
                return(@this.XRange);

            case Vector3.Axis.Y:
                return(@this.YRange);

            case Vector3.Axis.Z:
                return(@this.ZRange);

            default:
                throw new ArgumentOutOfRangeException("Invalid 3D axis " + axis.ToString());
            }
        }
Пример #5
0
        public void Hull_of_a_sequence_of_Vector2_is_correct()
        {
            var points = new List <Vector3>()
            {
                new Vector3(2.72, 3.14, 1.0),
                new Vector3(3.72, 2.14, 0.1),
                new Vector3(4.72, 1.14, 2.0),
                new Vector3(4.02, 4.14, -1.0)
            };

            var c = Box3.Hull(points);

            Expect(c.MinCorner.X, Is.EqualTo(2.72).Within(_tolerance));
            Expect(c.MinCorner.Y, Is.EqualTo(1.14).Within(_tolerance));
            Expect(c.MinCorner.Z, Is.EqualTo(-1.0).Within(_tolerance));
            Expect(c.MaxCorner.X, Is.EqualTo(4.72).Within(_tolerance));
            Expect(c.MaxCorner.Y, Is.EqualTo(4.14).Within(_tolerance));
            Expect(c.MaxCorner.Z, Is.EqualTo(2.0).Within(_tolerance));
        }
Пример #6
0
 static Box3()
 {
     _emptyBox    = new Box3(Interval.Empty, Interval.Empty, Interval.Empty);
     _entirePlane = new Box3(Interval.EntireLine, Interval.EntireLine, Interval.EntireLine);
 }
Пример #7
0
        public void Any_Box2_Contains_any_empty_Box2()
        {
            var a = new Box3(minCorner: new Vector3(2.72, 3.14, 1.23), dimensions: new Vector3(1.0, 2.0, 3.0));

            Expect(a.Contains(Box3.Empty));
        }
Пример #8
0
 public static bool IsOnNegativeSide(this Box3 @this, Plane plane)
 {
     return(@this.Vertices.All(v => !v.IsOnPositiveSide(plane)));
 }
Пример #9
0
 public static Vector3 FromBoxCoords(this Vector3 v, Box3 box)
 {
     return(new Vector3(box.MinX + box.XDimension * v.X, box.MinY + box.YDimension * v.Y, box.MinZ + box.ZDimension * v.Z));
 }
Пример #10
0
 public static Vector3 ToBoxCoords(this Vector3 v, Box3 box)
 {
     return(new Vector3((v.X - box.MinX) / box.XDimension, (v.Y - box.MinY) / box.YDimension, (v.Z - box.MinZ) / box.ZDimension));
 }
Пример #11
0
 public static double DistanceTo(this Vector3 @this, Box3 box)
 {
     return(Math.Sqrt(Distance2(box, @this)));
 }
Пример #12
0
 public static double Distance2(this Box3 @this, Vector3 point)
 {
     return(@this.XRange.Distance2(point.X) + @this.YRange.Distance2(point.Y) + @this.ZRange.Distance2(point.Z));
 }