Esempio n. 1
0
        private static void Main(string[] args)

        {
            TestVoxelization();
            //TS_Testing_Functions.TestModify();
            //TVGL3Dto2DTests.TestSilhouette();
            // Polygon_Testing_Functions.TestSimplify();
            //TS_Testing_Functions.TestClassify();
            //TVGL3Dto2DTests.TestXSectionAndMonotoneTriangulate();

#if PRESENT
            // 1. bubble up from the bin directories to find the TestFiles directory
            var polysValue = TestCases.MakeBumpyRings(50, 28, 1.8);
            //var polysValue = TestCases.EdgeCases["tinyOffsetProb"];
            var polygon1 = new Polygon(polysValue.Item1);
            var polygon2 = new Polygon(polysValue.Item2);
            //Presenter.ShowAndHang(new[] { polygon1, polygon2 });
            var polygons = polygon1.Union(polygon2);
            var polygon  = polygons.LargestPolygon();
            Presenter.ShowAndHang(polygon);
            polygon.Transform(Matrix3x3.CreateRotation(1));
            Presenter.ShowAndHang(polygon);

            //var polygons = new List<Polygon> { polygon1 };
            //var coords1 = TestCases.MakeStarryCircularPolygon(50, 28, 1.8).ToList();
            //var hole1 = TestCases.MakeStarryCircularPolygon(80, 14, 1.5).ToList();
            //hole1.Reverse();
            //var polygon1 = new Polygon(coords1);
            //polygon1 = polygon1.Intersect(new Polygon(hole1))[0];
            //Presenter.ShowAndHang(polygons);
            //var polygon1 = new Polygon(coords1, true);
            // Presenter.ShowAndHang(polygon1);
            //var polygons3 = polygon1.OffsetRound(88);
            var offsetBase = Math.Sqrt(polygons.LargestPolygon().Area);
            var factors    = new[] { -.03, 0.03, -.1, 0.1, -.3, 0.3, -1, 1, -3, 3, -10 };
            foreach (var factor in factors)
            {
                var offset    = factor * offsetBase;
                var polygons3 = polygons[0].OffsetRound(offset, 0.00254);
                Presenter.ShowAndHang(polygons3);
            }
#else
            //#endif
            //PolygonBooleanTester.FullComparison();
            //var stats = new List<(string, int, long, long)>();

            //foreach (var testCase in TestCases.GetAllTwoArgumentEdgeCases())
            //{
            //    var polys = testCase.Value;
            //    PolygonBooleanTester.SingleCompare(stats, TestCases.C2Poly(polys.Item1), TestCases.C2Poly(polys.Item2),
            //        TestCases.C2PLs(polys.Item1), TestCases.C2PLs(polys.Item2));
            //}
#endif
            //var summary = BenchmarkRunner.Run(typeof(PolygonBooleanTester).Assembly);
            //PolygonOperationsTesting.DebugEdgeCases("nestedSquares");
            //PolygonOperationsTesting.TestRemoveSelfIntersect();
            //PolygonOperationsTesting.DebugEdgeCases();
            //PolygonOperationsTesting.DebugOctagons();
            //PolygonOperationsTesting.TestUnionSimple();
        }
Esempio n. 2
0
    public string ApplyUserReset(Object2D realUser, Object2D virtualUser, Vector2 resetDirection)
    {
        //float ratio = 2;
        float rotationSpeed = 60.0f;

        if (isFirst)
        {
            initialAngle       = Vector2.SignedAngle(realUser.transform.forward, resetDirection);
            realTargetRotation = Matrix3x3.CreateRotation(initialAngle) * realUser.transform.forward;

            //virtualTargetRotation = Matrix3x3.CreateRotation(ratio * targetAngle) * virtualUser.transform.forward; freeze-turn when user reset
            isFirst = false;

            maxRotTime = Mathf.Abs(initialAngle) / rotationSpeed;
            //Debug.Log(maxRotTime);
            remainRotTime = 0;
        }

        float realAngle = Vector2.SignedAngle(realUser.transform.forward, realTargetRotation);

        if (remainRotTime < maxRotTime)
        {
            //Debug.Log(remainRotTime);
            realUser.Rotate(Mathf.Sign(initialAngle) * rotationSpeed * Time.fixedDeltaTime);
            //virtualUser.Rotate(ratio * rotationSpeed * Time.fixedDeltaTime);
            remainRotTime += Time.fixedDeltaTime;
        }
        else
        {
            SyncDirection(realUser, resetDirection);
            //Debug.Log("SYNC");

            //Utility.SyncDirection(virtualUser, realUser, virtualTargetRotation, realTargetRotation);

            //realUser.transform.position = realUser.transform.position + realUser.transform.forward * 0.1f;
            //if (realUser.gameObject != null) realUser.gameObject.transform.position = Utility.Cast2Dto3D(realUser.transform.position);

            //Utility.SyncPosition(virtualUser, realUser, virtualUser.transform.localPosition, newRealPosition);
            //bool isNeedReset = NeedWallReset(realUser, realSpace);

            //Debug.Log(virtualUser.transform);
            //Debug.Log(realUser.transform);
            ////Debug.Log(virtualUser.gameObject.transform.localPosition);
            ////Debug.Log(realUser.gameObject.transform.localPosition);
            //Debug.Log(isNeedReset);

            //realUser.transform.position = realUser.transform.position + realUser.transform.forward * 0.1f; // 다시 리셋 상태에 빠지는 것을 방지
            isFirst = true;
            return("DONE");
            //episode.DeleteTarget();
            //isFirst = true;
            //isFirst2 = true;
        }

        return("NOT_YET");
    }
