示例#1
0
    // Start is called before the first frame update
    void Start()
    {
        //Model cube = new Model(Model.default_primitives.Cube);

        //CreateUnityGameObject(cube);

        Model k = new Model(Model.letter.K);

        CreateUnityGameObject(k);

        Outcode a = new Outcode(new Vector2(2f, -2f));

        print(a.ToString());

        Vector2 start = new Vector2(2, 2), end = new Vector2(-3, 0);

        if (line_clip(ref start, ref end))
        {
            draw(start, end);                                //if true, rasterize
        }
        Vector2 test1        = new Vector2(1, 1);
        Vector2 test2        = new Vector2(3, 1);
        bool    boolLineclip = line_clip(ref test1, ref test2);

        print(boolLineclip);

        // Vector2 testVec = new Vector2(2, 2);
        // Vector2Int newVec = convertToInts(testVec);
    }
示例#2
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((Outcode != null ? Outcode.GetHashCode() : 0) * 397) ^ (Incode != null ? Incode.GetHashCode() : 0));
     }
 }
示例#3
0
 public Outcode(Outcode outcode_to_clone)
 {
     up    = outcode_to_clone.up;
     down  = outcode_to_clone.down;
     left  = outcode_to_clone.left;
     right = outcode_to_clone.right;
 }
示例#4
0
    private static Vector3 Clipping(Vector3 v, float m)
    {
        Outcode ov = new Outcode(v);
        float   X = v.x, Y = v.y;

        if (ov.Left)
        {
            Y = lineIntersectY(-1, v, m);
            X = -1;
        }
        else if (ov.Right)
        {
            Y = lineIntersectY(1, v, m);
            X = 1;
        }
        else if (ov.Up)
        {
            X = lineIntersectX(1, v, m);
            Y = 1;
        }
        else if (ov.Down)
        {
            X = lineIntersectX(-1, v, m);
            Y = -1;
        }

        v.x = X;
        v.y = Y;

        return(v);
    }
    public static bool LineClip(ref Vector2 v, ref Vector2 u)
    {
        Outcode inViewPort = new Outcode();
        Outcode vO         = new Outcode(v);
        Outcode uO         = new Outcode(u);

        //Detect Trivial Acceptance
        if ((vO + uO) == inViewPort)
        {
            return(true);
        }

        //Detect Trivial Rejection
        if ((vO + uO) != inViewPort)
        {
            return(false);
        }

        //If vO is in the viewport, invert the points and check again.
        if (vO == inViewPort)
        {
            return(LineClip(ref u, ref v));
        }

        Vector2 v1;

        if (vO.up)
        {
            v1 = v;

            v1 = Intercept(u, v, 0);
            return(false);
        }
        if (vO.down)
        {
            v1 = v;

            v1 = Intercept(u, v, 1);
            return(false);
        }
        if (vO.left)
        {
            v1 = v;

            v1 = Intercept(u, v, 2);
            return(false);
        }
        if (vO.right)
        {
            v1 = v;
            v1 = Intercept(u, v, 3);
            return(false);
        }

        v1 = v;

        v1 = Intercept(u, v, 3);
        return(false);
    }
示例#6
0
    public static Outcode operator |(Outcode left, Outcode right)
    {
        Outcode ans = new Outcode();

        ans.above = left.above || right.above;
        ans.below = left.below || right.below;
        ans.left  = left.left || right.left;
        ans.right = left.right || right.right;

        return(ans);
    }
示例#7
0
    public static Outcode operator&(Outcode oc1, Outcode oc2)
    {
        Outcode tmp = new Outcode();

        tmp.Up    = oc1.Up && oc2.Up;
        tmp.Down  = oc1.Down && oc2.Down;
        tmp.Left  = oc1.Left && oc2.Left;
        tmp.Right = oc1.Right && oc2.Right;

        return(tmp);
    }
