I wrote a python script that creates a rotation matrix
from math import *
import numpy as np
a = radians(10)
b = radians(15)
g = radians(67)
# https://en.wikipedia.org/wiki/Rotation_matrix#General_rotations
rx = np.array([
[cos(g), -sin(g), 0],
[sin(g), cos(g), 0],
[0, 0, 1],
])
ry = np.array([
[cos(b), 0, sin(b)],
[0, 1, 0],
[-sin(b), 0, cos(b)],
])
rz = np.array([
[1, 0, 0],
[0, cos(a), -sin(a)],
[0, sin(a), cos(a)],
])
r = rz @ ry @ rx
print("rotation matrix")
print(r)
# rotated basis vectors
x = r.T[0]
y = r.T[1]
z = r.T[2]
print("magnitudes")
print(np.linalg.norm(x))
print(np.linalg.norm(y))
print(np.linalg.norm(z))
print("dots")
print(np.dot(x, y))
print(np.dot(y, z))
print(np.dot(x, z))
rotation does not change the shape so every basis vector must be perpendicular. (AFAIK)
however, output of this script shows that the dot products of the basis vectors are not zero.
this is the output of my script
rotation matrix
[[ 0.37741729 -0.88913941 0.25881905]
[ 0.92408112 0.34342438 -0.16773126]
[ 0.0602517 0.30247447 0.95125124]]
magnitudes
1.0
1.0
0.9999999999999999
dots
-2.7755575615628914e-17
0.0
1.3877787807814457e-17
why does this produce non-zero dot product?