Esempio n. 3
0
        public void GetBoundingRectangle_ShouldReturnMinimalAxisAlignedRectangleContainingThisRectangle_WhenRectangleIsNotAxisAligned()
        {
            // Arrange
            var rectangle = new Rectangle(new Vector2(4, 2), new Vector2(10, 6))
                            .Transform(Matrix3x3.CreateRotation(Angle.Deg2Rad(30)));

            // Act
            var boundingRectangle = rectangle.GetBoundingRectangle();

            // Assert
            Assert.That(boundingRectangle.Center, Is.EqualTo(new Vector2(2.464101, 3.732050)).Using(Vector2Comparer));
            Assert.That(boundingRectangle.Dimensions, Is.EqualTo(new Vector2(11.660254, 10.196152)).Using(Vector2Comparer));
        }
 public void Translate(Vector2 translation, Space relativeTo = Space.Self)
 {
     if (relativeTo == Space.World)
     {
         Vector2 newPosition = this.position + translation;
         this.position = newPosition;
     }
     else if (relativeTo == Space.Self)
     {
         Matrix3x3 rotationMatrix = Matrix3x3.CreateRotation(this.localRotation);
         Vector2   newPosition    = this.localPosition + rotationMatrix * translation;
         this.localPosition = newPosition;
     }
 }
Esempio n. 5
0
        public void Width_Test(double centerX, double centerY, double width, double height, double rotation, double expectedWidth)
        {
            // Arrange
            var center     = new Vector2(centerX, centerY);
            var dimensions = new Vector2(width, height);

            var rectangle = new Rectangle(center, dimensions).Transform(Matrix3x3.CreateRotation(Angle.Deg2Rad(rotation)));

            // Act
            var actualWidth = rectangle.Width;

            // Assert
            Assert.That(actualWidth, Is.EqualTo(expectedWidth));
        }
        private static IShape CreateRectangle(Vector2 center, Vector2 dimension, double rotation = 0, Axis[]?axes = null)
        {
            var rot = Matrix3x3.CreateRotation(Angle.Deg2Rad(rotation));

            var shape = CreatePolygon(
                (rot * new Vector2(-dimension.X / 2, -dimension.Y / 2).Homogeneous).ToVector2() + new Vector2(center.X, center.Y),
                (rot * new Vector2(+dimension.X / 2, -dimension.Y / 2).Homogeneous).ToVector2() + new Vector2(center.X, center.Y),
                (rot * new Vector2(+dimension.X / 2, +dimension.Y / 2).Homogeneous).ToVector2() + new Vector2(center.X, center.Y),
                (rot * new Vector2(-dimension.X / 2, +dimension.Y / 2).Homogeneous).ToVector2() + new Vector2(center.X, center.Y)
                );

            shape.GetAxes().Returns(axes ?? Array.Empty <Axis>());

            return(shape);
        }
Esempio n. 7
0
        /// <summary>
        ///     Creates view matrix that converts coordinates from 2D space to the screen space as seen by camera.
        /// </summary>
        /// <param name="cameraEntity">Entity with camera component attached.</param>
        /// <returns>View matrix that converts coordinates from 2D space to the screen space as seen by camera.</returns>
        public static Matrix3x3 Create2DWorldToScreenMatrix(this Entity cameraEntity)
        {
            if (!cameraEntity.HasComponent <CameraComponent>())
            {
                throw new ArgumentException("Entity is not a camera.");
            }

            var cameraTransform = cameraEntity.GetComponent <Transform2DComponent>();

            var cameraScale        = cameraTransform.Scale;
            var viewRectangleScale = GetViewRectangleScale(cameraEntity);
            var finalCameraScale   = new Vector2(cameraScale.X * viewRectangleScale.X, cameraScale.Y * viewRectangleScale.Y);

            return(Matrix3x3.CreateScale(new Vector2(1 / finalCameraScale.X, 1 / finalCameraScale.Y)) *
                   Matrix3x3.CreateRotation(-cameraTransform.Rotation) *
                   Matrix3x3.CreateTranslation(-cameraTransform.Translation) * Matrix3x3.Identity);
        }
Esempio n. 8
0
    //public RandomEpisode(Space2D virtualSpace, int episodeLength) : base(virtualSpace, episodeLength) { }

    protected override void GenerateEpisode(Transform2D virtualUserTransform, Space2D virtualSpace)
    {
        Vector2 samplingPosition = Vector2.zero;
        Vector2 userPosition     = virtualUserTransform.localPosition;

        do
        {
            float angle    = Utility.sampleUniform(-180.0f, 180.0f);
            float distance = Utility.sampleUniform(2.0f, 5.0f);

            Vector2 sampleForward = Matrix3x3.CreateRotation(angle) * virtualUserTransform.forward;
            //Vector3 sampleForward = Quaternion.AngleAxis(angle, Vector3.up) * simulationController.GetUserVirtualTransform().forward;

            samplingPosition = userPosition + sampleForward * distance; // local 좌표계에서 절대 위치 기준
        } while (!virtualSpace.IsInside(samplingPosition, 0.1f));       // while (!virtualSpace.IsReallyInside(userPosition, samplingPosition));

        currentTargetPosition = samplingPosition;
    }
Esempio n. 9
0
        public void Center_Test(double centerX, double centerY, double width, double height, double rotation)
        {
            // Arrange
            var center     = new Vector2(centerX, centerY);
            var dimensions = new Vector2(width, height);

            // We want to rotate around center of rectangle thus we need to transform by center after rotation.
            // ReSharper disable once CompareOfFloatsByEqualityOperator
            var rectangle = rotation == 0
                ? new Rectangle(center, dimensions)
                : new Rectangle(dimensions).Transform(Matrix3x3.CreateRotation(Angle.Deg2Rad(rotation))).Transform(Matrix3x3.CreateTranslation(center));

            // Act
            var actualCenter = rectangle.Center;

            // Assert
            Assert.That(actualCenter, Is.EqualTo(center).Using(Vector2Comparer));
        }
    public override string ApplyReset(Object2D realUser, Object2D virtualUser, Space2D realSpace, string resetType)
    {
        if (isFirst)
        {
            realTargetRotation    = Matrix3x3.CreateRotation(targetAngle) * realUser.transform.forward;
            virtualTargetRotation = Matrix3x3.CreateRotation(ratio * targetAngle) * virtualUser.transform.forward;
            isFirst = false;
        }

        float realAngle = Vector2.SignedAngle(realUser.transform.forward, realTargetRotation);

        if (Mathf.Abs(realAngle) >= epsilonRotation)
        {
            realUser.Rotate(rotationSpeed * Time.deltaTime);
            virtualUser.Rotate(ratio * rotationSpeed * Time.deltaTime);
        }
        else
        {
            Utility.SyncDirection(virtualUser, realUser, virtualTargetRotation, realTargetRotation);

            switch (resetType)
            {
            case "Wall":
                while (NeedWallReset(realUser, realSpace))
                {
                    CalculationErrorAdjustment(realUser.transform, resetType, (Polygon2D)realSpace.space);
                }
                break;

            case "User":
                break;
            }

            if (realUser.gameObject != null)
            {
                realUser.gameObject.transform.position = Utility.Cast2Dto3D(realUser.transform.position);
            }

            isFirst = true;
            return("DONE");
        }

        return("NOT_YET");
    }
Esempio n. 11
0
        public void CreateRotation(double angle, double m11, double m12, double m13, double m21, double m22,
                                   double m23, double m31, double m32, double m33)
        {
            // Arrange
            // Act
            var rotationMatrix = Matrix3x3.CreateRotation(angle);

            // Assert
            Assert.That(rotationMatrix.M11, Is.EqualTo(m11));
            Assert.That(rotationMatrix.M12, Is.EqualTo(m12));
            Assert.That(rotationMatrix.M13, Is.EqualTo(m13));

            Assert.That(rotationMatrix.M21, Is.EqualTo(m21));
            Assert.That(rotationMatrix.M22, Is.EqualTo(m22));
            Assert.That(rotationMatrix.M23, Is.EqualTo(m23));

            Assert.That(rotationMatrix.M31, Is.EqualTo(m31));
            Assert.That(rotationMatrix.M32, Is.EqualTo(m32));
            Assert.That(rotationMatrix.M33, Is.EqualTo(m33));
        }
Esempio n. 12
0
    public static GridData3D <VoxelInfo> Rotate(GridData3D <VoxelInfo> source, Vector3 axis, float radiant)
    {
        int width  = 0;
        int height = 0;
        int length = 0;

        GridData3D <VoxelInfo> result = new GridData3D <VoxelInfo>(width, height, length);

        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                for (int z = 0; z < length; z++)
                {
                    Vector3   afterPos  = new Vector3(x, y, z);
                    Vector3   beforePos = Matrix3x3.DotProduct(Matrix3x3.CreateRotation(axis, -radiant), afterPos);
                    VoxelInfo v         = source.GetDataAt((int)beforePos.x, (int)beforePos.y, (int)beforePos.z);
                }
            }
        }
        return(result);
    }
        private static (List <Vector2> points, List <bool> knownWrongPoints) MainOffsetRoutine(Polygon polygon, double offset, bool notMiter,
                                                                                               double maxLengthSquared, double tolerance, out int maxNumberOfPolygons, double deltaAngle = double.NaN)
        {
            maxNumberOfPolygons = 1;
            // set up the return list (predict size to prevent re-allocation) and rotation matrix for OffsetRound
            var numPoints = polygon.Edges.Length;
            int numFalsesToAdd;
            var startingListSize = numPoints;
            var roundCorners     = !double.IsNaN(deltaAngle);

            if (roundCorners)
            {
                startingListSize += (int)(2 * Math.PI / deltaAngle);
            }
            var offsetSign = Math.Sign(offset);
            var rotMatrix  = roundCorners ? Matrix3x3.CreateRotation(offsetSign * deltaAngle) : Matrix3x3.Null;

            if (notMiter && !roundCorners)
            {
                startingListSize = (int)(1.5 * startingListSize);
            }
            var pointsList  = new List <Vector2>(startingListSize);
            var wrongPoints = new List <bool>(startingListSize);
            // previous line starts at the end of the list and then updates to whatever next line was. In addition to the previous line, we
            // also want to capture the unit vector pointing outward (which is in the {Y, -X} direction). The prevLineLengthReciprocal was originally
            // thought to have uses outside of the unit vector but it doesn't. Anyway, slight speed up in calculating it once
            var prevLine = polygon.Edges[0];
            var prevLineLengthReciprocal = 1.0 / prevLine.Length;
            var prevUnitNormal           = new Vector2(prevLine.Vector.Y * prevLineLengthReciprocal, -prevLine.Vector.X * prevLineLengthReciprocal);

            for (int i = 1; i <= numPoints; i++)
            {
                var nextLine = (i == numPoints) ? polygon.Edges[0] : polygon.Edges[i];
                var nextLineLengthReciprocal = 1.0 / nextLine.Length;
                var nextUnitNormal           = new Vector2(nextLine.Vector.Y * nextLineLengthReciprocal, -nextLine.Vector.X * nextLineLengthReciprocal);
                // establish the new offset points for the point connecting prevLine to nextLive. this is stored as "point".
                var point = nextLine.FromPoint.Coordinates;
                var cross = prevLine.Vector.Cross(nextLine.Vector);
                var dot   = prevLine.Vector.Dot(nextLine.Vector);
                // cross/dot is the tan(angle). both dot and cross are quicker than square-root or trigonometric functions
                // and essentially tan(angle) * offset will be the distance between two points emanating from the polygons edges at
                // this point. If it is less than the tolerance, then just make one point - it doesn't matter if offset is negative/positive
                // or if angle is convex or concave. Oh, the 100 is added to account for problems that arise when intersections weren't detected
                if ((cross * offset / dot).IsNegligible(100 * tolerance))
                {
                    if (prevUnitNormal.Dot(nextUnitNormal) > 0)
                    {
                        // if line is practically straight, and going the same direction, then simply offset it without all the complication below
                        pointsList.Add(point + offset * prevUnitNormal);
                    }
                    else
                    {
                        pointsList.Add(point);
                    }
                }
                // if the cross is positive and the offset is positive (or there both negative), then we will need to make extra points
                // let's start with the roundCorners
                else if (cross * offset > 0)
                {
                    if ((polygon.IsPositive && offset < 0) || (!polygon.IsPositive && offset > 0))
                    {
                        maxNumberOfPolygons++;
                    }
                    if (roundCorners)
                    {
                        var firstPoint = point + offset * prevUnitNormal;
                        pointsList.Add(firstPoint);
                        var lastPoint         = point + offset * nextUnitNormal;
                        var firstToLastVector = lastPoint - firstPoint;
                        var firstToLastNormal = new Vector2(firstToLastVector.Y, -firstToLastVector.X);
                        // to avoid "costly" call to Math.Sin and Math.Cos, we create the transform matrix that 1) translates to origin
                        // 2) rotates by the angle, and 3) translates back
                        var transform = Matrix3x3.CreateTranslation(-point) * rotMatrix *
                                        Matrix3x3.CreateTranslation(point);
                        var nextPoint = firstPoint.Transform(transform);
                        // the challenge with this matrix transform is figuring out when to stop. But we know that all the new points must to on
                        // positive side of the line connecting the first and last points. This is defined by the following dot-product
                        while (offsetSign * firstToLastNormal.Dot(nextPoint - lastPoint) > 0)
                        {
                            pointsList.Add(nextPoint);
                            firstPoint = nextPoint;
                            nextPoint  = firstPoint.Transform(transform);
                        }
                        pointsList.Add(lastPoint);
                    }
                    // if the cross is positive and the offset is positive, then we will need to make extra points for the
                    // squaredCorners
                    else if (notMiter)
                    {
                        // find these two points by calling the LineLine2DIntersection function twice.
                        var middleUnitVector = (prevUnitNormal + nextUnitNormal).Normalize();
                        var middlePoint      = point + offset * middleUnitVector;
                        var middleDir        = new Vector2(-middleUnitVector.Y, middleUnitVector.X);
                        pointsList.Add(MiscFunctions.LineLine2DIntersection(point + offset * prevUnitNormal,
                                                                            prevLine.Vector, middlePoint, middleDir));
                        pointsList.Add(MiscFunctions.LineLine2DIntersection(middlePoint, middleDir,
                                                                            point + offset * nextUnitNormal, nextLine.Vector));
                    }
                    // miter and concave connections are done the same way...
                    else
                    {
                        var intersection = MiscFunctions.LineLine2DIntersection(point + offset * prevUnitNormal,
                                                                                prevLine.Vector, point + offset * nextUnitNormal, nextLine.Vector);
                        // if the corner is too shape the new point will be placed far away (near infinity). This is to rein it in
                        var vectorToCorner = intersection - point;
                        var vectorToCornerLengthSquared = vectorToCorner.LengthSquared();
                        if (vectorToCornerLengthSquared > maxLengthSquared)
                        {
                            intersection =
                                point + vectorToCorner * Math.Sqrt(maxLengthSquared / vectorToCornerLengthSquared);
                        }
                        pointsList.Add(intersection);
                    }
                }
                else
                {
                    numFalsesToAdd = pointsList.Count - wrongPoints.Count;
                    for (int k = 0; k < numFalsesToAdd; k++)
                    {
                        wrongPoints.Add(false);
                    }
                    wrongPoints.Add(true);
                    wrongPoints.Add(true);
                    pointsList.Add(point + offset * prevUnitNormal);
                    pointsList.Add(point + offset * nextUnitNormal);
                }
                prevLine       = nextLine;
                prevUnitNormal = nextUnitNormal;
            }
            numFalsesToAdd = pointsList.Count - wrongPoints.Count;
            for (int k = 0; k < numFalsesToAdd; k++)
            {
                wrongPoints.Add(false);
            }
            return(pointsList, wrongPoints);
        }
    public (Vector2, float) VirtualMove(Object2D realUser, Object2D virtualUser, Space2D virtualSpace)
    {
        Transform2D virtualUserTransform = virtualUser.transform;

        if (!initializing)
        {
            ResetCurrentState(virtualUserTransform);
            initializing = false;
        }

        if (episode.IsNotEnd())
        {
            if (isFirst)
            {
                isFirst         = false;
                targetPosition  = episode.GetTarget(virtualUserTransform, virtualSpace);
                initialToTarget = targetPosition - virtualUserTransform.localPosition;
                float InitialAngle    = Vector2.SignedAngle(virtualUserTransform.forward, initialToTarget);
                float initialDistance = Vector2.Distance(virtualUserTransform.localPosition, targetPosition);

                virtualTargetDirection = Matrix3x3.CreateRotation(InitialAngle) * virtualUser.transform.forward; // target을 향하는 direction(forward)를 구함
                //realTargetDirection = Matrix3x3.CreateRotation(InitialAngle) * realUser.transform.forward;

                virtualTargetPosition = virtualUser.transform.localPosition + virtualTargetDirection * initialDistance; // target에 도달하는 position을 구함
                //realTargetPosition = realUser.transform.localPosition + realTargetDirection * initialDistance;

                maxRotTime      = Mathf.Abs(InitialAngle) / rotationSpeed;
                maxTransTime    = initialDistance / translationSpeed;
                remainRotTime   = 0;
                remainTransTime = 0;

                initialAngleDirection = Mathf.Sign(InitialAngle);
            }

            float distance = (targetPosition - virtualUserTransform.localPosition).magnitude;
            float angle    = Vector2.SignedAngle(virtualUserTransform.forward, initialToTarget);

            if (remainRotTime < maxRotTime)
            {
                virtualUser.Rotate(initialAngleDirection * rotationSpeed * Time.fixedDeltaTime);
                remainRotTime += Time.fixedDeltaTime;
            }
            else if (remainTransTime < maxTransTime)
            {
                if (isFirst2) // 방향을 동기화
                {
                    isFirst2 = false;
                    SyncDirection(virtualUser, virtualTargetDirection);
                }
                else
                {
                    virtualUser.Translate(virtualUserTransform.forward * translationSpeed * Time.fixedDeltaTime, Space.World);
                    remainTransTime += Time.fixedDeltaTime;
                }
            }
            else
            {
                if (isFirst3) // 위치를 동기화
                {
                    isFirst3 = false;
                    SyncPosition(virtualUser, virtualTargetPosition);
                }
                else
                {
                    episode.DeleteTarget();

                    //Debug.Log(string.Format("realUser: {0}", realUser.transform));
                    //Debug.Log(string.Format("virtualUser: {0}", virtualUser.transform));

                    isFirst  = true;
                    isFirst2 = true;
                    isFirst3 = true;
                }
            }
        }

        UpdateCurrentState(virtualUserTransform);

        return(GetDelta(virtualUserTransform.forward));
    }
