Skip to content
Snippets Groups Projects
Commit d9507181 authored by Alexander Rose's avatar Alexander Rose
Browse files

linalg: return out array for .toArray, create symmetric mat3

parent 4be903b9
Branches
Tags
No related merge requests found
......@@ -72,6 +72,7 @@ namespace Mat3 {
out[offset + 6] = a[6];
out[offset + 7] = a[7];
out[offset + 8] = a[8];
return out;
}
export function fromArray(a: Mat3, array: NumberArray, offset: number) {
......@@ -220,6 +221,44 @@ namespace Mat3 {
return out;
}
export function symmtricFromUpper(out: Mat3, a: Mat3) {
if (out === a) {
out[3] = a[1];
out[6] = a[2];
out[7] = a[5];
} else {
out[0] = a[0];
out[1] = a[1];
out[2] = a[2];
out[3] = a[1];
out[4] = a[4];
out[5] = a[5];
out[6] = a[2];
out[7] = a[5];
out[8] = a[8];
}
return out;
}
export function symmtricFromLower(out: Mat3, a: Mat3) {
if (out === a) {
out[1] = a[3];
out[2] = a[6];
out[5] = a[7];
} else {
out[0] = a[0];
out[1] = a[3];
out[2] = a[6];
out[3] = a[3];
out[4] = a[4];
out[5] = a[7];
out[6] = a[6];
out[7] = a[7];
out[8] = a[8];
}
return out;
}
export function determinant(a: Mat3) {
const a00 = a[0], a01 = a[1], a02 = a[2];
const a10 = a[3], a11 = a[4], a12 = a[5];
......
......@@ -141,6 +141,7 @@ namespace Mat4 {
out[offset + 13] = a[13];
out[offset + 14] = a[14];
out[offset + 15] = a[15];
return out;
}
export function fromArray(a: Mat4, array: NumberArray, offset: number) {
......
......@@ -318,6 +318,7 @@ namespace Quat {
out[offset + 1] = a[1];
out[offset + 2] = a[2];
out[offset + 3] = a[3];
return out;
}
export function fromArray(a: Quat, array: NumberArray, offset: number) {
......
......@@ -53,6 +53,7 @@ namespace Vec2 {
export function toArray(a: Vec2, out: NumberArray, offset: number) {
out[offset + 0] = a[0];
out[offset + 1] = a[1];
return out;
}
export function fromArray(a: Vec2, array: NumberArray, offset: number) {
......
......@@ -73,6 +73,7 @@ namespace Vec3 {
out[offset + 0] = v[0]
out[offset + 1] = v[1]
out[offset + 2] = v[2]
return out
}
export function create(x: number, y: number, z: number): Vec3 {
......
......@@ -62,6 +62,7 @@ namespace Vec4 {
out[offset + 1] = a[1];
out[offset + 2] = a[2];
out[offset + 3] = a[3];
return out;
}
export function fromArray(a: Vec4, array: NumberArray, offset: number) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment