Exemple #1
0
        /// <summary>
        /// Rotates a point around a reference point by the provide angle in radians
        /// </summary>
        /// <param name="point">The point to rotate</param>
        /// <param name="referencePoint">The reference point to rotate about</param>
        /// <param name="angle">The angle to rotate it in radians</param>
        /// <returns>The rotated point</returns>
        public static IPoint Rotate(IPoint point, IPoint referencePoint, double angle)
        {
            var sine   = Math.Sin(angle);
            var cosine = Math.Cos(angle);

            var pointOut = new LucidPoint(point.X - referencePoint.X, point.Y - referencePoint.Y);

            var newX = pointOut.X * cosine - pointOut.Y * sine;
            var newY = pointOut.X * sine + pointOut.Y * cosine;

            pointOut.X = newX + referencePoint.X;
            pointOut.Y = newY + referencePoint.Y;

            return(pointOut);
        }
Exemple #2
0
        public static ILucidGeometry Create(string geometryJson)
        {
            if (geometryJson.Contains("\"x\""))
            {
                return(LucidPoint.Create(geometryJson));
            }
            if (geometryJson.Contains("\"xmax\""))
            {
                return(LucidExtent.Create(geometryJson));
            }
            if (geometryJson.Contains("\"paths\""))
            {
                return(LucidLine.Create(geometryJson));
            }
            if (geometryJson.Contains("\"rings\""))
            {
                return(LucidPolygon.Create(geometryJson));
            }

            throw new Exception($"Unrecognized geometry type {geometryJson}");
        }
Exemple #3
0
 /// <summary>
 /// Determines the angle in radians of a targetPoint vector with the origin being (0,0).
 /// </summary>
 /// <param name="targetPoint">The point to find the angle of.</param>
 /// <returns>The angle of the target point about (0,0)</returns>
 public static double Angle(IPoint targetPoint)
 {
     return(Angle(LucidPoint.Create(0, 0), targetPoint));
 }