Esempio n. 1
0
def exer2_1():
    """
    Plot a rational Bezier curve converting the control vertexes
    in polinomial and using the same algorithms of the polinomial.
    Test with two different weight sets.
    """
    V = np.array([[0,0],[1,2],[3,1]])
    W1 = np.array([1,1,1])
    W2 = np.array([1,2,1])

    fn.drawVertexes(V)
    fn.drawVertexes(V,'o')
    P1 = fn.bezierRational(V,W1)[0]
    P2 = fn.bezierRational(V,W2)[0]
    fn.drawVertexes(P1)
    fn.drawVertexes(P2)
Esempio n. 2
0
def exer2_3():
    """
    Represents the first quadrant of a circumference using
    the rational Bezier curves with control vertexes:
    (1,0), (1,1), (0,1)
    and weights:
    1, sqrt(2)/2, 1.
    """
    V = np.array([[1,0],[1,1],[0,1]])
    W = np.array([1,math.sqrt(2)/2,1])

    fn.drawVertexes(V)
    fn.drawVertexes(V,'o')
    fn.drawVertexes(fn.bezierRational(V,W)[0])
Esempio n. 3
0
def exer2_4():
    """
    Given the control vertexes:
    (1,0), (a,a), (0,1)
    for different values of a find the weigths that
    represents an arc of circumference.
    """
    for a in [0.7, 1., 2., 3.]:
        V = np.array([[1,0],[a,a],[0,1]])
        W = np.array([1,fn.findArcWeigth(a),1])
        centre, radius = fn.findCircle(a)

        fn.drawVertexes(fn.circum(centre, radius))
        fn.drawVertexes(V)
        fn.drawVertexes(V,'o')
        fn.drawVertexes(fn.bezierRational(V,W)[0])
Esempio n. 4
0
def exer2_2():
    """
    Increase the grade of a rational Bezier curve converting the
    control vertexes in polinomial and using the same algorithms
    of the polinomial.
    """
    V = np.array([[0,0,0],[1,2,0],[3,2,3],[2,6,2]])
    W = np.array([1,1,1,1])
    V1,W1 = fn.increaseGradeRational(V, W)
    V2,W2 = fn.increaseGradeRational(V1, W1)
    V3,W3 = fn.increaseGradeRational(V2, W2)
    fn.drawVertexes(fn.bezierRational(V,W)[0])
    fn.drawVertexes(V)
    fn.drawVertexes(V,'o')
    fn.drawVertexes(V1)
    fn.drawVertexes(V1,'o')
    fn.drawVertexes(V2)
    fn.drawVertexes(V2,'o')
    fn.drawVertexes(V3)
    fn.drawVertexes(V3,'o')