Ejemplo n.º 1
0
 /* ********************************************************************************* */
 public static void Create_Control_Point(
     PointX Prev, PointX CornerPnt, PointX Next, PointX CtrlPnt) {
   PointX before = new PointX(Prev), after = new PointX(Next);
   before.Subtract(CornerPnt);
   before.Normalize();
   after.Subtract(CornerPnt);
   after.Normalize();
   before.Add(after); // this now divides the angle between the two lines
   before.Normalize(); // this gives us normalized output
   // CtrlPnt.CopyFrom(before);
   double x0, y0, sin, cos;
   double d =
       (after.x * before.y)
           - (after.y * before.x); // winding order: d=(x-x1)*(y2-y1)-(y-y1)*(x2-x1)
   if (d > 0) {
     sin = Sin90; // 90 degrees
     cos = Cos90;
   } else {
     sin = Sin270; // 270 degrees
     cos = Cos270;
   }
   x0 = (before.x * cos) - (before.y * sin); // precalculated all to constants
   y0 = (before.y * cos) + (before.x * sin);
   CtrlPnt.Assign(x0, y0); // result is one point, 1 unit long, 'tangent' to the corner.
   /*
   position = sign((Bx - Ax) * (Y - Ay) - (By - Ay) * (X - Ax))// alternative: cross product
   */
 }