Esempio n. 15
0
 /// <summary>
 ///     Creates 2D transformation matrix that represents this transform component.
 /// </summary>
 /// <returns>2D transformation matrix representing this transform component.</returns>
 public Matrix3x3 ToMatrix() =>
 Matrix3x3.CreateTranslation(Translation)
 * Matrix3x3.CreateRotation(Rotation)
 * Matrix3x3.CreateScale(Scale)
 * Matrix3x3.Identity;
        private static void Run()
        {
            #region Near Equality Methods
            var  x            = 1.0;
            var  y            = 2.0;
            bool isItTrueThat = x.IsPracticallySame(y);
            isItTrueThat = x.IsPracticallySame(y);
            Vector2 v2_1 = new Vector2(1.0, 2.0);
            Vector2 v2_2 = new Vector2(1.00000000001, 2.000000000002);
            isItTrueThat = v2_1.IsPracticallySame(v2_2);
            Vector3 v3_1 = new Vector3(1.0, 2.0, 3.0);
            Vector3 v3_2 = new Vector3(1.00000000001, 2.000000000002, 3.0);
            isItTrueThat = v3_1.IsPracticallySame(v3_2);
            isItTrueThat = x.IsNegligible();
            isItTrueThat = v2_1.IsNegligible();
            isItTrueThat = v3_1.IsNegligible();
            isItTrueThat = x.IsGreaterThanNonNegligible(y);
            isItTrueThat = x.IsLessThanNonNegligible(y);

            #endregion

            #region All Vector2 Methods
            v2_1 = new Vector2();
            Vector2  nullVector2  = Vector2.Null;
            Vector2  zeroVector2  = Vector2.Zero;
            Vector2  oneVector2   = Vector2.One;
            Vector2  unitVector2X = Vector2.UnitX;
            Vector2  unitVector2Y = Vector2.UnitY;
            Vector2  copyVector   = v2_1.Copy();
            double[] coordinates  = v2_1.Position;
            x = v2_1.X;
            x = v2_1[0];
            y = v2_1.Y;
            y = v2_1[1];
            double  length          = v2_1.Length();
            double  lengthSquared   = v2_1.LengthSquared();
            double  distance        = v2_1.Distance(zeroVector2);
            double  distanceSquared = v2_1.DistanceSquared(zeroVector2);
            Vector2 normal          = v2_1.Normalize();
            Vector2 reflect         = v2_1.Reflect(unitVector2Y);
            Vector2 clamp           = v2_1.Clamp(zeroVector2, oneVector2);
            Vector2 lerp            = v2_1.Lerp(oneVector2, 0.5);

            v2_2 = v2_1 + v2_1;
            v2_2 = v2_1 - v2_1;
            v2_2 = v2_1 * v2_1; //not dot or cross - basically a
            //component to component product vector whos terms sum to dot product
            v2_2         = v2_1 - v2_1;
            v2_2         = v2_1 / v2_1;
            v2_2         = v2_1 / new double();
            v2_2         = -v2_1;
            isItTrueThat = v2_1.IsNull();
            isItTrueThat = v2_1.IsNegligible();
            v2_1.CopyTo(coordinates);
            isItTrueThat = v2_1 == v2_2;
            isItTrueThat = v2_1 != v2_2;
            double  dot        = v2_1.Dot(v2_2);
            double  cross      = v2_1.Cross(v2_2);
            Vector2 minVector  = Vector2.Min(v2_1, v2_2);
            Vector2 maxVector  = Vector2.Max(v2_1, v2_2);
            Vector2 absVector  = Vector2.Abs(v2_1);
            Vector2 sqrtVector = Vector2.SquareRoot(v2_1);

            Matrix3x3 m3x3 = new Matrix3x3();
            v2_1 = v2_1.Transform(m3x3);
            v2_1 = v2_1.TransformNoTranslate(m3x3);

            Matrix4x4 m4x4 = new Matrix4x4();
            v2_1 = v2_1.Transform(m4x4);
            v2_1 = v2_1.TransformNoTranslate(m4x4);
            v2_1 = v2_1.Transform(new Quaternion());
            #endregion

            #region All Matrix3x3 Methods
            isItTrueThat = m3x3.IsProjectiveTransform;
            double value = m3x3.M11;
            value        = m3x3.M12;
            value        = m3x3.M13;
            value        = m3x3.M21;
            value        = m3x3.M22;
            value        = m3x3.M23;
            value        = m3x3.M31;
            value        = m3x3.M32;
            value        = m3x3.M33;
            m3x3         = Matrix3x3.Identity;
            m3x3         = Matrix3x3.Null;
            isItTrueThat = m3x3.IsIdentity();
            isItTrueThat = m3x3.IsNull();
            Vector2 t = m3x3.Translation;
            m3x3         = Matrix3x3.CreateTranslation(t);
            m3x3         = Matrix3x3.CreateTranslation(x, y);
            m3x3         = Matrix3x3.CreateScale(1.0);
            m3x3         = Matrix3x3.CreateScale(x, y);
            m3x3         = Matrix3x3.CreateScale(Vector2.One);
            m3x3         = Matrix3x3.CreateScale(x, y, v2_2);    //vResult is the center of scaling
            m3x3         = Matrix3x3.CreateSkew(2.0, 2.0);
            m3x3         = Matrix3x3.CreateSkew(2.0, 2.0, v2_2); //vResult is the center of skewing
            m3x3         = Matrix3x3.CreateRotation(1.0);        //in radians
            m3x3         = Matrix3x3.CreateRotation(1.0, v2_2);  //vResult is the center of rotate
            m3x3         = m3x3.Transpose();
            isItTrueThat = Matrix3x3.Invert(m3x3, out Matrix3x3 invM3x3);
            var d = m3x3.GetDeterminant();
            m3x3 = Matrix3x3.Lerp(m3x3, m3x3, 0.5);
            m3x3 = -m3x3;
            var m3x3Another = 4.0 * m3x3;
            m3x3 = m3x3 + m3x3;
            m3x3 = m3x3 - m3x3;
            m3x3 = m3x3 * m3x3;

            isItTrueThat = m3x3 == m3x3Another;
            isItTrueThat = m3x3 != m3x3Another;
            #endregion

            #region All Vector3 Methods

            v3_1 = new Vector3();
            v3_1 = new Vector3(v2_1, 0.0);
            Vector3 nullVector3  = Vector3.Null;
            Vector3 zeroVector3  = Vector3.Zero;
            Vector3 oneVector3   = Vector3.One;
            Vector3 unitVector3X = Vector3.UnitX;
            Vector3 unitVector3Y = Vector3.UnitY;
            Vector3 unitVector3Z = Vector3.UnitZ;
            unitVector3X = Vector3.UnitVector(CartesianDirections.XNegative);
            unitVector3X = Vector3.UnitVector(0);

            Vector3 copyVector3 = v3_1.Copy();
            coordinates = v3_1.Position;
            x           = v3_1.X;
            x           = v3_1[0];
            y           = v3_1.Y;
            y           = v3_1[1];
            double z = v3_1.Z;
            y               = v3_1[2];
            length          = v3_1.Length();
            lengthSquared   = v3_1.LengthSquared();
            distance        = v3_1.Distance(zeroVector3);
            distanceSquared = v3_1.DistanceSquared(zeroVector3);
            Vector3 normal3  = v3_1.Normalize();
            Vector3 reflect3 = v3_1.Reflect(unitVector3Y);
            Vector3 clamp3   = v3_1.Clamp(zeroVector3, oneVector3);
            Vector3 lerp3    = v3_1.Lerp(oneVector3, 0.5);

            v3_2 = v3_1 + v3_1;
            v3_2 = v3_1 - v3_1;
            v3_2 = v3_1 * v3_1; //not dot or cross - basically a
            //component to component product vector whos terms sum to dot product
            v3_2         = v3_1 - v3_1;
            v3_2         = v3_1 / v3_1;
            v3_2         = v3_1 / new double();
            v3_2         = -v3_1;
            isItTrueThat = v3_1.IsNull();
            isItTrueThat = v3_1.IsNegligible();
            v3_1.CopyTo(coordinates);
            isItTrueThat = v3_1 == v3_2;
            isItTrueThat = v3_1 != v3_2;
            double  dot3        = v3_1.Dot(v3_2);
            Vector3 cross3      = v3_1.Cross(v3_2);
            Vector3 minVector3  = Vector3.Min(v3_1, v3_2);
            Vector3 maxVector3  = Vector3.Max(v3_1, v3_2);
            Vector3 absVector3  = Vector3.Abs(v3_1);
            Vector3 sqrtVector3 = Vector3.SquareRoot(v3_1);

            m3x3 = new Matrix3x3();
            v3_1 = v3_1.Multiply(m3x3);

            m4x4 = new Matrix4x4();
            v3_1 = v3_1.Transform(m4x4);
            v3_1 = v3_1.TransformNoTranslate(m4x4);
            v3_1 = v3_1.Transform(new Quaternion());
            #endregion

            #region All Matrix4x4 Methods
            isItTrueThat = m4x4.IsProjectiveTransform;
            value        = m4x4.M11;
            value        = m4x4.M12;
            value        = m4x4.M13;
            value        = m4x4.M14;
            value        = m4x4.M21;
            value        = m4x4.M22;
            value        = m4x4.M23;
            value        = m4x4.M24;
            value        = m4x4.M31;
            value        = m4x4.M32;
            value        = m4x4.M33;
            value        = m4x4.M34;
            value        = m4x4.M41;
            value        = m4x4.M42;
            value        = m4x4.M43;
            value        = m4x4.M44;
            m4x4         = Matrix4x4.Identity;
            m4x4         = Matrix4x4.Null;
            m4x4         = new Matrix4x4(m3x3);
            isItTrueThat = m4x4.IsIdentity();
            isItTrueThat = m4x4.IsNull();
            Vector3 t3 = m4x4.TranslationAsVector;
            m4x4 = Matrix4x4.CreateBillboard(v3_1, v3_1, v3_1, v3_1);
            m4x4 = Matrix4x4.CreateConstrainedBillboard(v3_1, v3_1, v3_1, v3_1, v3_1);


            m4x4 = Matrix4x4.CreateTranslation(t3);
            m4x4 = Matrix4x4.CreateTranslation(x, y, z);
            m4x4 = Matrix4x4.CreateScale(1.0);
            m4x4 = Matrix4x4.CreateScale(x, y, z);
            m4x4 = Matrix4x4.CreateScale(v3_1);
            m4x4 = Matrix4x4.CreateScale(v3_1, v3_2);        //vOther is the center of scaling
            m4x4 = Matrix4x4.CreateScale(x, y, z, v3_2);     //vOther is the center of scaling
            m4x4 = Matrix4x4.CreateRotationX(1.0);           //in radians
            m4x4 = Matrix4x4.CreateRotationX(1.0, v3_2);     //vOther is the center of rotate
            m4x4 = Matrix4x4.CreateRotationY(1.0);           //in radians
            m4x4 = Matrix4x4.CreateRotationY(1.0, v3_2);     //vOther is the center of rotate
            m4x4 = Matrix4x4.CreateRotationZ(1.0);           //in radians
            m4x4 = Matrix4x4.CreateRotationZ(1.0, v3_2);     //vOther is the center of rotate
            m4x4 = Matrix4x4.CreateFromAxisAngle(v3_2, 1.0); //vOther is the center of rotate
            m4x4 = Matrix4x4.CreatePerspectiveFieldOfView(1.0, 2.0, 3.0, 4.0);
            m4x4 = Matrix4x4.CreatePerspective(1.0, 1.0, 1.0, 1.0);
            m4x4 = Matrix4x4.CreatePerspectiveOffCenter(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
            m4x4 = Matrix4x4.CreateOrthographic(1.0, 2.0, 3.0, 4.0);
            m4x4 = Matrix4x4.CreateOrthographicOffCenter(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
            m4x4 = Matrix4x4.CreateLookAt(v3_1, v3_1, v3_2);
            m4x4 = Matrix4x4.CreateWorld(v3_1, v3_1, v3_2);
            m4x4 = Matrix4x4.CreateFromYawPitchRoll(1.0, 2.0, 3.0);
            m4x4 = Matrix4x4.CreateFromQuaternion(new Quaternion());
            m4x4 = Matrix4x4.CreateShadow(v3_1, new Plane(d, v3_2));
            m4x4 = Matrix4x4.CreateReflection(new Plane(d, v3_2));

            m4x4         = m4x4.Transpose();
            isItTrueThat = Matrix4x4.Invert(m4x4, out Matrix4x4 invm4x4);
            d            = m4x4.GetDeterminant();
            isItTrueThat = m4x4.Decompose(out var scale, out var rotQ, out var trans3);

            m4x4 = m4x4.Transform(rotQ);

            m4x4 = Matrix4x4.Lerp(m4x4, m4x4, 0.5);
            m4x4 = -m4x4;
            var m4x4Another = 4.0 * m4x4;
            m4x4 = m4x4 + m4x4;
            m4x4 = m4x4 - m4x4;
            m4x4 = m4x4 * m4x4;

            isItTrueThat = m4x4 == m4x4Another;
            isItTrueThat = m4x4 != m4x4Another;
            #endregion

            #region All Quaternion Methods
            var quat = new Quaternion();
            x = quat.X;
            y = quat.Y;
            z = quat.Z;
            var w         = quat.W;
            var quatOther = new Quaternion(v3_1, w);
            quat         = new Quaternion(x, y, z, w);
            quat         = Quaternion.Identity;
            isItTrueThat = quat.IsIdentity();
            quat         = Quaternion.Null;
            isItTrueThat = quat.IsNull();
            length       = quat.Length();
            length       = quat.LengthSquared();
            quat         = quat.Normalize();
            quat         = quat.Conjugate();
            quat         = quat.Inverse();
            quat         = Quaternion.CreateFromAxisAngle(v3_1, d);
            quat         = Quaternion.CreateFromYawPitchRoll(1.0, 2.0, 3.0);
            quat         = Quaternion.CreateFromRotationMatrix(m4x4);
            dot          = quat.Dot(quat);
            quat         = Quaternion.Lerp(quat, quat, 0.5);
            quat         = Quaternion.Slerp(quat, quat, 0.5);
            quat         = -quat;
            quat         = quat + quat;
            quat         = quat - quat;
            quat         = quat * quat;
            quat         = 4.0 * quat;
            quat         = quat / quat;
            isItTrueThat = quat == quatOther;
            isItTrueThat = quat != quatOther;
            #endregion

            #region All Plane Methods
            var plane = new Plane();
            plane = new Plane(d, v3_1);
            var planeOther = new Plane(d, new Vector3(x, y, z));
            v3_1  = plane.Normal;
            d     = plane.DistanceToOrigin;
            plane = Plane.CreateFromVertices(v3_1, unitVector3X, v3_2);
            plane.Normalize();
            plane.Transform(m4x4);
            plane.Transform(quat);
            dot          = plane.DotCoordinate(v3_1);
            dot          = plane.DotNormal(v3_1);
            isItTrueThat = plane == planeOther;
            isItTrueThat = plane != planeOther;
            #endregion

            #region IEnumerable<double> Statistics
            IEnumerable <double> numbers = new[] { 1.1, 2.2, 3.3 };
            var mean      = numbers.Mean();
            var median    = numbers.Median();
            var nrmse     = numbers.NormalizedRootMeanSquareError();
            var nthMedian = numbers.NthOrderStatistic(3);
            var varMean   = numbers.VarianceFromMean(mean);
            var varMedian = numbers.VarianceFromMedian(median);
            #endregion
        }