Пример #1
0
def rotation_matrix_from_vectors(direction, target_direction):
    v = target_direction.cross_product(direction)
    skew = Mat4x4((0.0, -v.z, v.y, 0.0), (v.z, 0.0, -v.x, 0.0),
                  (-v.y, v.x, 0.0, 0.0), (0.0, 0.0, 0.0, 0.0))
    try:
        return (Mat4x4.identity() + skew + (skew * skew) *
                ((1 - direction * target_direction) / v.length**2))
    except ZeroDivisionError:
        return Mat4x4.identity()
Пример #2
0
def rotation_matrix_from_vectors(direction, target_direction):
    v = target_direction.cross_product(direction)
    skew = Mat4x4(( 0.0, -v.z,  v.y,  0.0),
                  ( v.z,  0.0, -v.x,  0.0),
                  (-v.y,  v.x,  0.0,  0.0),
                  ( 0.0,  0.0,  0.0,  0.0))
    try:
        return (Mat4x4.identity() + skew +
                (skew*skew)*((1 - direction*target_direction)/v.length**2))
    except ZeroDivisionError:
        return Mat4x4.identity()
Пример #3
0
    print(f)

print(v1, v1.normalize())
print(Vec3.from_line(*(tuple(v1) + tuple(v2))).normalize())

print(v1.x, v1.y, v1.z)

print(Vec3.from_line(x1=1, y2=1).normalize().length)
print(v1.length)

print(v1.reflect(v2).normalize() * 2)

#------------------------------------------------------------------------------#
print('-' * 80)

m1 = Mat4x4((-2, 5, 88, 0), (56, 17, 9, -1), (-1, -1, 78, 9), (7, 3, 8, 1))
print(m1)

m2 = Mat4x4.identity()
print(m2)
print(m2[0][0], m2[1][1], m2[2][2], m2[3][3])

print(m1 + m2)
print(m1 - m2)

#------------------------------------------------------------------------------#
print('-' * 80)


#------------------------------------------------------------------------------#
def rotation_matrix_from_vectors(direction, target_direction):
Пример #4
0
print(Vec3.from_line(x1=1, y2=1).normalize().length)
print(v1.length)

print(v1.reflect(v2).normalize() * 2)

#------------------------------------------------------------------------------#
print('-'*80)

m1 = Mat4x4((-2,  5, 88,  0),
            (56, 17,  9, -1),
            (-1, -1, 78,  9),
            ( 7,  3,  8,  1))
print(m1)

m2 = Mat4x4.identity()
print(m2)
print(m2[0][0], m2[1][1], m2[2][2], m2[3][3])

print(m1 + m2)
print(m1 - m2)

#------------------------------------------------------------------------------#
print('-'*80)

#------------------------------------------------------------------------------#
def rotation_matrix_from_vectors(direction, target_direction):
    v = target_direction.cross_product(direction)
    skew = Mat4x4(( 0.0, -v.z,  v.y,  0.0),
                  ( v.z,  0.0, -v.x,  0.0),
                  (-v.y,  v.x,  0.0,  0.0),