AddEdge() private method

private AddEdge ( Edge edge ) : void
edge Edge
return void
Esempio n. 1
0
        /**
         * This is the only way to create a new Edge
         * @param site0
         * @param site1
         * @return
         *
         */
        public static Edge CreateBisectingEdge(Site site0, Site site1)
        {
            float dx, dy, absdx, absdy;
            float a, b, c;

            dx    = site1.x - site0.x;
            dy    = site1.y - site0.y;
            absdx = dx > 0 ? dx : -dx;
            absdy = dy > 0 ? dy : -dy;
            c     = site0.x * dx + site0.y * dy + (dx * dx + dy * dy) * 0.5f;
            if (absdx > absdy)
            {
                a  = 1.0f;
                b  = dy / dx;
                c /= dx;
            }
            else
            {
                b  = 1.0f;
                a  = dx / dy;
                c /= dy;
            }

            Edge edge = Edge.Create();

            edge.leftSite  = site0;
            edge.rightSite = site1;
            site0.AddEdge(edge);
            site1.AddEdge(edge);

            edge._leftVertex  = null;
            edge._rightVertex = null;

            edge.a = a;
            edge.b = b;
            edge.c = c;
            //trace("createBisectingEdge: a ", edge.a, "b", edge.b, "c", edge.c);

            return(edge);
        }
Esempio n. 2
0
        /*
         * This is the only way to create a new Edge
         * @param site0
         * @param site1
         * @return
         */

        public static Edge CreateBisectingEdge(Site s0, Site s1)
        {
            float dx, dy;
            float absdx, absdy;
            float a, b, c;

            dx    = s1.x - s0.x;
            dy    = s1.y - s0.y;
            absdx = dx > 0 ? dx : -dx;
            absdy = dy > 0 ? dy : -dy;
            c     = s0.x * dx + s0.y * dy + (dx * dx + dy * dy) * 0.5f;

            if (absdx > absdy)
            {
                a  = 1;
                b  = dy / dx;
                c /= dx;
            }
            else
            {
                b  = 1;
                a  = dx / dy;
                c /= dy;
            }

            Edge edge = Edge.Create();

            edge.LeftSite  = s0;
            edge.RightSite = s1;
            s0.AddEdge(edge);
            s1.AddEdge(edge);

            edge.a = a;
            edge.b = b;
            edge.c = c;

            return(edge);
        }
		/**
			 * This is the only way to create a new Edge 
			 * @param site0
			 * @param site1
			 * @return 
			 * 
			 */
		public static Edge CreateBisectingEdge (Site site0, Site site1)
		{
			float dx, dy, absdx, absdy;
			float a, b, c;
			
			dx = site1.x - site0.x;
			dy = site1.y - site0.y;
			absdx = dx > 0 ? dx : -dx;
			absdy = dy > 0 ? dy : -dy;
			c = site0.x * dx + site0.y * dy + (dx * dx + dy * dy) * 0.5f;
			if (absdx > absdy) {
				a = 1.0f;
				b = dy / dx;
				c /= dx;
			} else {
				b = 1.0f;
				a = dx / dy;
				c /= dy;
			}
				
			Edge edge = Edge.Create ();
			
			edge.leftSite = site0;
			edge.rightSite = site1;
			site0.AddEdge (edge);
			site1.AddEdge (edge);
				
			edge._leftVertex = null;
			edge._rightVertex = null;
				
			edge.a = a;
			edge.b = b;
			edge.c = c;
			//trace("createBisectingEdge: a ", edge.a, "b", edge.b, "c", edge.c);
				
			return edge;
		}
        public static Edge CreateBisectingEdge(Site site0, Site site1)
        {
            Vector2 coord  = site1.Coord;
            Vector2 coord2 = site0.Coord;
            float   num    = coord2.x - coord.x;
            float   num2   = coord2.y - coord.y;
            float   num3   = (!(num > 0f)) ? (0f - num) : num;
            float   num4   = (!(num2 > 0f)) ? (0f - num2) : num2;
            float   num5   = coord.x * num + coord.y * num2 + (num * num + num2 * num2) * 0.5f;
            float   num6;
            float   num7;

            if (num3 > num4)
            {
                num6  = 1f;
                num7  = num2 / num;
                num5 /= num;
            }
            else
            {
                num7  = 1f;
                num6  = num / num2;
                num5 /= num2;
            }
            Edge edge = Create();

            edge.leftSite  = site0;
            edge.rightSite = site1;
            site0.AddEdge(edge);
            site1.AddEdge(edge);
            edge._leftVertex  = null;
            edge._rightVertex = null;
            edge.a            = num6;
            edge.b            = num7;
            edge.c            = num5;
            return(edge);
        }