コード例 #1
0
        public Triangulator(List <Point> polyLine, float sheer)
        {
            _sheer          = sheer;
            Triangles       = new List <List <Point> >();
            Trapezoids      = new List <Trapezoid>();
            _xMonoPoly      = new List <MonotoneMountain>();
            _edgeList       = InitEdges(polyLine);
            _trapezoidalMap = new TrapezoidalMap();
            _boundingBox    = _trapezoidalMap.BoundingBox(_edgeList);
            _queryGraph     = new QueryGraph(Sink.Isink(_boundingBox));

            Process();
        }
コード例 #2
0
 // Update neighbors to the right
 public void UpdateRight(Trapezoid ur, Trapezoid lr)
 {
     UpperRight = ur;
     if (ur != null)
     {
         ur.UpperLeft = this;
     }
     LowerRight = lr;
     if (lr != null)
     {
         lr.LowerLeft = this;
     }
 }
コード例 #3
0
 // Update neighbors to the left
 public void UpdateLeft(Trapezoid ul, Trapezoid ll)
 {
     UpperLeft = ul;
     if (ul != null)
     {
         ul.UpperRight = this;
     }
     LowerLeft = ll;
     if (ll != null)
     {
         ll.LowerRight = this;
     }
 }
コード例 #4
0
 public Trapezoid(Point leftPoint, Point rightPoint, Edge top, Edge bottom)
 {
     LeftPoint  = leftPoint;
     RightPoint = rightPoint;
     Top        = top;
     Bottom     = bottom;
     UpperLeft  = null;
     UpperRight = null;
     LowerLeft  = null;
     LowerRight = null;
     Inside     = true;
     Sink       = null;
 }
コード例 #5
0
        // Case 1: segment completely enclosed by trapezoid
        //         break trapezoid into 4 smaller trapezoids
        public Trapezoid[] Case1(Trapezoid t, Edge e)
        {
            Trapezoid[] trapezoids = new Trapezoid[4];
            trapezoids[0] = new Trapezoid(t.LeftPoint, e.P, t.Top, t.Bottom);
            trapezoids[1] = new Trapezoid(e.P, e.Q, t.Top, e);
            trapezoids[2] = new Trapezoid(e.P, e.Q, e, t.Bottom);
            trapezoids[3] = new Trapezoid(e.Q, t.RightPoint, t.Top, t.Bottom);

            trapezoids[0].UpdateLeft(t.UpperLeft, t.LowerLeft);
            trapezoids[1].UpdateLeftRight(trapezoids[0], null, trapezoids[3], null);
            trapezoids[2].UpdateLeftRight(null, trapezoids[0], null, trapezoids[3]);
            trapezoids[3].UpdateRight(t.UpperRight, t.LowerRight);

            return(trapezoids);
        }
コード例 #6
0
        // Case 4: Trapezoid contains point q, p lies outside
        //         break trapezoid into 3 smaller trapezoids
        public Trapezoid[] Case4(Trapezoid t, Edge e)
        {
            Point lp;

            if (e.P.X == t.LeftPoint.X)
            {
                lp = e.P;
            }
            else
            {
                lp = t.LeftPoint;
            }

            Trapezoid[] trapezoids = new Trapezoid[3];

            if (_cross == t.Top)
            {
                trapezoids[0]            = t.UpperLeft;
                trapezoids[0].RightPoint = e.Q;
            }
            else
            {
                trapezoids[0] = new Trapezoid(lp, e.Q, t.Top, e);
                trapezoids[0].UpdateLeft(t.UpperLeft, e.Above);
            }

            if (_bCross == t.Bottom)
            {
                trapezoids[1]            = t.LowerLeft;
                trapezoids[1].RightPoint = e.Q;
            }
            else
            {
                trapezoids[1] = new Trapezoid(lp, e.Q, e, t.Bottom);
                trapezoids[1].UpdateLeft(e.Below, t.LowerLeft);
            }

            trapezoids[2] = new Trapezoid(e.Q, t.RightPoint, t.Top, t.Bottom);
            trapezoids[2].UpdateLeftRight(trapezoids[0], trapezoids[1], t.UpperRight, t.LowerRight);

            return(trapezoids);
        }
コード例 #7
0
ファイル: Edge.cs プロジェクト: GolfNorth/VelcroPhysicsUnity
        public Edge(Point p, Point q)
        {
            P = p;
            Q = q;

            if (q.X - p.X != 0)
            {
                Slope = (q.Y - p.Y) / (q.X - p.X);
            }
            else
            {
                Slope = 0;
            }

            B       = p.Y - p.X * Slope;
            Above   = null;
            Below   = null;
            MPoints = new HashSet <Point>();
            MPoints.Add(p);
            MPoints.Add(q);
        }
コード例 #8
0
 // Update neighbors on both sides
 public void UpdateLeftRight(Trapezoid ul, Trapezoid ll, Trapezoid ur, Trapezoid lr)
 {
     UpperLeft = ul;
     if (ul != null)
     {
         ul.UpperRight = this;
     }
     LowerLeft = ll;
     if (ll != null)
     {
         ll.LowerRight = this;
     }
     UpperRight = ur;
     if (ur != null)
     {
         ur.UpperLeft = this;
     }
     LowerRight = lr;
     if (lr != null)
     {
         lr.LowerLeft = this;
     }
 }