예제 #1
0
def calculate_view_matrix(position, rotation):
    """TReturns 4x4 view matrix from the (x.y,z) position and XYZ Euler rotation, in degrees."""
    # Set View Matrix

    trans_mat = transformations.translation_matrix((-position[0], -position[1], -position[2]))

    rotation = tuple(-np.radians(coord) for coord in rotation)
    rot_mat = transformations.euler_matrix(rotation[0], rotation[1], rotation[2], 'rxyz')

    return np.dot(rot_mat, trans_mat)
예제 #2
0
 def on_message(self, message):
     print message
     (t, x, y, z, roll, pitch, yaw) = viconServer.getData()
     (t, x, y, z, roll, pitch, yaw) = [t/100, x/1000, y/1000, z/1000, roll, pitch, yaw]
     R = tf.euler_matrix(roll, pitch, yaw)
     vf = R*np.mat([1,0,0,0]).T
     vu = R*np.mat([0,0,1,0]).T
     msg = json.dumps([x,y,z,float(vf[0]),float(vf[1]),float(vf[2]), \
                      float(vu[0]), float(vu[1]), float(vu[2])])
     print msg
     self.send_message(msg)
예제 #3
0
def calculate_model_matrix(position, rotation, scale):
    """Returns 4x4 model matrix from the (x.y,z) position and XYZ Euler rotation, in degrees."""

    # Set Model and Normal Matrices
    trans_mat = transformations.translation_matrix(position)

    rotation = tuple(np.radians(coord) for coord in rotation)
    rot_mat = transformations.euler_matrix(rotation[0], rotation[1], rotation[2])
    scale_mat = transformations.scale_matrix(scale)

    return np.dot(np.dot(trans_mat, rot_mat), scale_mat)
예제 #4
0
 def to_matrix(self):
     return trans.euler_matrix(*self._array, axes=self.axes)