Beispiel #1
0
        [TestCase(4, 3, 3, 2, 1, 2, 45)]  // obtuse deg rotated
        public static void CreateFromPoints_Creates_Angular_Offset_Formed_by_3_Points(
            double x1, double y1,
            double x2, double y2,
            double x3, double y3,
            double expectedAngleDegrees)
        {
            CartesianCoordinate point1 = new CartesianCoordinate(x1, y1);
            CartesianCoordinate point2 = new CartesianCoordinate(x2, y2);
            CartesianCoordinate point3 = new CartesianCoordinate(x3, y3);
            AngularOffset       offset = AngularOffset.CreateFromPoints(point1, point2, point3);

            Assert.AreEqual(expectedAngleDegrees, offset.ToAngle().Degrees, Tolerance);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Transformations"/> class.
        /// </summary>
        /// <param name="localOriginInGlobal">The local origin in global coordinates.</param>
        /// <param name="localAxisXPtInGlobal">Any point along the local x-axis in global coordinates.</param>
        public Transformations(CartesianCoordinate localOriginInGlobal, CartesianCoordinate localAxisXPtInGlobal)
        {
            LocalOrigin = localOriginInGlobal;
            LocalAxisX  = localAxisXPtInGlobal;

            Displacement = localOriginInGlobal.OffsetFrom(CartesianCoordinate.Origin());
            if (localAxisXPtInGlobal.Y == localOriginInGlobal.Y)
            {
                Rotation = new AngularOffset();
            }
            else
            {
                Rotation = AngularOffset.CreateFromPoints(
                    localAxisXPtInGlobal,
                    localOriginInGlobal,
                    new CartesianCoordinate(localOriginInGlobal.X - 1, localOriginInGlobal.Y)
                    );
            }
        }