示例#8
0
    public static bool trivialAcceptance(Outcode left, Outcode right)
    {
        Outcode zero = new Outcode();

        if ((left == zero) && (right == zero))
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
示例#9
0
    public static bool trivialRejection(Outcode left, Outcode right)
    {
        Outcode zero = new Outcode();

        if ((left & right) != zero)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
示例#10
0
    /// <summary>
    /// Checks if line is clipped
    /// </summary>
    /// <param name="v">1st point of line passed in</param>
    /// <param name="u">2nd point of line passed in</param>
    /// <returns>Returns true if the line is not clipped</returns>
    public static bool lineClip(ref Vector2 v, ref Vector2 u)
    {
        Outcode v0         = new Outcode(v);
        Outcode u0         = new Outcode(u);
        Outcode inViewPort = new Outcode();

        //Trivially Accept
        if ((v0 + u0) == inViewPort)
        {
            return(true);
        }

        //Trivially Reject
        if (v0 * u0 != inViewPort)
        {
            return(false);
        }

        // If niether trivially rejected or triavally accepted, checks if the first point of the line is in the viewport
        if (v0 == inViewPort)
        {
            /*Calls method again but with points enterd in reverse.
             * Will not be trivially accepted or rejected and will reach this point again and checks if the
             * second point is in the viewport or not (It wont be as it wasnt trivially rejected, so it continues with the method) */
            return(lineClip(ref u, ref v));
        }

        if (v0.up)
        {
            v = intercept(u, v, 0);

            return(true);
        }

        if (v0.down)
        {
            v = intercept(u, v, 1);

            return(true);
        }

        if (v0.left)
        {
            v = intercept(u, v, 2);

            return(true);
        }

        v = intercept(u, v, 3);
        return(true);
    }
    public static bool lineClip(ref Vector2 v1, ref Vector2 u2)
    {
        Outcode outcodeV = new Outcode();
        Outcode outcodeU = new Outcode();

        outcodeV = new Outcode(v1);
        outcodeU = new Outcode(u2);
        Outcode inViewPort = new Outcode();

        //Acceptance test
        if ((outcodeV + outcodeU) == inViewPort)
        {
            return(true);
        }

        //rejection test
        else if (outcodeV * outcodeU != inViewPort)
        {
            return(false);
        }

        //If its not accepted or rejected checks if the point is in the viewPort.
        else if (outcodeV == inViewPort)
        {
            return(lineClip(ref u2, ref v1));
        }

        else if (outcodeV.up)
        {
            v1 = intercept(u2, v1, 0);

            return(false);
        }

        else if (outcodeV.down)
        {
            v1 = intercept(u2, v1, 1);

            return(false);
        }

        else if (outcodeV.left)
        {
            v1 = intercept(u2, v1, 2);

            return(false);
        }

        v1 = intercept(u2, v1, 3);
        return(false);
    }
示例#12
0
    //Contains code required for and related to line clipping
    #region Line Clipping

    private bool line_clip(ref Vector2 start, ref Vector2 end)
    {
        Outcode startOutcode = new Outcode(start), endOutcode = new Outcode(end), inViewportOutcode = new Outcode();

        if ((startOutcode == inViewportOutcode) && (endOutcode == inViewportOutcode))
        {
            //print("Trivial Acceptance");
            return(true);
        }

        if ((startOutcode * endOutcode) != inViewportOutcode)
        {
            //print("Trivial Rejection");
            return(false);
        }

        //If not trivial accept,
        if (startOutcode == inViewportOutcode)
        {
            return(line_clip(ref end, ref start));
        }

        if (startOutcode.up)
        {
            start = intercept(start, end, 0);
            return(line_clip(ref start, ref end));
        }

        if (startOutcode.down)
        {
            start = intercept(start, end, 1);
            return(line_clip(ref start, ref end));
        }

        if (startOutcode.left)
        {
            start = intercept(start, end, 2);
            return(line_clip(ref start, ref end));
        }

        if (startOutcode.right)
        {
            start = intercept(start, end, 3);
            return(line_clip(ref start, ref end));
        }

        //Reversed to clip end using the same code
        line_clip(ref end, ref start);

        return(false);
    }
示例#13
0
 public static bool checkOutcodeEquals(Outcode left, Outcode right)
 {
     if (left.above == right.above &&
         left.below == right.below &&
         left.left == right.left &&
         left.right == right.right)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
    public static bool lineClip(ref Vector2 v, ref Vector2 u)
    {
        Outcode inViewPort = new Outcode();
        Outcode vO         = new Outcode(v);
        Outcode uO         = new Outcode(u);

        //detect trivial acceptance
        if ((vO + uO) == inViewPort)
        {
            return(true);
        }

        //detect trivial rejection
        if ((vO * uO) != inViewPort)
        {
            return(false);
        }

        /*check vO is in. If not, flip the u and the v around and check method again.
         * When this gets hit again, it is now checking u instead of v beacause they flipped.
         * This is only hit if one point is inViewPort and the other isnt. (wasnt TA or TR).
         */
        if (vO == inViewPort)
        {
            return(lineClip(ref u, ref v));
        }

        //only called if one point in viewport
        //No need for uO methods, as the point will be flipped to vO in previous methods.
        Vector2 v2 = v;     //defined here so i dont have to keep defining it

        if (vO.up)
        {
            v = intercept(u, v, 0);
            return(true);
        }
        if (vO.down)
        {
            v = intercept(u, v, 1);
            return(true);
        }
        if (vO.left)
        {
            v = intercept(u, v, 2);
            return(true);
        }
        v = intercept(u, v, 3);
        return(true);
    }
        public void GetResturantsByDeliveryArea_SuppliedValidOutcode_ReturnsSuccessfulResturantResult()
        {
            // Arrange
            var outcode = new Outcode
            {
                Value = "BS7"
            };
            var restaurantService = new HttpRestaurantService();

            // Act
            var result = restaurantService.GetResturantsByDeliveryArea(outcode);

            // Assert
            Assert.IsTrue(result.Successful);
        }
示例#16
0
    private bool Line_clip(ref Vector2 start, ref Vector2 end)
    {
        Outcode startOutcode = new Outcode(start), endOutcode = new Outcode(end), inViewPortOutcode = new Outcode();

        if ((startOutcode == inViewPortOutcode) && (endOutcode == inViewPortOutcode))
        {
            //print("Trivial Acceptance"); //Draw the whole line
            return(true);
        }

        if ((startOutcode * endOutcode) != inViewPortOutcode)
        {
            //print("Trivial Reject"); //Line fully out of the screen (outcode has to have a common 1)
            return(false);
        }

        if (startOutcode == inViewPortOutcode)
        {
            return(Line_clip(ref end, ref start));
        }

        if (startOutcode.up)
        {
            start = intercept(start, end, 0);

            return(Line_clip(ref start, ref end));
        }

        if (startOutcode.down)
        {
            start = intercept(start, end, 1);
            return(Line_clip(ref start, ref end));
        }

        if (startOutcode.left)
        {
            start = intercept(start, end, 2);
            return(Line_clip(ref start, ref end));
        }

        if (startOutcode.right)
        {
            start = intercept(start, end, 3);
            return(Line_clip(ref start, ref end));
        }

        return(Line_clip(ref end, ref start));
    }
示例#17
0
    private bool line_clip(ref Vector2 start, ref Vector2 end) //Testing of acceptance, each rejection and various others
    {
        Outcode startOutcode = new Outcode(start), endOutcode = new Outcode(end), inViewPortOutcode = new Outcode();

        //Both points inside viewport
        if ((startOutcode == inViewPortOutcode) && (endOutcode == inViewPortOutcode))
        {
            print("Trivial Acceptance");
            return(true);
        }
        //Not in viewport
        if ((startOutcode * endOutcode) != inViewPortOutcode)
        {
            print("Trivial reject");
            return(false);
        }

        if (startOutcode == inViewPortOutcode)
        {
            return(line_clip(ref end, ref start));
        }

        if (startOutcode.up)
        {
            start = intercept(start, end, 0);
            return(line_clip(ref start, ref end));
        }
        if (startOutcode.down)
        {
            start = intercept(start, end, 1);
            return(line_clip(ref start, ref end));
        }
        if (startOutcode.left)
        {
            start = intercept(start, end, 2);
            return(line_clip(ref start, ref end));
        }
        if (startOutcode.right)
        {
            start = intercept(start, end, 3);
            return(line_clip(ref start, ref end));
        }

        //Return if start doesnt clip to valid point. Clip end only if start clips to valid point.
        return(line_clip(ref end, ref start));
    }
示例#18
0
    //line clipping

    public bool ClipLine(ref Vector2 lineStart, ref Vector2 lineEnd)
    {
        Outcode startOutcode = new Outcode(lineStart);
        Outcode endOutcode   = new Outcode(lineEnd);


        //Trivial Acceptance
        if (Outcode.trivialAcceptance(startOutcode, endOutcode))
        {
            print("Trivially Accepted");
            return(true);
        }
        //Trivial rejection
        if (Outcode.trivialRejection(startOutcode, endOutcode))
        {
            print("Trivially Rejected");
            return(false);
        }

        //work to be done

        if (startOutcode.above)
        {
            lineStart = interceptOfLine(0, lineStart, lineEnd);
            return(ClipLine(ref lineStart, ref lineEnd));
        }
        if (startOutcode.below)
        {
            lineStart = interceptOfLine(1, lineStart, lineEnd);
            return(ClipLine(ref lineStart, ref lineEnd));
        }

        if (startOutcode.left)
        {
            lineStart = interceptOfLine(2, lineStart, lineEnd);
            return(ClipLine(ref lineStart, ref lineEnd));
        }
        if (startOutcode.below)
        {
            lineStart = interceptOfLine(3, lineStart, lineEnd);
            return(ClipLine(ref lineStart, ref lineEnd));
        }

        return(ClipLine(ref lineStart, ref lineEnd));
    }
示例#19
0
    public static bool lineClip(ref Vector2 v, ref Vector2 u)
    {
        Outcode inViewPort = new Outcode();
        Outcode vO         = new Outcode(v);
        Outcode uO         = new Outcode(u);

        //detect trivial acceptance
        if ((vO + uO) == inViewPort)
        {
            return(true);
        }

        //detect trivial rejection
        if ((vO * uO) != inViewPort)
        {
            return(false);
        }

        if (vO == inViewPort)
        {
            return(lineClip(ref u, ref v));
        }

        Vector2 v2 = v;

        if (vO.up)
        {
            v = intercept(u, v, 0);
            return(false);
        }
        if (vO.down)
        {
            v = intercept(u, v, 1);
            return(false);
        }
        if (vO.left)
        {
            v = intercept(u, v, 2);
            return(false);
        }
        v = intercept(u, v, 3);
        return(false);
    }
示例#20
0
    public bool Line_Clip(ref Vector2 start, ref Vector2 end)
    {
        Outcode startOutcode = new Outcode(start);
        Outcode endOutcode   = new Outcode(end);

        if (startOutcode == new Outcode() && endOutcode == new Outcode())
        {
            print("Trivially Accept");
            return(true);
        }
        if ((startOutcode & endOutcode) != new Outcode())
        {
            print("Trivially Reject");
            return(false);
        }

        start = Line_Intercept(start, end, startOutcode.getEdges());
        end   = Line_Intercept(end, start, endOutcode.getEdges());

        return(true);
    }
    void Start()
    {
        Vector2 point1 = new Vector2(.5f, 2f);
        Vector2 point2 = new Vector2(.3f, .1f);

        Outcode a = new Outcode(point1);
        Outcode b = new Outcode(point2);

        // all false
        Outcode inViewPort = new Outcode();

        if ((a == inViewPort) && (b == inViewPort))
        {
            Debug.Log("Trivially Accept");
        }

        if (a * b != inViewPort)
        {
            Debug.Log("Trivially Rejected");
        }

        if ((a + b) == inViewPort)
        {
            Debug.Log("Trivially Accept");
        }

        if (!lineClip(ref point1, ref point2))
        {
            Debug.Log(point1.x + "  ,  " + point1.y);
            Debug.Log(point2.x + "  ,  " + point2.y);
        }


        Vector2        pixelPoint1 = new Vector2(12, 15);
        Vector2        pixelPoint2 = new Vector2(2, 10);
        List <Vector2> list        = breshenham(pixelPoint1, pixelPoint2);

        //foreach(Vector2 v in list)
        //    Debug.Log(v.x + "  ,  " + v.y);
    }
    void Start()
    {
        Outcode a = new Outcode(new Vector2(3, 0.4f));

        Outcode b          = new Outcode(new Vector2(0.4f, 0.7f));
        Outcode inViewPort = new Outcode();

        if ((a == inViewPort) && (b == inViewPort))
        {
            Debug.Log("Trivially Accept");
        }

        if (a * b != inViewPort)
        {
            Debug.Log("Trivially Rejected");
        }

        if ((a + b) == inViewPort)
        {
            Debug.Log("Trivially Accept");
        }
    }
示例#23
0
    public static bool WorkToDO(ref Vector3 v0, ref Vector3 v1)
    {
        float m = (v1.y - v0.y) / (v1.x - v0.x);

        float X = v0.x, Y = v1.y;

        v0 = Clipping(v0, m);
        v1 = Clipping(v1, m);

        Outcode ov0 = new Outcode(v0);
        Outcode ov1 = new Outcode(v1);

        if (TrivialAcceptance(ov0, ov1))
        {
            print("Work to Do : true, on the Screen");
            return(true);
        }
        else
        {
            print("Work to Do : false, not on the Screen");
            return(false);
        }
    }
示例#24
0
 public static bool getEdge(int e, Outcode code)
 {
     if (e == 0)
     {
         return(code.above);
     }
     else if (e == 1)
     {
         return(code.below);
     }
     else if (e == 2)
     {
         return(code.left);
     }
     else if (e == 3)
     {
         return(code.right);
     }
     else
     {
         return(false);
     }
 }
示例#25
0
    public static bool Line_Clipping(ref Vector3 v0, ref Vector3 v1)
    {
        Outcode ov0 = new Outcode(v0);
        Outcode ov1 = new Outcode(v1);

        print("Vectors : " + v0 + " / " + v1);

        if (TrivialAcceptance(ov0, ov1))
        {
            print("Trivial Acceptance !");
            return(true);
        }
        else if (TrivialRejection(ov0, ov1))
        {
            print("Trivial Rejection !");
            return(false);
        }
        else
        {
            print(WorkToDO(ref v0, ref v1));
            print("Vectors : " + v0 + " / " + v1);
        }
        return(false);
    }
示例#26
0
    // Start is called before the first frame update
    void Start()
    {
        //Create texture on which to draw line -- size can vary, should be square for cube sake
        Texture2D  tex  = new Texture2D(256, 256);
        GameObject cube = GetComponent <GameObject>();

        GetComponent <Renderer>().material.mainTexture = tex;

        //Starting points
        Vector2 point1 = new Vector2(.5f, 2f);
        Vector2 point2 = new Vector2(.3f, .1f);

        //Apply outcodes and clip line
        Outcode a = new Outcode(point1);
        Outcode b = new Outcode(point2);

        // All are false
        Outcode inViewPort = new Outcode();

        if ((a == inViewPort) && (b == inViewPort))
        {
            Debug.Log("Trivially Accept");
        }

        if (a * b != inViewPort)
        {
            Debug.Log("Trivially Rejected");
        }

        if ((a + b) == inViewPort)
        {
            Debug.Log("Trivially Accept");
        }

        if (!LineClip(ref point1, ref point2))
        {
            Debug.Log(point1.x + "  ,  " + point1.y);
            Debug.Log(point2.x + "  ,  " + point2.y);
        }

        //Create start of line and end of line
        Vector2Int pixelPoint1 = new Vector2Int(17, 28);
        Vector2Int pixelPoint2 = new Vector2Int(-1, 3);

        //Pass start and end point through Breshenham's algorithm to create all other points between start and end point
        List <Vector2Int> list = Breshenham(pixelPoint1, pixelPoint2);

        //Print all points to console
        foreach (Vector2 v in list)
        {
            Debug.Log(v.x + "  ,  " + v.y);
        }

        //Apply points as pixels to the texture
        for (int i = 0; i < list.Count; i++)
        {
            int   drawX = (int)list[i].x;
            int   drawY = (int)list[i].y;
            Color color = Color.red;
            tex.SetPixel(drawX, drawY, color);
        }

        //Apply the texture to the cube
        tex.Apply();
    }
    // Start is called before the first frame update
    void Start()
    {
        cube[0] = new Vector3(1, 1, 1);
        cube[1] = new Vector3(-1, 1, 1);
        cube[2] = new Vector3(-1, -1, 1);
        cube[3] = new Vector3(1, -1, 1);

        cube[4] = new Vector3(1, 1, -1);
        cube[5] = new Vector3(-1, 1, -1);
        cube[6] = new Vector3(-1, -1, -1);
        cube[7] = new Vector3(1, -1, -1);

        Vector2Int p1 = new Vector2Int(2, -2);
        Vector2Int p2 = new Vector2Int(-2, 2);

        Breshanham(p1, p2);

        //acceptance test
        Outcode outcodeA = new Outcode(pointA);

        print("pointA: (1,1)");
        outcodeA.printOutcode();

        Outcode outcodeB = new Outcode(pointB);

        print("pointB: (2,1)");
        outcodeB.printOutcode();

        Outcode outcodeC = new Outcode(pointC);

        print("pointC: (1,-2)");
        outcodeC.printOutcode();

        Outcode outcodeD = new Outcode(pointD);

        print("pointD: (-2,-2)");
        outcodeD.printOutcode();

        Outcode inViewPort = new Outcode();

        if ((outcodeA + outcodeB) == inViewPort)
        {
            print("Trival Accepted");
        }
        else if ((outcodeA * outcodeB) == inViewPort)
        {
            print("Trival Rejected");
        }

        if (!lineClip(ref point1, ref point2))
        {
            print(point1.x + " , " + point1.y);
            print(point2.x + " , " + point2.y);
        }



        //     print("[1.] 2 lines: (5,15) and (1,-7))");
        Vector2Int        pixelPoint1 = new Vector2Int(5, 15);
        Vector2Int        pixelPoint2 = new Vector2Int(1, -7);
        List <Vector2Int> list        = Breshanham(pixelPoint1, pixelPoint2);

        //foreach(Vector2Int v in list)
        //{
        //    print(v.x + " , " + v.y);
        //}

        //print("[2.] 2 lines: (5,15) and (1,-7))");
        Vector2Int        pixelPoint3 = new Vector2Int(25, -20);
        Vector2Int        pixelPoint4 = new Vector2Int(0, 15);
        List <Vector2Int> list2       = Breshanham(pixelPoint3, pixelPoint4);

        //foreach (Vector2Int v in list2)
        //{
        //    print(v.x + " , " + v.y);
        //    if (gameObject.tag == "Cube1")
        //    {
        //       //transform.Rotate(new Vector2(v.x, v.y) * Time.deltaTime);
        //    }

        //}

        //Perspective/Projection Matrix
        projectionMatrix = Matrix4x4.Perspective(45, 1.6f, 1, 800);

        //Scale Matrix
        scaleMatrixCall(scaleNumber);



        //texturing
    }
示例#28
0
 public static bool TrivialRejection(Outcode oc1, Outcode oc2)
 {
     return(!((oc1 & oc2).IsZero()));
 }
示例#29
0
 public static bool TrivialAcceptance(Outcode oc1, Outcode oc2)
 {
     return(oc1.IsZero() && oc2.IsZero());
 }
示例#30
0
    public static bool lineClip(ref Vector2 v, ref Vector2 u)
    {
        Outcode v_outcode  = new Outcode(v);
        Outcode u_outcode  = new Outcode(u);
        Outcode inViewport = new Outcode();

        if ((u_outcode + v_outcode) == inViewport)
        {
            return(true);
        }

        if ((u_outcode * v_outcode) != inViewport)
        {
            print("TR");
            return(false);
        }

        if (v_outcode == inViewport)
        {
            return(lineClip(ref u, ref v));
        }

        if (v_outcode.up)
        {
            v = intercept(u, v, 0);

            Outcode v2_outcode = new Outcode(v);

            if (v2_outcode == inViewport)
            {
                return(lineClip(ref u, ref v));
            }
        }

        if (v_outcode.down)
        {
            v = intercept(u, v, 1);

            Outcode v2_outcode = new Outcode(v);

            if (v2_outcode == inViewport)
            {
                return(lineClip(ref u, ref v));
            }
        }

        if (v_outcode.left)
        {
            v = intercept(u, v, 2);

            Outcode v2_outcode = new Outcode(v);

            if (v2_outcode == inViewport)
            {
                return(lineClip(ref u, ref v));
            }
        }

        if (v_outcode.right)
        {
            v = intercept(u, v, 3);

            Outcode v2_outcode = new Outcode(v);

            if (v2_outcode == inViewport)
            {
                return(lineClip(ref u, ref v));
            }
        }

        return(false);
    }
示例#31
0
        public static bool lineClip(ref Vector2 v, ref Vector2 u)
        {
            Outcode outcodeV   = new Outcode(v);
            Outcode outcodeU   = new Outcode(u);
            Outcode inViewPort = new Outcode();

            if ((outcodeV + outcodeU) == inViewPort)
            {
                return(true);
            }
            if ((outcodeV * outcodeU) != inViewPort)
            {
                return(false);
            }

            if (outcodeV == inViewPort)
            {
                return(lineClip(ref u, ref v));
            }



            if (outcodeV.up)  // Above viewport
            {
                Vector2 newV = intercept(v, u, 0);

                Outcode newVOutcode = new Outcode(newV);
                if (newVOutcode == inViewPort)
                {
                    v = newV;
                    return(lineClip(ref u, ref v));
                }
            }

            if (outcodeV.down)  // Below viewport
            {
                Vector2 newV = intercept(v, u, 1);

                Outcode newVOutcode = new Outcode(newV);
                if (newVOutcode == inViewPort)
                {
                    v = newV;
                    return(lineClip(ref u, ref v));
                }
            }

            if (outcodeV.left)  // Left of viewport
            {
                Vector2 newV = intercept(v, u, 2);

                Outcode newVOutcode = new Outcode(newV);
                if (newVOutcode == inViewPort)
                {
                    v = newV;
                    return(lineClip(ref u, ref v));
                }
            }

            if (outcodeV.right)  // Right of viewport
            {
                Vector2 newV = intercept(v, u, 3);

                Outcode newVOutcode = new Outcode(newV);
                if (newVOutcode == inViewPort)
                {
                    v = newV;
                    return(lineClip(ref u, ref v));
                }
            }

            return(false);
        }