diff --git a/packages/matrices/src/m22-m23.ts b/packages/matrices/src/m22-m23.ts new file mode 100644 index 0000000000..5df4b293eb --- /dev/null +++ b/packages/matrices/src/m22-m23.ts @@ -0,0 +1,16 @@ +import { set4 } from "@thi.ng/vectors3"; +import { MatOpM } from "./api"; + +/** + * Converts M22 to M23 and writes result to `out`. + * + * @param out + * @param m22 + */ +export const mat22to23: MatOpM = + (out, m22) => ( + !out && (out = []), + set4(out, m22), + out[4] = out[5] = 0, + out + ); diff --git a/packages/matrices/src/m23-m22.ts b/packages/matrices/src/m23-m22.ts new file mode 100644 index 0000000000..16bd1b8285 --- /dev/null +++ b/packages/matrices/src/m23-m22.ts @@ -0,0 +1,11 @@ +import { set4 } from "@thi.ng/vectors3"; +import { MatOpM } from "./api"; + +/** + * Converts M23 to M22 and writes result to `out`. + * + * @param out + * @param m23 + */ +export const mat23to22: MatOpM = + (out, m23) => set4(out || [], m23); diff --git a/packages/matrices/src/m23-m44.ts b/packages/matrices/src/m23-m44.ts new file mode 100644 index 0000000000..f3e2506fe6 --- /dev/null +++ b/packages/matrices/src/m23-m44.ts @@ -0,0 +1,21 @@ +import { MatOpM } from "./api"; + +/** + * Converts M23 to M44 and writes result to `out`. + * + * @param out + * @param m23 + */ +export const mat23to44: MatOpM = + (out, m23) => ( + !out && (out = []), + out[0] = m23[0], + out[1] = m23[1], + out[4] = m23[2], + out[5] = m23[3], + out[12] = m23[4], + out[13] = m23[5], + out[10] = out[15] = 1, + out[2] = out[3] = out[6] = out[7] = out[8] = out[9] = out[11] = out[14] = 0, + out + );