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

linalg .toString with precision arg

parent 75f6466f
No related branches found
No related tags found
No related merge requests found
......@@ -435,6 +435,10 @@ namespace Quat {
return normalize(out, Quat.fromMat3(out, axesTmpMat));
}
export function toString(a: Quat, precision?: number) {
return `[${a[0].toPrecision(precision)} ${a[1].toPrecision(precision)} ${a[2].toPrecision(precision)} ${a[3].toPrecision(precision)}]`;
}
}
export default Quat
\ No newline at end of file
......@@ -166,6 +166,10 @@ namespace Vec2 {
export function areEqual(a: Vec2, b: Vec2) {
return a[0] === b[0] && a[1] === b[1];
}
export function toString(a: Vec2, precision?: number) {
return `[${a[0].toPrecision(precision)} ${a[1].toPrecision(precision)}}]`;
}
}
export default Vec2
\ No newline at end of file
......@@ -19,7 +19,7 @@
import Mat4 from './mat4';
import { Quat, Mat3, EPSILON } from '../3d';
import { spline as _spline, clamp } from '../../interpolate'
import { spline as _spline, quadraticBezier as _quadraticBezier, clamp } from '../../interpolate'
import { NumberArray } from '../../../mol-util/type-helpers';
interface Vec3 extends Array<number> { [d: number]: number, '@type': 'vec3', length: 3 }
......@@ -344,6 +344,14 @@ namespace Vec3 {
return out;
}
export function quadraticBezier(out: Vec3, a: Vec3, b: Vec3, c: Vec3, t: number) {
out[0] = _quadraticBezier(a[0], b[0], c[0], t);
out[1] = _quadraticBezier(a[1], b[1], c[1], t);
out[2] = _quadraticBezier(a[2], b[2], c[2], t);
return out;
}
/**
* Performs a spline interpolation with two control points and a tension parameter
*/
......@@ -525,8 +533,8 @@ namespace Vec3 {
return normalize(out, cross(out, triangleNormalTmpAB, triangleNormalTmpAC));
}
export function toString(a: Vec3) {
return `[${a[0]} ${a[1]} ${a[2]}]`;
export function toString(a: Vec3, precision?: number) {
return `[${a[0].toPrecision(precision)} ${a[1].toPrecision(precision)} ${a[2].toPrecision(precision)}]`;
}
}
......
......@@ -225,6 +225,10 @@ namespace Vec4 {
Math.abs(a2 - b2) <= EPSILON.Value * Math.max(1.0, Math.abs(a2), Math.abs(b2)) &&
Math.abs(a3 - b3) <= EPSILON.Value * Math.max(1.0, Math.abs(a3), Math.abs(b3)));
}
export function toString(a: Vec4, precision?: number) {
return `[${a[0].toPrecision(precision)} ${a[1].toPrecision(precision)} ${a[2].toPrecision(precision)} ${a[3].toPrecision(precision)}]`;
}
}
export default Vec4
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment