Skip to content

Commit

Permalink
feat(matrices): add m22 & m23 matrix converters
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jan 20, 2019
1 parent 311b007 commit 2aceab9
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/matrices/src/m22-m23.ts
Original file line number Diff line number Diff line change
@@ -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
);
11 changes: 11 additions & 0 deletions packages/matrices/src/m23-m22.ts
Original file line number Diff line number Diff line change
@@ -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);
21 changes: 21 additions & 0 deletions packages/matrices/src/m23-m44.ts
Original file line number Diff line number Diff line change
@@ -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
);

0 comments on commit 2aceab9

Please sign in to comment.