diff --git a/src/mol-math/linear-algebra/3d/mat3.ts b/src/mol-math/linear-algebra/3d/mat3.ts index d37d4c18cd6debddd01c43f74dbe5e54b2b362f3..8e29f2477dda15cbc003a227d8fbde836700152d 100644 --- a/src/mol-math/linear-algebra/3d/mat3.ts +++ b/src/mol-math/linear-algebra/3d/mat3.ts @@ -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]; diff --git a/src/mol-math/linear-algebra/3d/mat4.ts b/src/mol-math/linear-algebra/3d/mat4.ts index e98d98361ea7fed7dfef11351646c0d2c81005a5..546b2d8064db27fddb99f9f813387e6a29006872 100644 --- a/src/mol-math/linear-algebra/3d/mat4.ts +++ b/src/mol-math/linear-algebra/3d/mat4.ts @@ -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) { diff --git a/src/mol-math/linear-algebra/3d/quat.ts b/src/mol-math/linear-algebra/3d/quat.ts index 50e12f11a2f3ce05f4e47ccf475f5368ed9c2108..3b9844d0f340143718e365543490454bac2375f5 100644 --- a/src/mol-math/linear-algebra/3d/quat.ts +++ b/src/mol-math/linear-algebra/3d/quat.ts @@ -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) { diff --git a/src/mol-math/linear-algebra/3d/vec2.ts b/src/mol-math/linear-algebra/3d/vec2.ts index d1bd980551e856fc5f5e0c699636146776a7eac1..16d922951c4a529e21573838a29e6078967c7009 100644 --- a/src/mol-math/linear-algebra/3d/vec2.ts +++ b/src/mol-math/linear-algebra/3d/vec2.ts @@ -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) { diff --git a/src/mol-math/linear-algebra/3d/vec3.ts b/src/mol-math/linear-algebra/3d/vec3.ts index 08afca3531a52d1ca5bbd263fddec98d1188d7a2..51b7a7624a5d3f4194422cc4d2296c6ee176ef96 100644 --- a/src/mol-math/linear-algebra/3d/vec3.ts +++ b/src/mol-math/linear-algebra/3d/vec3.ts @@ -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 { diff --git a/src/mol-math/linear-algebra/3d/vec4.ts b/src/mol-math/linear-algebra/3d/vec4.ts index ab4eb2dbaf08ec2e9f07377308ec04ec431b647a..32f5ddfbcb30a22ced43acca89f193da50ee694c 100644 --- a/src/mol-math/linear-algebra/3d/vec4.ts +++ b/src/mol-math/linear-algebra/3d/vec4.ts @@ -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) {