Exemplo n.º 1
0
    def cross(self, q2):
        ''' cross product between quaternions '''
        s1 = self.w()
        s2 = q2.w()

        v1 = vec.V3(self.x(), self.y(), self.z())
        v2 = vec.V3(q2.x(), q2.y(), q2.z())

        s3 = s1 * s2 - (v1.dot(v2))

        v3 = (v2 * s1 + v1 * s2) + v1.cross(v2)

        return Q(s3, v3)
Exemplo n.º 2
0
    def prj(self, point):

        if point == vec.V3(0, 0, 0): raise CamExcept("Cam3: point is 0")

        V = point - self.From

        T = 1 / math.tan(self.view_angle / 2)

        div = V.dot(self.t_matrix[2])

        if div == 0: CamExcept("Cam3: S div is 0")

        S = T / div

        Sx = self.Cx + (self.Lx * S * V.dot(self.t_matrix[0]))
        Sy = self.Cx + (self.Lx * S * V.dot(self.t_matrix[1]))

        return vec.V2(Sx, Sy)
Exemplo n.º 3
0
 def get_vector(self):
     '''get the vector part of the quaternion'''
     return vec.V3(self.x(), self.y(), self.z())