Example #1
0
 /// <summary>
 /// Give two points in any order. Will always be ordered so
 /// that q.y > p.y and q.x > p.x if same y value
 /// </summary>
 ///
 public DTSweepConstraint(TriangulationPoint p1, TriangulationPoint p2) // throws DuplicatePointException
 {
     p = p1;
     q = p2;
     if (p1.getY() > p2.getY())
     {
         q = p1;
         p = p2;
     }
     else if (p1.getY() == p2.getY())
     {
         if (p1.getX() > p2.getX())
         {
             q = p1;
             p = p2;
         }
         else if (p1.getX() == p2.getX())
         {
             logger.Info("Failed to create constraint {}={}", p1, p2);
             //                throw new DuplicatePointException( p1 + "=" + p2 );
             //                return;
         }
     }
     q.addEdge(this);
 }
Example #2
0
        /// <summary>
        /// angle
        /// </summary>
        ///
        /// <param name="node">middle node</param>
        /// <returns>the angle between p-a and p-b in range [-pi,pi]</returns>
        ///
        private static double angle(TriangulationPoint p,
                                    TriangulationPoint a,
                                    TriangulationPoint b)
        {
            // XXX: do we really need a signed angle for holeAngle?
            //      could possible save some cycles here

            /* Complex plane
             * ab = cosA +i*sinA
             * ab = (ax + ay*i)(bx + by*i) = (ax*bx + ay*by) + i(ax*by-ay*bx)
             * atan2(y,x) computes the principal value of the argument function
             * applied to the complex number x+iy
             * Where x = ax*bx + ay*by
             *       y = ax*by - ay*bx
             */
            double px = p.getX();
            double py = p.getY();
            double ax = a.getX() - px;
            double ay = a.getY() - py;
            double bx = b.getX() - px;
            double by = b.getY() - py;

            return(Math.Atan2(ax * by - ay * bx, ax * bx + ay * by));
        }