Example #1
0
def rotate(curve, axis, edges=None, angles=None):
    points = []
    [points.extend(element.tesselate()) for element in curve]
    points = optimize(points)
    slices = []

    if edges is not None and angles is None:
        angles = [(math.pi * 2.0 / edges) * i for i in range(0, edges)]
    elif edges is not None or angles is None:
        raise Exception()

    for angle in angles:
        mat = model.rotationMatrix(axis, angle).transpose()
        slices.append([(numpy.array([*p, 1.0]) * mat).getA()[0][0:3] for p in points])

    return slices
Example #2
0
def rotate(curve, axis, edges):
    def pointToVector(p):
        return numpy.resize(numpy.append(p, [1.]), (4, 1))
    def vectorToPoint(v):
        return v.getA()[:,0][0:3]

    points = []
    [points.extend(element.tesselate()) for element in curve]
    points = optimize(points)
    slices = []

    for i in range(0, edges):
        mat = model.rotationMatrix(axis, (math.pi * 2. / float(edges)) * float(i))
        slices.append([vectorToPoint(mat * pointToVector(p)) for p in points])

    return slices
Example #3
0
 def rotate(self, hrot, vrot):
     self.camera -= self.pov
     if hrot != 0.:
         horizRotationMatrix = numpy.matrix([
                 [math.cos(hrot), -math.sin(hrot), 0., 0.],
                 [math.sin(hrot),  math.cos(hrot), 0., 0.],
                 [            0.,              0., 1., 0.],
                 [            0.,              0., 0., 1.]])
         self.camera = horizRotationMatrix * self.camera
         self.axis = horizRotationMatrix * self.axis
     if vrot != 0.:
         normal = model.normal(self.camera.getA()[:,0], self.axis.getA()[:,0])
         normal = model.normalize(normal)
         vertRotationMatrix = model.rotationMatrix(normal, vrot)
         self.camera = vertRotationMatrix * self.camera
         self.axis = vertRotationMatrix * self.axis
     self.camera += self.pov
Example #4
0
 def rotate(self, hrot, vrot):
     camera = self.camera - self.pov
     axis = self.axis
     if hrot != 0.0:
         horizRotationMatrix = numpy.matrix([
                 [ math.cos(hrot), math.sin(hrot), 0.0, 0.0],
                 [-math.sin(hrot), math.cos(hrot), 0.0, 0.0],
                 [            0.0,            0.0, 1.0, 0.0],
                 [            0.0,            0.0, 0.0, 1.0]])
         camera = (camera * horizRotationMatrix).getA()[0]
         axis = (axis * horizRotationMatrix).getA()[0]
     if vrot != 0.0:
         normal = numpy.cross(camera[0:3], self.axis[0:3])
         normal /= numpy.linalg.norm(normal)
         vertRotationMatrix = model.rotationMatrix(normal, vrot).transpose()
         camera = (camera * vertRotationMatrix).getA()[0]
         axis = (axis * vertRotationMatrix).getA()[0]
     self.camera = camera + self.pov
     self.axis = axis