Пример #1
0
    def calculateEndPerpendiculars(self, start, control0, control1, end):
        unitC00 = VectMath.unitvect(
            [control0[0] - start[0], control0[1] - start[1]])
        #unitControl00 = [self.startPos[0]+(10*unitC00[0]),self.startPos[1]+(10*unitC00[1])]
        perpUnitStartLeft = [
            start[0] + (10 * unitC00[1]), start[1] - (10 * unitC00[0])
        ]
        perpUnitStartRright = [
            start[0] - (10 * unitC00[1]), start[1] + (10 * unitC00[0])
        ]

        unitC01 = VectMath.unitvect(
            [control1[0] - end[0], control1[1] - end[1]])
        #unitControl01 = [self.endPos[0]+(10*unitC01[0]),self.endPos[1]+(10*unitC01[1])]
        perpUnitEndLeft = [
            end[0] - (10 * unitC01[1]), end[1] + (10 * unitC01[0])
        ]
        perpUnitEndRight = [
            end[0] + (10 * unitC01[1]), end[1] - (10 * unitC01[0])
        ]

        return [
            perpUnitStartLeft, perpUnitStartRright, perpUnitEndLeft,
            perpUnitEndRight
        ]
Пример #2
0
    def calculateUnitPerpendiculars(self,start,control0,control1,end):
        unitC00 = VectMath.unitvect([control0[0]-start[0],control0[1]-start[1]])
        perpUnitStartLeft = [0+unitC00[1],0-unitC00[0]]
        perpUnitStartRright = [0-unitC00[1],0+unitC00[0]]

        unitC01 = VectMath.unitvect([control1[0]-end[0],control1[1]-end[1]])
        perpUnitEndLeft = [0-unitC01[1],0+unitC01[0]]
        perpUnitEndRight = [0+unitC01[1],0-unitC01[0]]

        return [perpUnitStartLeft,perpUnitStartRright,perpUnitEndLeft,perpUnitEndRight]
Пример #3
0
def calculateEndPerpendiculars(start,control0,control1,end):
    unitC00 = VectMath.unitvect([control0[0]-start[0],control0[1]-start[1]])
    #unitControl00 = [self.startPos[0]+(10*unitC00[0]),self.startPos[1]+(10*unitC00[1])]
    perpUnitStartLeft = [start[0]+(10*unitC00[1]),start[1]-(10*unitC00[0])]
    perpUnitStartRright = [start[0]-(10*unitC00[1]),start[1]+(10*unitC00[0])]

    unitC01 = VectMath.unitvect([control1[0]-end[0],control1[1]-end[1]])
    #unitControl01 = [self.endPos[0]+(10*unitC01[0]),self.endPos[1]+(10*unitC01[1])]
    perpUnitEndLeft = [end[0]-(10*unitC01[1]),end[1]+(10*unitC01[0])]
    perpUnitEndRight = [end[0]+(10*unitC01[1]),end[1]-(10*unitC01[0])]

    return [perpUnitStartLeft,perpUnitStartRright,perpUnitEndLeft,perpUnitEndRight]
Пример #4
0
    def calculateUnitPerpendiculars(self, start, control0, control1, end):
        unitC00 = VectMath.unitvect(
            [control0[0] - start[0], control0[1] - start[1]])
        perpUnitStartLeft = [0 + unitC00[1], 0 - unitC00[0]]
        perpUnitStartRright = [0 - unitC00[1], 0 + unitC00[0]]

        unitC01 = VectMath.unitvect(
            [control1[0] - end[0], control1[1] - end[1]])
        perpUnitEndLeft = [0 - unitC01[1], 0 + unitC01[0]]
        perpUnitEndRight = [0 + unitC01[1], 0 - unitC01[0]]

        return [
            perpUnitStartLeft, perpUnitStartRright, perpUnitEndLeft,
            perpUnitEndRight
        ]
Пример #5
0
def calculatePerpendiculars(start,end):
    unit = VectMath.unitvect([end[0]-start[0],end[1]-start[1]])
    perpUnitStartLeft = [start[0]+(10*unit[1]),start[1]-(10*unit[0])]
    perpUnitStartRright = [start[0]-(10*unit[1]),start[1]+(10*unit[0])]

    perpUnitEndLeft = [end[0]+(10*unit[1]),end[1]-(10*unit[0])]
    perpUnitEndRight = [end[0]-(10*unit[1]),end[1]+(10*unit[0])]

    return [perpUnitStartLeft,perpUnitStartRright,perpUnitEndLeft,perpUnitEndRight]
Пример #6
0
def GetBezierPoint(points, t):
    """EXPLANATION:
The formula for a point on the bezier curve defined by four points (points[0:3]) at a given value of t is as follows:
    B(t) = ((1-t)^3 * points[0]) + (3 * (1-t)^2 * t * points[1]) + (3 * (1-t) * t^2 * points[2]) + (t^3 * points[3])
            (Where 0 <= t <= 1.)

Here, the formula has been split into the four component parts, each returning a vactor:
    -part1 = (1-t)^3 * points[0]
    -part2 = 3 * (1-t)^2 * t * points[1]
    -part3 = 3 * (1-t) * t^2 * points[2]
    -part4 = t^3 * points[3]

These vectors are then added using the function fourpointsum() to give the final value for B(t).
    """
    part1 = VectMath.vectmult(cube(1.0 - t), points[0])
    part2 = VectMath.vectmult((3 * sqr(1.0 - t) * t), points[1])
    part3 = VectMath.vectmult((3 * (1.0 - t) * sqr(t)), points[2])
    part4 = VectMath.vectmult(cube(t), points[3])

    return VectMath.fourpointsum(part1, part2, part3, part4)