Skip to content

Instantly share code, notes, and snippets.

@jhorikawa
Created May 15, 2024 06:11
Show Gist options
  • Save jhorikawa/db2fbd126782a0a5bf2c38ef4f3d2ac8 to your computer and use it in GitHub Desktop.
Save jhorikawa/db2fbd126782a0a5bf2c38ef4f3d2ac8 to your computer and use it in GitHub Desktop.
VEX code for plane to plane orientation.
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