Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/intern/math_matrix.c
| Show First 20 Lines • Show All 2,382 Lines • ▼ Show 20 Lines | void interp_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3], const float t) | ||||
| * linearly interpolated. */ | * linearly interpolated. */ | ||||
| float P_A[3][3], P_B[3][3], P[3][3]; | float P_A[3][3], P_B[3][3], P[3][3]; | ||||
| int i; | int i; | ||||
| mat3_polar_decompose(A, U_A, P_A); | mat3_polar_decompose(A, U_A, P_A); | ||||
| mat3_polar_decompose(B, U_B, P_B); | mat3_polar_decompose(B, U_B, P_B); | ||||
| /* Quaterions cannot represent an axis flip. If such a singularity is detected, choose a | |||||
| * different decomposition of the matrix that still satisfies A = U_A * P_A but which has a | |||||
| * positive determinant and thus no axis flips. This resolves T77154. | |||||
| * | |||||
| * Note that a flip of two axes is just a rotation of 180 degrees around the third axis, and | |||||
| * three flipped axes are just an 180 degree rotation + a single axis flip. It is thus sufficient | |||||
| * to solve this problem for single axis flips. */ | |||||
| if (determinant_m3_array(U_A) < 0) { | |||||
| mul_m3_fl(U_A, -1.0f); | |||||
| mul_m3_fl(P_A, -1.0f); | |||||
| } | |||||
| if (determinant_m3_array(U_B) < 0) { | |||||
| mul_m3_fl(U_B, -1.0f); | |||||
| mul_m3_fl(P_B, -1.0f); | |||||
| } | |||||
| mat3_to_quat(quat_A, U_A); | mat3_to_quat(quat_A, U_A); | ||||
| mat3_to_quat(quat_B, U_B); | mat3_to_quat(quat_B, U_B); | ||||
| interp_qt_qtqt(quat, quat_A, quat_B, t); | interp_qt_qtqt(quat, quat_A, quat_B, t); | ||||
| quat_to_mat3(U, quat); | quat_to_mat3(U, quat); | ||||
| for (i = 0; i < 3; i++) { | for (i = 0; i < 3; i++) { | ||||
| interp_v3_v3v3(P[i], P_A[i], P_B[i], t); | interp_v3_v3v3(P[i], P_A[i], P_B[i], t); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 790 Lines • Show Last 20 Lines | |||||