Skip to content

Commit

Permalink
fix(vectors): Mat23/33/44 toString() impls
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Sep 10, 2018
1 parent 3dd0072 commit 07d1ccf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
5 changes: 2 additions & 3 deletions packages/vectors/src/mat23.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,8 @@ export class Mat23 implements
}

toString() {
const i = this.i;
const b = [...this.buf.slice(i, i + 6)].map((x) => x.toFixed(4));
return `${b[i]} ${b[i + 2]} ${b[i + 4]}\n${b[i + 1]} ${b[i + 3]} ${b[i + 5]}`;
const b = (<number[]>get23(this.buf, this.i)).map((x) => x.toFixed(4));
return `${b[0]} ${b[2]} ${b[4]}\n${b[1]} ${b[3]} ${b[5]}`;
}

toJSON() {
Expand Down
9 changes: 4 additions & 5 deletions packages/vectors/src/mat33.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,10 @@ export class Mat33 implements
}

toString() {
const i = this.i;
const b = [...this.buf.slice(i, i + 9)].map((x) => x.toFixed(4));
return `${b[i]} ${b[i + 3]} ${b[i + 6]}
${b[i + 1]} ${b[i + 4]} ${b[i + 7]}
${b[i + 2]} ${b[i + 5]} ${b[i + 8]}`;
const b = (<number[]>get33(this.buf, this.i)).map((x) => x.toFixed(4));
return `${b[0]} ${b[3]} ${b[6]}
${b[1]} ${b[4]} ${b[7]}
${b[2]} ${b[5]} ${b[8]}`;
}

toJSON() {
Expand Down
11 changes: 5 additions & 6 deletions packages/vectors/src/mat44.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,12 +575,11 @@ export class Mat44 implements
}

toString() {
const i = this.i;
const b = [...this.buf.slice(i, i + 16)].map((x) => x.toFixed(4));
return `${b[i]} ${b[i + 4]} ${b[i + 8]} ${b[i + 12]}
${b[i + 1]} ${b[i + 5]} ${b[i + 9]} ${b[i + 13]}
${b[i + 2]} ${b[i + 6]} ${b[i + 10]} ${b[i + 14]}
${b[i + 3]} ${b[i + 7]} ${b[i + 11]} ${b[i + 15]}`;
const b = (<number[]>get44(this.buf, this.i)).map((x) => x.toFixed(4));
return `${b[0]} ${b[4]} ${b[8]} ${b[12]}
${b[1]} ${b[5]} ${b[9]} ${b[13]}
${b[2]} ${b[6]} ${b[10]} ${b[14]}
${b[3]} ${b[7]} ${b[11]} ${b[15]}`;
}

toJSON() {
Expand Down

0 comments on commit 07d1ccf

Please sign in to comment.