Created
May 15, 2024 06:11
-
-
Save jhorikawa/db2fbd126782a0a5bf2c38ef4f3d2ac8 to your computer and use it in GitHub Desktop.
VEX code for plane to plane orientation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
matrix planeToPlaneOrientation(vector upos; vector u1; vector u2; vector vpos; vector v1; vector v2) { | |
vector u3 = normalize(cross(u1, u2)); | |
vector v3 = normalize(cross(v1, v2)); | |
matrix3 U = set(u1, u2, u3); | |
matrix3 V = set(v1, v2, v3); | |
matrix3 rotmat = transpose(U) * V; | |
matrix mat = ident(); | |
translate(mat, -upos); | |
mat *= rotmat; | |
translate(mat, vpos); | |
return mat; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment