コード例 #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
ファイル: main.py プロジェクト: kitchenbudapest/vr
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
ファイル: linmath_test.py プロジェクト: esilotesham/vr
    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
ファイル: linmath_test.py プロジェクト: kitchenbudapest/vr
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),