Esempio n. 1
0
        def move(self, x, y):
            self.camera -= self.pov
            axis = numpy.array(self.axis)[:,0][0:3]
            camera = numpy.array(self.camera)[:,0][0:3]
            normal = model.normalize(model.normal(axis, camera))

            width = 2. * math.tan(self.fov / 2.) * numpy.linalg.norm(camera)

            offset = normal * (-x / width) + axis * (-y / width)
            rotationMatrix = numpy.matrix([
                    [1., 0., 0., offset[0]],
                    [0., 1., 0., offset[1]],
                    [0., 0., 1., offset[2]],
                    [0., 0., 0.,        1.]])
            self.camera += self.pov
            self.camera = rotationMatrix * self.camera
            self.pov = rotationMatrix * self.pov
Esempio n. 2
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
Esempio n. 3
0
 def getNormal(points):
     return model.normalize(model.normal(vertices[points[1]] - vertices[points[0]],
             vertices[points[2]] - vertices[points[0]]))