Example #1
0
        /// <summary>
        /// May very well be our delta-point of interest.
        /// </summary>
        /// <remarks>
        /// This method is called by <see cref="Cubic.CubicTangent(Vertex,int)"/>
        /// </remarks>
        /// <param name="Cubed"></param>
        /// <param name="Derivitive"></param>
        /// <returns>
        /// NULL if Cubed and Derivitive Points are equal.
        /// </returns>
        public static LineObj GetLine(Point Cubed, Point Derivitive)
        {
            if (Cubed.X.Equals(Derivitive.X) && Cubed.Y.Equals(Derivitive.Y))
            return null;

              if (Cubed.X.Equals(Derivitive.X)) return new LineObj { c = Cubed.X };
              else
              {
            var p = Cubed - Derivitive;
            var d = p.Y / p.X;
            return new LineObj { a = d, b = Cubed.Y - (d * Cubed.X) };
              }
        }
 public static Point GetPointOnSegment(this Point P0, Point P1, double ratio)
 {
     return P0 + (P1-P0 * ratio.n());
     //turn P0.add(pExt.mult(P1.subtract(P0),pExt.n(ratio)));
 }
 public static double To(this Point a, Point b)
 {
     Point diff = a - b;
       return Math.Pow(a.X-b.X, 2)+Math.Pow(a.Y-b.Y, 2);
 }
 public static Point GetMiddle(this Point P0, Point P1)
 {
     return (P0+P1) / 2;
 }