mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-27 02:43:04 +01:00
extract matrix class to a separate module
This commit is contained in:
parent
b4e83520b5
commit
7909cbc674
40 changed files with 469 additions and 463 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import {AXIS, Matrix3, ORIGIN} from './l3space';
|
||||
import {AXIS, ORIGIN} from './l3space';
|
||||
import Vector from "math/vector";
|
||||
import {Matrix3} from "math/matrix";
|
||||
|
||||
export default class CSys {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
import Vector from 'math/vector';
|
||||
import {Matrix3} from "math/matrix";
|
||||
|
||||
export type Basis = [Vector, Vector, Vector];
|
||||
|
||||
export type Vec3 = [number, number, number];
|
||||
|
||||
export type Matrix3x4Data = [[number, number, number, number],[number, number, number, number],[number, number, number, number]];
|
||||
|
||||
const freeze = Object.freeze;
|
||||
|
||||
const ORIGIN = freeze(new Vector(0, 0, 0));
|
||||
|
|
@ -25,415 +24,6 @@ export const STANDARD_BASES = freeze({
|
|||
'ZY': [AXIS.Z, AXIS.Y, AXIS.X]
|
||||
});
|
||||
|
||||
export class Matrix3 {
|
||||
|
||||
mxx: number = 1;
|
||||
mxy: number = 0;
|
||||
mxz: number = 0;
|
||||
tx: number = 0;
|
||||
myx: number = 0;
|
||||
myy: number = 1;
|
||||
myz: number = 0;
|
||||
ty: number = 0;
|
||||
mzx: number = 0;
|
||||
mzy: number = 0;
|
||||
mzz: number = 1;
|
||||
tz: number = 0;
|
||||
|
||||
reset(): Matrix3 {
|
||||
this.mxx = 1;
|
||||
this.mxy = 0;
|
||||
this.mxz = 0;
|
||||
this.tx = 0;
|
||||
this.myx = 0;
|
||||
this.myy = 1;
|
||||
this.myz = 0;
|
||||
this.ty = 0;
|
||||
this.mzx = 0;
|
||||
this.mzy = 0;
|
||||
this.mzz = 1;
|
||||
this.tz = 0;
|
||||
return this;
|
||||
};
|
||||
|
||||
setBasis(basis: [Vector, Vector, Vector]): Matrix3 {
|
||||
var b = basis;
|
||||
this.mxx = b[0].x;
|
||||
this.mxy = b[1].x;
|
||||
this.mxz = b[2].x;
|
||||
this.tx = 0;
|
||||
this.myx = b[0].y;
|
||||
this.myy = b[1].y;
|
||||
this.myz = b[2].y;
|
||||
this.ty = 0;
|
||||
this.mzx = b[0].z;
|
||||
this.mzy = b[1].z;
|
||||
this.mzz = b[2].z;
|
||||
this.tz = 0;
|
||||
return this;
|
||||
};
|
||||
|
||||
setBasisAxises(x: Vector, y: Vector, z: Vector): Matrix3 {
|
||||
this.mxx = x.x;
|
||||
this.mxy = y.x;
|
||||
this.mxz = z.x;
|
||||
this.tx = 0;
|
||||
this.myx = x.y;
|
||||
this.myy = y.y;
|
||||
this.myz = z.y;
|
||||
this.ty = 0;
|
||||
this.mzx = x.z;
|
||||
this.mzy = y.z;
|
||||
this.mzz = z.z;
|
||||
this.tz = 0;
|
||||
return this;
|
||||
};
|
||||
|
||||
setBasisAndTranslation(basis: [Vector, Vector, Vector], translation: Vector): Matrix3 {
|
||||
this.setBasis(basis);
|
||||
this.tx = translation.x;
|
||||
this.ty = translation.y;
|
||||
this.tz = translation.z;
|
||||
return this;
|
||||
};
|
||||
|
||||
scale(dx: number, dy: number, dz: number): Matrix3{
|
||||
this.mxx *= dx;
|
||||
this.myy *= dy;
|
||||
this.mzz *= dz;
|
||||
return this;
|
||||
};
|
||||
|
||||
translate(dx: number, dy: number, dz: number): Matrix3 {
|
||||
this.tx += dx;
|
||||
this.ty += dy;
|
||||
this.tz += dz;
|
||||
return this;
|
||||
};
|
||||
|
||||
translateVec({x, y, z}: Vector): Matrix3 {
|
||||
this.tx += x;
|
||||
this.ty += y;
|
||||
this.tz += z;
|
||||
return this;
|
||||
};
|
||||
|
||||
set3(
|
||||
mxx: number, mxy: number, mxz: number,
|
||||
myx: number, myy: number, myz: number,
|
||||
mzx: number, mzy: number, mzz: number
|
||||
): Matrix3 {
|
||||
this.mxx = mxx;
|
||||
this.mxy = mxy;
|
||||
this.mxz = mxz;
|
||||
this.myx = myx;
|
||||
this.myy = myy;
|
||||
this.myz = myz;
|
||||
this.mzx = mzx;
|
||||
this.mzy = mzy;
|
||||
this.mzz = mzz;
|
||||
return this;
|
||||
};
|
||||
|
||||
set34(
|
||||
mxx: number, mxy: number, mxz: number, tx: number,
|
||||
myx: number, myy: number, myz: number, ty: number,
|
||||
mzx: number, mzy: number, mzz: number, tz: number
|
||||
): Matrix3 {
|
||||
this.mxx = mxx;
|
||||
this.mxy = mxy;
|
||||
this.mxz = mxz;
|
||||
this.tx = tx;
|
||||
this.myx = myx;
|
||||
this.myy = myy;
|
||||
this.myz = myz;
|
||||
this.ty = ty;
|
||||
this.mzx = mzx;
|
||||
this.mzy = mzy;
|
||||
this.mzz = mzz;
|
||||
this.tz = tz;
|
||||
return this;
|
||||
};
|
||||
|
||||
setMatrix(m: Matrix3): Matrix3 {
|
||||
this.mxx = m.mxx;
|
||||
this.mxy = m.mxy;
|
||||
this.mxz = m.mxz;
|
||||
this.tx = m.tx;
|
||||
this.myx = m.myx;
|
||||
this.myy = m.myy;
|
||||
this.myz = m.myz;
|
||||
this.ty = m.ty;
|
||||
this.mzx = m.mzx;
|
||||
this.mzy = m.mzy;
|
||||
this.mzz = m.mzz;
|
||||
this.tz = m.tz;
|
||||
return this;
|
||||
};
|
||||
|
||||
setToMatrix(m: any): void {
|
||||
m.set(
|
||||
this.mxx, this.mxy, this.mxz, this.tx,
|
||||
this.myx, this.myy, this.myz, this.ty,
|
||||
this.mzx, this.mzy, this.mzz, this.tz,
|
||||
0, 0, 0, 1
|
||||
);
|
||||
};
|
||||
|
||||
toArray(): Matrix3x4Data {
|
||||
return [
|
||||
[this.mxx, this.mxy, this.mxz, this.tx],
|
||||
[this.myx, this.myy, this.myz, this.ty],
|
||||
[this.mzx, this.mzy, this.mzz, this.tz]
|
||||
];
|
||||
};
|
||||
|
||||
invert(): Matrix3 {
|
||||
return this.__invert(new Matrix3());
|
||||
};
|
||||
|
||||
_invert(): Matrix3 {
|
||||
return this.__invert(this);
|
||||
};
|
||||
|
||||
__invert(out: Matrix3): Matrix3 {
|
||||
|
||||
var det =
|
||||
this.mxx * (this.myy * this.mzz - this.mzy * this.myz) +
|
||||
this.mxy * (this.myz * this.mzx - this.mzz * this.myx) +
|
||||
this.mxz * (this.myx * this.mzy - this.mzx * this.myy);
|
||||
|
||||
if (det == 0.0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var cxx = this.myy * this.mzz - this.myz * this.mzy;
|
||||
var cyx = -this.myx * this.mzz + this.myz * this.mzx;
|
||||
var czx = this.myx * this.mzy - this.myy * this.mzx;
|
||||
var cxt = -this.mxy * (this.myz * this.tz - this.mzz * this.ty)
|
||||
- this.mxz * (this.ty * this.mzy - this.tz * this.myy)
|
||||
- this.tx * (this.myy * this.mzz - this.mzy * this.myz);
|
||||
var cxy = -this.mxy * this.mzz + this.mxz * this.mzy;
|
||||
var cyy = this.mxx * this.mzz - this.mxz * this.mzx;
|
||||
var czy = -this.mxx * this.mzy + this.mxy * this.mzx;
|
||||
var cyt = this.mxx * (this.myz * this.tz - this.mzz * this.ty)
|
||||
+ this.mxz * (this.ty * this.mzx - this.tz * this.myx)
|
||||
+ this.tx * (this.myx * this.mzz - this.mzx * this.myz);
|
||||
var cxz = this.mxy * this.myz - this.mxz * this.myy;
|
||||
var cyz = -this.mxx * this.myz + this.mxz * this.myx;
|
||||
var czz = this.mxx * this.myy - this.mxy * this.myx;
|
||||
var czt = -this.mxx * (this.myy * this.tz - this.mzy * this.ty)
|
||||
- this.mxy * (this.ty * this.mzx - this.tz * this.myx)
|
||||
- this.tx * (this.myx * this.mzy - this.mzx * this.myy);
|
||||
|
||||
out.mxx = cxx / det;
|
||||
out.mxy = cxy / det;
|
||||
out.mxz = cxz / det;
|
||||
out.tx = cxt / det;
|
||||
out.myx = cyx / det;
|
||||
out.myy = cyy / det;
|
||||
out.myz = cyz / det;
|
||||
out.ty = cyt / det;
|
||||
out.mzx = czx / det;
|
||||
out.mzy = czy / det;
|
||||
out.mzz = czz / det;
|
||||
out.tz = czt / det;
|
||||
return out;
|
||||
};
|
||||
|
||||
combine(transform: Matrix3, out?: Matrix3): Matrix3 {
|
||||
var txx = transform.mxx;
|
||||
var txy = transform.mxy;
|
||||
var txz = transform.mxz;
|
||||
var ttx = transform.tx;
|
||||
var tyx = transform.myx;
|
||||
var tyy = transform.myy;
|
||||
var tyz = transform.myz;
|
||||
var tty = transform.ty;
|
||||
var tzx = transform.mzx;
|
||||
var tzy = transform.mzy;
|
||||
var tzz = transform.mzz;
|
||||
var ttz = transform.tz;
|
||||
|
||||
var m = out || new Matrix3();
|
||||
m.mxx = (this.mxx * txx + this.mxy * tyx + this.mxz * tzx);
|
||||
m.mxy = (this.mxx * txy + this.mxy * tyy + this.mxz * tzy);
|
||||
m.mxz = (this.mxx * txz + this.mxy * tyz + this.mxz * tzz);
|
||||
m.tx = (this.mxx * ttx + this.mxy * tty + this.mxz * ttz + this.tx);
|
||||
m.myx = (this.myx * txx + this.myy * tyx + this.myz * tzx);
|
||||
m.myy = (this.myx * txy + this.myy * tyy + this.myz * tzy);
|
||||
m.myz = (this.myx * txz + this.myy * tyz + this.myz * tzz);
|
||||
m.ty = (this.myx * ttx + this.myy * tty + this.myz * ttz + this.ty);
|
||||
m.mzx = (this.mzx * txx + this.mzy * tyx + this.mzz * tzx);
|
||||
m.mzy = (this.mzx * txy + this.mzy * tyy + this.mzz * tzy);
|
||||
m.mzz = (this.mzx * txz + this.mzy * tyz + this.mzz * tzz);
|
||||
m.tz = (this.mzx * ttx + this.mzy * tty + this.mzz * ttz + this.tz);
|
||||
|
||||
return m;
|
||||
};
|
||||
|
||||
combine3x3(transform: Matrix3, out?: Matrix3): Matrix3 {
|
||||
var txx = transform.mxx;
|
||||
var txy = transform.mxy;
|
||||
var txz = transform.mxz;
|
||||
|
||||
var tyx = transform.myx;
|
||||
var tyy = transform.myy;
|
||||
var tyz = transform.myz;
|
||||
|
||||
var tzx = transform.mzx;
|
||||
var tzy = transform.mzy;
|
||||
var tzz = transform.mzz;
|
||||
|
||||
|
||||
var m = out || new Matrix3();
|
||||
m.mxx = (this.mxx * txx + this.mxy * tyx + this.mxz * tzx);
|
||||
m.mxy = (this.mxx * txy + this.mxy * tyy + this.mxz * tzy);
|
||||
m.mxz = (this.mxx * txz + this.mxy * tyz + this.mxz * tzz);
|
||||
|
||||
m.myx = (this.myx * txx + this.myy * tyx + this.myz * tzx);
|
||||
m.myy = (this.myx * txy + this.myy * tyy + this.myz * tzy);
|
||||
m.myz = (this.myx * txz + this.myy * tyz + this.myz * tzz);
|
||||
|
||||
m.mzx = (this.mzx * txx + this.mzy * tyx + this.mzz * tzx);
|
||||
m.mzy = (this.mzx * txy + this.mzy * tyy + this.mzz * tzy);
|
||||
m.mzz = (this.mzx * txz + this.mzy * tyz + this.mzz * tzz);
|
||||
|
||||
|
||||
return m;
|
||||
};
|
||||
|
||||
__applyNoTranslation(vector: Vector, out: Vector): Vector {
|
||||
let x = vector.x;
|
||||
let y = vector.y;
|
||||
let z = vector.z;
|
||||
out.x = this.mxx * x + this.mxy * y + this.mxz * z;
|
||||
out.y = this.myx * x + this.myy * y + this.myz * z;
|
||||
out.z = this.mzx * x + this.mzy * y + this.mzz * z;
|
||||
return out;
|
||||
};
|
||||
|
||||
_applyNoTranslation(vector: Vector): Vector {
|
||||
return this.__applyNoTranslation(vector, vector);
|
||||
};
|
||||
|
||||
applyNoTranslation = vector => this.__applyNoTranslation(vector, new Vector());
|
||||
|
||||
_apply(vector: Vector): Vector {
|
||||
return this.__apply(vector, vector);
|
||||
};
|
||||
|
||||
__apply(vector: Vector, out: Vector): Vector {
|
||||
let x = vector.x;
|
||||
let y = vector.y;
|
||||
let z = vector.z;
|
||||
out.x = this.mxx * x + this.mxy * y + this.mxz * z + this.tx;
|
||||
out.y = this.myx * x + this.myy * y + this.myz * z + this.ty;
|
||||
out.z = this.mzx * x + this.mzy * y + this.mzz * z + this.tz;
|
||||
return out;
|
||||
};
|
||||
|
||||
apply3(data: Vec3): Vec3 {
|
||||
return this.__apply3(data, [0,0,0])
|
||||
};
|
||||
|
||||
_apply3(data: Vec3): Vec3 {
|
||||
return this.__apply3(data, data);
|
||||
};
|
||||
|
||||
__apply3([x, y, z]: Vec3, out: Vec3): Vec3 {
|
||||
out[0] = this.mxx * x + this.mxy * y + this.mxz * z + this.tx;
|
||||
out[1] = this.myx * x + this.myy * y + this.myz * z + this.ty;
|
||||
out[2] = this.mzx * x + this.mzy * y + this.mzz * z + this.tz;
|
||||
return out;
|
||||
};
|
||||
|
||||
rotateWithSphericalAxis(axisAzimuth: number, axisInclination: number, angle: number, pivot: Vector) {
|
||||
|
||||
const axis = new Vector(
|
||||
Math.sin(axisAzimuth) * Math.cos(axisInclination),
|
||||
Math.sin(axisAzimuth) * Math.sin(axisInclination),
|
||||
Math.cos(axisAzimuth)
|
||||
);
|
||||
|
||||
return Matrix3.rotateMatrix(angle, axis, pivot, this);
|
||||
};
|
||||
|
||||
rotate(angle: number, axis: Vector, pivot: Vector) {
|
||||
return Matrix3.rotateMatrix(angle, axis, pivot, this);
|
||||
};
|
||||
|
||||
static rotateMatrix(angle: number, axis: Vector, pivot: Vector, matrix?: Matrix3): Matrix3 {
|
||||
const sin = Math.sin(angle);
|
||||
const cos = Math.cos(angle);
|
||||
return Matrix3.rotationMatrix(cos, sin, axis, pivot, matrix);
|
||||
}
|
||||
|
||||
static rotationFromVectorToVector(from: Vector, to: Vector, pivot: Vector, matrix?: Matrix3): Matrix3 {
|
||||
|
||||
const axis = from.cross(to);
|
||||
|
||||
const cos = from.dot(to);
|
||||
const sin = axis.length();
|
||||
|
||||
return Matrix3.rotationMatrix(cos, sin, axis, pivot, matrix);
|
||||
|
||||
}
|
||||
|
||||
static rotationMatrix(cos: number, sin: number, axis: Vector, pivot: Vector, matrix?: Matrix3): Matrix3 {
|
||||
var axisX, axisY, axisZ;
|
||||
var m = matrix || new Matrix3();
|
||||
|
||||
if (axis === AXIS.X || axis === AXIS.Y || axis === AXIS.Z) {
|
||||
axisX = axis.x;
|
||||
axisY = axis.y;
|
||||
axisZ = axis.z;
|
||||
} else {
|
||||
// normalize
|
||||
var mag = axis.length();
|
||||
|
||||
if (mag == 0.0) {
|
||||
return m;
|
||||
} else {
|
||||
axisX = axis.x / mag;
|
||||
axisY = axis.y / mag;
|
||||
axisZ = axis.z / mag;
|
||||
}
|
||||
}
|
||||
|
||||
var px = pivot.x;
|
||||
var py = pivot.y;
|
||||
var pz = pivot.z;
|
||||
|
||||
m.mxx = cos + axisX * axisX * (1 - cos);
|
||||
m.mxy = axisX * axisY * (1 - cos) - axisZ * sin;
|
||||
m.mxz = axisX * axisZ * (1 - cos) + axisY * sin;
|
||||
|
||||
m.tx = px * (1 - m.mxx) - py * m.mxy - pz * m.mxz;
|
||||
|
||||
m.myx = axisY * axisX * (1 - cos) + axisZ * sin;
|
||||
m.myy = cos + axisY * axisY * (1 - cos);
|
||||
m.myz = axisY * axisZ * (1 - cos) - axisX * sin;
|
||||
m.ty = py * (1 - m.myy) - px * m.myx - pz * m.myz;
|
||||
|
||||
m.mzx = axisZ * axisX * (1 - cos) - axisY * sin;
|
||||
m.mzy = axisZ * axisY * (1 - cos) + axisX * sin;
|
||||
m.mzz = cos + axisZ * axisZ * (1 - cos);
|
||||
m.tz = pz * (1 - m.mzz) - px * m.mzx - py * m.mzy;
|
||||
return m;
|
||||
};
|
||||
|
||||
apply = vector => this.__apply(vector, new Vector());
|
||||
|
||||
setTranslation(tx, ty, tz) {
|
||||
this.tx = tx;
|
||||
this.ty = ty;
|
||||
this.tz = tz;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function BasisForPlane(normal: Vector, alignY: Vector = AXIS.Y, alignZ: Vector = AXIS.Z): [Vector, Vector, Vector] {
|
||||
let alignPlane, x, y;
|
||||
|
|
|
|||
413
modules/math/matrix.ts
Normal file
413
modules/math/matrix.ts
Normal file
|
|
@ -0,0 +1,413 @@
|
|||
import {AXIS, Vec3} from "math/l3space";
|
||||
import Vector from "math/vector";
|
||||
|
||||
export type Matrix3x4Data = [[number, number, number, number], [number, number, number, number], [number, number, number, number]];
|
||||
|
||||
export class Matrix3 {
|
||||
|
||||
mxx: number = 1;
|
||||
mxy: number = 0;
|
||||
mxz: number = 0;
|
||||
tx: number = 0;
|
||||
myx: number = 0;
|
||||
myy: number = 1;
|
||||
myz: number = 0;
|
||||
ty: number = 0;
|
||||
mzx: number = 0;
|
||||
mzy: number = 0;
|
||||
mzz: number = 1;
|
||||
tz: number = 0;
|
||||
|
||||
reset(): Matrix3 {
|
||||
this.mxx = 1;
|
||||
this.mxy = 0;
|
||||
this.mxz = 0;
|
||||
this.tx = 0;
|
||||
this.myx = 0;
|
||||
this.myy = 1;
|
||||
this.myz = 0;
|
||||
this.ty = 0;
|
||||
this.mzx = 0;
|
||||
this.mzy = 0;
|
||||
this.mzz = 1;
|
||||
this.tz = 0;
|
||||
return this;
|
||||
};
|
||||
|
||||
setBasis(basis: [Vector, Vector, Vector]): Matrix3 {
|
||||
var b = basis;
|
||||
this.mxx = b[0].x;
|
||||
this.mxy = b[1].x;
|
||||
this.mxz = b[2].x;
|
||||
this.tx = 0;
|
||||
this.myx = b[0].y;
|
||||
this.myy = b[1].y;
|
||||
this.myz = b[2].y;
|
||||
this.ty = 0;
|
||||
this.mzx = b[0].z;
|
||||
this.mzy = b[1].z;
|
||||
this.mzz = b[2].z;
|
||||
this.tz = 0;
|
||||
return this;
|
||||
};
|
||||
|
||||
setBasisAxises(x: Vector, y: Vector, z: Vector): Matrix3 {
|
||||
this.mxx = x.x;
|
||||
this.mxy = y.x;
|
||||
this.mxz = z.x;
|
||||
this.tx = 0;
|
||||
this.myx = x.y;
|
||||
this.myy = y.y;
|
||||
this.myz = z.y;
|
||||
this.ty = 0;
|
||||
this.mzx = x.z;
|
||||
this.mzy = y.z;
|
||||
this.mzz = z.z;
|
||||
this.tz = 0;
|
||||
return this;
|
||||
};
|
||||
|
||||
setBasisAndTranslation(basis: [Vector, Vector, Vector], translation: Vector): Matrix3 {
|
||||
this.setBasis(basis);
|
||||
this.tx = translation.x;
|
||||
this.ty = translation.y;
|
||||
this.tz = translation.z;
|
||||
return this;
|
||||
};
|
||||
|
||||
scale(dx: number, dy: number, dz: number): Matrix3 {
|
||||
this.mxx *= dx;
|
||||
this.myy *= dy;
|
||||
this.mzz *= dz;
|
||||
return this;
|
||||
};
|
||||
|
||||
translate(dx: number, dy: number, dz: number): Matrix3 {
|
||||
this.tx += dx;
|
||||
this.ty += dy;
|
||||
this.tz += dz;
|
||||
return this;
|
||||
};
|
||||
|
||||
translateVec({x, y, z}: Vector): Matrix3 {
|
||||
this.tx += x;
|
||||
this.ty += y;
|
||||
this.tz += z;
|
||||
return this;
|
||||
};
|
||||
|
||||
set3(
|
||||
mxx: number, mxy: number, mxz: number,
|
||||
myx: number, myy: number, myz: number,
|
||||
mzx: number, mzy: number, mzz: number
|
||||
): Matrix3 {
|
||||
this.mxx = mxx;
|
||||
this.mxy = mxy;
|
||||
this.mxz = mxz;
|
||||
this.myx = myx;
|
||||
this.myy = myy;
|
||||
this.myz = myz;
|
||||
this.mzx = mzx;
|
||||
this.mzy = mzy;
|
||||
this.mzz = mzz;
|
||||
return this;
|
||||
};
|
||||
|
||||
set34(
|
||||
mxx: number, mxy: number, mxz: number, tx: number,
|
||||
myx: number, myy: number, myz: number, ty: number,
|
||||
mzx: number, mzy: number, mzz: number, tz: number
|
||||
): Matrix3 {
|
||||
this.mxx = mxx;
|
||||
this.mxy = mxy;
|
||||
this.mxz = mxz;
|
||||
this.tx = tx;
|
||||
this.myx = myx;
|
||||
this.myy = myy;
|
||||
this.myz = myz;
|
||||
this.ty = ty;
|
||||
this.mzx = mzx;
|
||||
this.mzy = mzy;
|
||||
this.mzz = mzz;
|
||||
this.tz = tz;
|
||||
return this;
|
||||
};
|
||||
|
||||
setMatrix(m: Matrix3): Matrix3 {
|
||||
this.mxx = m.mxx;
|
||||
this.mxy = m.mxy;
|
||||
this.mxz = m.mxz;
|
||||
this.tx = m.tx;
|
||||
this.myx = m.myx;
|
||||
this.myy = m.myy;
|
||||
this.myz = m.myz;
|
||||
this.ty = m.ty;
|
||||
this.mzx = m.mzx;
|
||||
this.mzy = m.mzy;
|
||||
this.mzz = m.mzz;
|
||||
this.tz = m.tz;
|
||||
return this;
|
||||
};
|
||||
|
||||
setToMatrix(m: any): void {
|
||||
m.set(
|
||||
this.mxx, this.mxy, this.mxz, this.tx,
|
||||
this.myx, this.myy, this.myz, this.ty,
|
||||
this.mzx, this.mzy, this.mzz, this.tz,
|
||||
0, 0, 0, 1
|
||||
);
|
||||
};
|
||||
|
||||
toArray(): Matrix3x4Data {
|
||||
return [
|
||||
[this.mxx, this.mxy, this.mxz, this.tx],
|
||||
[this.myx, this.myy, this.myz, this.ty],
|
||||
[this.mzx, this.mzy, this.mzz, this.tz]
|
||||
];
|
||||
};
|
||||
|
||||
invert(): Matrix3 {
|
||||
return this.__invert(new Matrix3());
|
||||
};
|
||||
|
||||
_invert(): Matrix3 {
|
||||
return this.__invert(this);
|
||||
};
|
||||
|
||||
__invert(out: Matrix3): Matrix3 {
|
||||
|
||||
var det =
|
||||
this.mxx * (this.myy * this.mzz - this.mzy * this.myz) +
|
||||
this.mxy * (this.myz * this.mzx - this.mzz * this.myx) +
|
||||
this.mxz * (this.myx * this.mzy - this.mzx * this.myy);
|
||||
|
||||
if (det == 0.0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var cxx = this.myy * this.mzz - this.myz * this.mzy;
|
||||
var cyx = -this.myx * this.mzz + this.myz * this.mzx;
|
||||
var czx = this.myx * this.mzy - this.myy * this.mzx;
|
||||
var cxt = -this.mxy * (this.myz * this.tz - this.mzz * this.ty)
|
||||
- this.mxz * (this.ty * this.mzy - this.tz * this.myy)
|
||||
- this.tx * (this.myy * this.mzz - this.mzy * this.myz);
|
||||
var cxy = -this.mxy * this.mzz + this.mxz * this.mzy;
|
||||
var cyy = this.mxx * this.mzz - this.mxz * this.mzx;
|
||||
var czy = -this.mxx * this.mzy + this.mxy * this.mzx;
|
||||
var cyt = this.mxx * (this.myz * this.tz - this.mzz * this.ty)
|
||||
+ this.mxz * (this.ty * this.mzx - this.tz * this.myx)
|
||||
+ this.tx * (this.myx * this.mzz - this.mzx * this.myz);
|
||||
var cxz = this.mxy * this.myz - this.mxz * this.myy;
|
||||
var cyz = -this.mxx * this.myz + this.mxz * this.myx;
|
||||
var czz = this.mxx * this.myy - this.mxy * this.myx;
|
||||
var czt = -this.mxx * (this.myy * this.tz - this.mzy * this.ty)
|
||||
- this.mxy * (this.ty * this.mzx - this.tz * this.myx)
|
||||
- this.tx * (this.myx * this.mzy - this.mzx * this.myy);
|
||||
|
||||
out.mxx = cxx / det;
|
||||
out.mxy = cxy / det;
|
||||
out.mxz = cxz / det;
|
||||
out.tx = cxt / det;
|
||||
out.myx = cyx / det;
|
||||
out.myy = cyy / det;
|
||||
out.myz = cyz / det;
|
||||
out.ty = cyt / det;
|
||||
out.mzx = czx / det;
|
||||
out.mzy = czy / det;
|
||||
out.mzz = czz / det;
|
||||
out.tz = czt / det;
|
||||
return out;
|
||||
};
|
||||
|
||||
combine(transform: Matrix3, out?: Matrix3): Matrix3 {
|
||||
var txx = transform.mxx;
|
||||
var txy = transform.mxy;
|
||||
var txz = transform.mxz;
|
||||
var ttx = transform.tx;
|
||||
var tyx = transform.myx;
|
||||
var tyy = transform.myy;
|
||||
var tyz = transform.myz;
|
||||
var tty = transform.ty;
|
||||
var tzx = transform.mzx;
|
||||
var tzy = transform.mzy;
|
||||
var tzz = transform.mzz;
|
||||
var ttz = transform.tz;
|
||||
|
||||
var m = out || new Matrix3();
|
||||
m.mxx = (this.mxx * txx + this.mxy * tyx + this.mxz * tzx);
|
||||
m.mxy = (this.mxx * txy + this.mxy * tyy + this.mxz * tzy);
|
||||
m.mxz = (this.mxx * txz + this.mxy * tyz + this.mxz * tzz);
|
||||
m.tx = (this.mxx * ttx + this.mxy * tty + this.mxz * ttz + this.tx);
|
||||
m.myx = (this.myx * txx + this.myy * tyx + this.myz * tzx);
|
||||
m.myy = (this.myx * txy + this.myy * tyy + this.myz * tzy);
|
||||
m.myz = (this.myx * txz + this.myy * tyz + this.myz * tzz);
|
||||
m.ty = (this.myx * ttx + this.myy * tty + this.myz * ttz + this.ty);
|
||||
m.mzx = (this.mzx * txx + this.mzy * tyx + this.mzz * tzx);
|
||||
m.mzy = (this.mzx * txy + this.mzy * tyy + this.mzz * tzy);
|
||||
m.mzz = (this.mzx * txz + this.mzy * tyz + this.mzz * tzz);
|
||||
m.tz = (this.mzx * ttx + this.mzy * tty + this.mzz * ttz + this.tz);
|
||||
|
||||
return m;
|
||||
};
|
||||
|
||||
combine3x3(transform: Matrix3, out?: Matrix3): Matrix3 {
|
||||
var txx = transform.mxx;
|
||||
var txy = transform.mxy;
|
||||
var txz = transform.mxz;
|
||||
|
||||
var tyx = transform.myx;
|
||||
var tyy = transform.myy;
|
||||
var tyz = transform.myz;
|
||||
|
||||
var tzx = transform.mzx;
|
||||
var tzy = transform.mzy;
|
||||
var tzz = transform.mzz;
|
||||
|
||||
|
||||
var m = out || new Matrix3();
|
||||
m.mxx = (this.mxx * txx + this.mxy * tyx + this.mxz * tzx);
|
||||
m.mxy = (this.mxx * txy + this.mxy * tyy + this.mxz * tzy);
|
||||
m.mxz = (this.mxx * txz + this.mxy * tyz + this.mxz * tzz);
|
||||
|
||||
m.myx = (this.myx * txx + this.myy * tyx + this.myz * tzx);
|
||||
m.myy = (this.myx * txy + this.myy * tyy + this.myz * tzy);
|
||||
m.myz = (this.myx * txz + this.myy * tyz + this.myz * tzz);
|
||||
|
||||
m.mzx = (this.mzx * txx + this.mzy * tyx + this.mzz * tzx);
|
||||
m.mzy = (this.mzx * txy + this.mzy * tyy + this.mzz * tzy);
|
||||
m.mzz = (this.mzx * txz + this.mzy * tyz + this.mzz * tzz);
|
||||
|
||||
|
||||
return m;
|
||||
};
|
||||
|
||||
__applyNoTranslation(vector: Vector, out: Vector): Vector {
|
||||
let x = vector.x;
|
||||
let y = vector.y;
|
||||
let z = vector.z;
|
||||
out.x = this.mxx * x + this.mxy * y + this.mxz * z;
|
||||
out.y = this.myx * x + this.myy * y + this.myz * z;
|
||||
out.z = this.mzx * x + this.mzy * y + this.mzz * z;
|
||||
return out;
|
||||
};
|
||||
|
||||
_applyNoTranslation(vector: Vector): Vector {
|
||||
return this.__applyNoTranslation(vector, vector);
|
||||
};
|
||||
|
||||
applyNoTranslation = vector => this.__applyNoTranslation(vector, new Vector());
|
||||
|
||||
_apply(vector: Vector): Vector {
|
||||
return this.__apply(vector, vector);
|
||||
};
|
||||
|
||||
__apply(vector: Vector, out: Vector): Vector {
|
||||
let x = vector.x;
|
||||
let y = vector.y;
|
||||
let z = vector.z;
|
||||
out.x = this.mxx * x + this.mxy * y + this.mxz * z + this.tx;
|
||||
out.y = this.myx * x + this.myy * y + this.myz * z + this.ty;
|
||||
out.z = this.mzx * x + this.mzy * y + this.mzz * z + this.tz;
|
||||
return out;
|
||||
};
|
||||
|
||||
apply3(data: Vec3): Vec3 {
|
||||
return this.__apply3(data, [0, 0, 0])
|
||||
};
|
||||
|
||||
_apply3(data: Vec3): Vec3 {
|
||||
return this.__apply3(data, data);
|
||||
};
|
||||
|
||||
__apply3([x, y, z]: Vec3, out: Vec3): Vec3 {
|
||||
out[0] = this.mxx * x + this.mxy * y + this.mxz * z + this.tx;
|
||||
out[1] = this.myx * x + this.myy * y + this.myz * z + this.ty;
|
||||
out[2] = this.mzx * x + this.mzy * y + this.mzz * z + this.tz;
|
||||
return out;
|
||||
};
|
||||
|
||||
rotateWithSphericalAxis(axisAzimuth: number, axisInclination: number, angle: number, pivot: Vector) {
|
||||
|
||||
const axis = new Vector(
|
||||
Math.sin(axisAzimuth) * Math.cos(axisInclination),
|
||||
Math.sin(axisAzimuth) * Math.sin(axisInclination),
|
||||
Math.cos(axisAzimuth)
|
||||
);
|
||||
|
||||
return Matrix3.rotateMatrix(angle, axis, pivot, this);
|
||||
};
|
||||
|
||||
rotate(angle: number, axis: Vector, pivot: Vector) {
|
||||
return Matrix3.rotateMatrix(angle, axis, pivot, this);
|
||||
};
|
||||
|
||||
static rotateMatrix(angle: number, axis: Vector, pivot: Vector, matrix?: Matrix3): Matrix3 {
|
||||
const sin = Math.sin(angle);
|
||||
const cos = Math.cos(angle);
|
||||
return Matrix3.rotationMatrix(cos, sin, axis, pivot, matrix);
|
||||
}
|
||||
|
||||
static rotationFromVectorToVector(from: Vector, to: Vector, pivot: Vector, matrix?: Matrix3): Matrix3 {
|
||||
|
||||
const axis = from.cross(to);
|
||||
|
||||
const cos = from.dot(to);
|
||||
const sin = axis.length();
|
||||
|
||||
return Matrix3.rotationMatrix(cos, sin, axis, pivot, matrix);
|
||||
|
||||
}
|
||||
|
||||
static rotationMatrix(cos: number, sin: number, axis: Vector, pivot: Vector, matrix?: Matrix3): Matrix3 {
|
||||
var axisX, axisY, axisZ;
|
||||
var m = matrix || new Matrix3();
|
||||
|
||||
if (axis === AXIS.X || axis === AXIS.Y || axis === AXIS.Z) {
|
||||
axisX = axis.x;
|
||||
axisY = axis.y;
|
||||
axisZ = axis.z;
|
||||
} else {
|
||||
// normalize
|
||||
var mag = axis.length();
|
||||
|
||||
if (mag == 0.0) {
|
||||
return m;
|
||||
} else {
|
||||
axisX = axis.x / mag;
|
||||
axisY = axis.y / mag;
|
||||
axisZ = axis.z / mag;
|
||||
}
|
||||
}
|
||||
|
||||
var px = pivot.x;
|
||||
var py = pivot.y;
|
||||
var pz = pivot.z;
|
||||
|
||||
m.mxx = cos + axisX * axisX * (1 - cos);
|
||||
m.mxy = axisX * axisY * (1 - cos) - axisZ * sin;
|
||||
m.mxz = axisX * axisZ * (1 - cos) + axisY * sin;
|
||||
|
||||
m.tx = px * (1 - m.mxx) - py * m.mxy - pz * m.mxz;
|
||||
|
||||
m.myx = axisY * axisX * (1 - cos) + axisZ * sin;
|
||||
m.myy = cos + axisY * axisY * (1 - cos);
|
||||
m.myz = axisY * axisZ * (1 - cos) - axisX * sin;
|
||||
m.ty = py * (1 - m.myy) - px * m.myx - pz * m.myz;
|
||||
|
||||
m.mzx = axisZ * axisX * (1 - cos) - axisY * sin;
|
||||
m.mzy = axisZ * axisY * (1 - cos) + axisX * sin;
|
||||
m.mzz = cos + axisZ * axisZ * (1 - cos);
|
||||
m.tz = pz * (1 - m.mzz) - px * m.mzx - py * m.mzy;
|
||||
return m;
|
||||
};
|
||||
|
||||
apply = vector => this.__apply(vector, new Vector());
|
||||
|
||||
setTranslation(tx, ty, tz) {
|
||||
this.tx = tx;
|
||||
this.ty = ty;
|
||||
this.tz = tz;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import * as test from '../../test'
|
||||
import {deepMerge} from '../coreTests/utils/deep-merge'
|
||||
import {Matrix3} from '../../../../modules/math/l3space'
|
||||
import {Matrix3} from "math/matrix";
|
||||
|
||||
const OPERANDS_MODE = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,12 +3,13 @@ import {Face} from './topo/face';
|
|||
import {Edge} from './topo/edge';
|
||||
import BrepCurve from './geom/curves/brepCurve';
|
||||
import {Plane} from './geom/impl/plane';
|
||||
import {BasisForPlane, Matrix3} from 'math/l3space';
|
||||
import {BasisForPlane} from 'math/l3space';
|
||||
import * as cad_utils from '../cad/cad-utils';
|
||||
import * as math from '../math/math';
|
||||
import {createBoundingSurface} from './brep-builder';
|
||||
import NurbsSurface from './geom/surfaces/nurbsSurface';
|
||||
import {BrepSurface} from './geom/surfaces/brepSurface';
|
||||
import {Matrix3} from 'math/matrix';
|
||||
|
||||
function isCCW(points, normal) {
|
||||
const tr2d = new Matrix3().setBasis(BasisForPlane(normal)).invert();
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import {Point} from './geom/point'
|
||||
import {Plane} from './geom/impl/plane'
|
||||
import {createPrism, enclose} from './brep-enclose'
|
||||
import {AXIS, Matrix3} from 'math/l3space'
|
||||
import {AXIS} from 'math/l3space'
|
||||
import {Circle} from '../cad/sketch/sketchModel'
|
||||
import CSys from 'math/csys';
|
||||
import {Matrix3} from 'math/matrix';
|
||||
|
||||
export function box(w, h, d, tr) {
|
||||
const wh = w * 0.5;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import BoundedCurve from './boundedCurve';
|
|||
import InvertedCurve from './invertedCurve';
|
||||
import {ParametricSurface} from "../surfaces/parametricSurface";
|
||||
import {ParametricCurve} from "./parametricCurve";
|
||||
import {Matrix3x4Data} from "math/l3space";
|
||||
import {Matrix3x4Data} from "math/matrix";
|
||||
|
||||
export class IsoCurveU implements ParametricCurve {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import InvertedCurve from './invertedCurve';
|
||||
import {ParametricCurve} from "./parametricCurve";
|
||||
import {Matrix3x4Data} from "math/l3space";
|
||||
import {Matrix3x4Data} from "math/matrix";
|
||||
|
||||
export default class BoundedCurve implements ParametricCurve {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import NurbsCurve from "./nurbsCurve";
|
||||
import {Matrix3, Vec3} from 'math/l3space'
|
||||
import {Vec3} from 'math/l3space'
|
||||
import {areEqual} from '../../../math/math'
|
||||
|
||||
import {eqSqTol, ueq, veq, veq3, veqNeg} from "../tolerance";
|
||||
|
|
@ -9,6 +9,7 @@ import Point from 'math/vector';
|
|||
import Vector from 'math/vector';
|
||||
import cache from "../impl/cache";
|
||||
import {Tessellation1D} from "../../../cad/craft/engine/tessellation";
|
||||
import {Matrix3} from "math/matrix";
|
||||
|
||||
export default class BrepCurve {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import * as ext from '../impl/nurbs-ext';
|
||||
import {distinctKnots, NurbsCurveData} from '../impl/nurbs-ext';
|
||||
import {ParametricCurve} from "./parametricCurve";
|
||||
import {Matrix3x4Data, Vec3} from "math/l3space";
|
||||
import {Vec3} from "math/l3space";
|
||||
import {Matrix3x4Data} from "math/matrix";
|
||||
|
||||
|
||||
//in fact the sketcher format
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import {Matrix3x4Data, Vec3} from "math/l3space";
|
||||
import {Vec3} from "math/l3space";
|
||||
import {Matrix3x4Data} from "math/matrix";
|
||||
|
||||
export interface ParametricCurve {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import {Point} from '../point';
|
||||
import {Line} from './line';
|
||||
import {AXIS, BasisForPlane, Matrix3} from '../../../../../modules/math/l3space';
|
||||
import {AXIS, BasisForPlane} from '../../../../../modules/math/l3space';
|
||||
import {eqTol, veq} from '../tolerance';
|
||||
import {Matrix3} from "math/matrix";
|
||||
|
||||
|
||||
export class Plane {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import {ParametricSurface, UV} from "./parametricSurface";
|
||||
import {Matrix3x4Data, Vec3} from "math/l3space";
|
||||
import {Vec3} from "math/l3space";
|
||||
import {Matrix3x4Data} from "math/matrix";
|
||||
|
||||
export default class NullSurface implements ParametricSurface {
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@ import cache from '../impl/cache';
|
|||
import * as ext from '../impl/nurbs-ext';
|
||||
import NurbsCurve from '../curves/nurbsCurve';
|
||||
import {ParametricSurface, UV} from "./parametricSurface";
|
||||
import {Matrix3x4Data, Vec3} from "math/l3space";
|
||||
import {Vec3} from "math/l3space";
|
||||
import {ParametricCurve} from "../curves/parametricCurve";
|
||||
import {Matrix3x4Data} from "math/matrix";
|
||||
|
||||
export default class NurbsSurface implements ParametricSurface {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import {Matrix3x4Data, Vec3} from "math/l3space";
|
||||
import {Vec3} from "math/l3space";
|
||||
import {Matrix3x4Data} from "math/matrix";
|
||||
|
||||
export type UV = [number, number];
|
||||
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ import {SolveStatus} from "../../sketcher/constr/AlgNumSystem";
|
|||
import {MShell} from "../model/mshell";
|
||||
import {MObject} from "../model/mobject";
|
||||
import {CadRegistry} from "../craft/cadRegistryPlugin";
|
||||
import {Matrix3} from "math/l3space";
|
||||
import {AssemblyConstraint, AssemblyConstraintDefinition} from "./assemblyConstraint";
|
||||
import {AssemblyConstraintsSchemas} from "./assemblySchemas";
|
||||
import {dfs} from "gems/traverse";
|
||||
import {SixDOF} from "./dof/sixDOF";
|
||||
import {AssemblyDOF} from "./dof/assemblyDOF";
|
||||
import {Matrix3} from "math/matrix";
|
||||
|
||||
declare module '../model/mshell' {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import {Matrix3, ORIGIN} from "math/l3space";
|
||||
import {ORIGIN} from "math/l3space";
|
||||
import Vector from "math/vector";
|
||||
import {eqTol} from "../../../brep/geom/tolerance";
|
||||
import {FaceTouchAlignConstraint} from "../constraints/faceTouchAlign";
|
||||
|
|
@ -10,6 +10,7 @@ import {PPPPDOF} from "./PPPPDOF";
|
|||
import {EdgeAlignConstraint} from "../constraints/edgeAlign";
|
||||
import {PPEEDOF} from "./PPEEDOF";
|
||||
import {EEEEDOF} from "./EEEEDOF";
|
||||
import {Matrix3} from "math/matrix";
|
||||
|
||||
const ANGULAR_ALLOWANCE = 10 * DEG_RAD;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { Matrix3 } from "math/l3space";
|
||||
import Vector from "math/vector";
|
||||
import { FaceTouchAlignConstraint } from "../constraints/faceTouchAlign";
|
||||
import { Plane } from './../../../brep/geom/impl/plane';
|
||||
import { AssemblyDOF, ModificationResponse } from "./assemblyDOF";
|
||||
import { ConflictDOF } from './conflictDOF';
|
||||
import {EdgeAlignConstraint} from "../constraints/edgeAlign";
|
||||
import {Matrix3} from "math/matrix";
|
||||
|
||||
export class EEEEDOF implements AssemblyDOF {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import {Matrix3, ORIGIN} from "math/l3space";
|
||||
import {ORIGIN} from "math/l3space";
|
||||
import Vector from "math/vector";
|
||||
import {eqTol} from "../../../brep/geom/tolerance";
|
||||
import {FaceTouchAlignConstraint} from "../constraints/faceTouchAlign";
|
||||
|
|
@ -8,6 +8,7 @@ import {areEqual, clamp, DEG_RAD} from "../../../math/math";
|
|||
import {ConflictDOF} from "./conflictDOF";
|
||||
import {PPPPDOF} from "./PPPPDOF";
|
||||
import {EdgeAlignConstraint} from "../constraints/edgeAlign";
|
||||
import {Matrix3} from "math/matrix";
|
||||
|
||||
export class PPDOF implements AssemblyDOF {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { Matrix3 } from "math/l3space";
|
||||
import Vector from "math/vector";
|
||||
import { FaceTouchAlignConstraint } from "../constraints/faceTouchAlign";
|
||||
import { Plane } from './../../../brep/geom/impl/plane';
|
||||
import { AssemblyDOF, ModificationResponse } from "./assemblyDOF";
|
||||
import { ConflictDOF } from './conflictDOF';
|
||||
import {EdgeAlignConstraint} from "../constraints/edgeAlign";
|
||||
import {Matrix3} from "math/matrix";
|
||||
|
||||
export class PPEEDOF implements AssemblyDOF {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { Matrix3 } from "math/l3space";
|
||||
import Vector from "math/vector";
|
||||
import { FaceTouchAlignConstraint } from "../constraints/faceTouchAlign";
|
||||
import { Plane } from './../../../brep/geom/impl/plane';
|
||||
import { AssemblyDOF, ModificationResponse } from "./assemblyDOF";
|
||||
import { ConflictDOF } from './conflictDOF';
|
||||
import {EdgeAlignConstraint} from "../constraints/edgeAlign";
|
||||
import {Matrix3} from "math/matrix";
|
||||
|
||||
export class PPPPDOF implements AssemblyDOF {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import Vector from "math/vector";
|
||||
import {Matrix3} from "math/l3space";
|
||||
import {FaceTouchAlignConstraint} from "../constraints/faceTouchAlign";
|
||||
import {EdgeAlignConstraint} from "../constraints/edgeAlign";
|
||||
import {DEG_RAD} from "../../../math/math";
|
||||
import {Matrix3} from "math/matrix";
|
||||
|
||||
export const ANGULAR_ALLOWANCE = 10 * DEG_RAD;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
|
||||
import { Matrix3 } from "math/l3space";
|
||||
import Vector from "math/vector";
|
||||
import { AssemblyConstraint } from '../assemblyConstraint';
|
||||
import { FaceTouchAlignConstraint } from "../constraints/faceTouchAlign";
|
||||
import { AssemblyDOF, ModificationResponse } from "./assemblyDOF";
|
||||
import {EdgeAlignConstraint} from "../constraints/edgeAlign";
|
||||
import {Matrix3} from "math/matrix";
|
||||
|
||||
export class ConflictDOF implements AssemblyDOF {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
import { Plane } from './../../../brep/geom/impl/plane';
|
||||
import {AssemblyDOF, ModificationResponse} from "./assemblyDOF";
|
||||
import Vector from "math/vector";
|
||||
import {Matrix3, ORIGIN} from "math/l3space";
|
||||
import {ORIGIN} from "math/l3space";
|
||||
import {FaceTouchAlignConstraint} from "../constraints/faceTouchAlign";
|
||||
import {PPDOF} from "./PPDOF";
|
||||
import {EdgeAlignConstraint} from "../constraints/edgeAlign";
|
||||
import {EEDOF} from "./EEDOF";
|
||||
import {Matrix3} from "math/matrix";
|
||||
|
||||
export class SixDOF implements AssemblyDOF {
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import {AssemblyProcess} from "../assemblySolver";
|
|||
import {useStream} from "ui/effects";
|
||||
import {MShell} from "../../model/mshell";
|
||||
import CSys from "math/csys";
|
||||
import {Matrix3} from "math/l3space";
|
||||
import {Matrix3} from "math/matrix";
|
||||
|
||||
export function StepByStepSimulation() {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
import Vector from 'math/vector';
|
||||
import BBox from '../math/bbox'
|
||||
import {HashTable} from '../utils/hashmap'
|
||||
import {Graph} from '../math/graph'
|
||||
import * as math from '../math/math'
|
||||
import {Matrix3, AXIS, ORIGIN} from '../../../modules/math/l3space'
|
||||
import {MeshSceneSolid} from './scene/wrappers/meshSceneObject'
|
||||
import {Matrix3} from 'math/matrix';
|
||||
|
||||
export const FACE_COLOR = 0xB0C4DE;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import {Matrix3} from '../../../../../modules/math/l3space'
|
||||
import * as math from '../../../math/math'
|
||||
import {enclose} from '../../../brep/brep-enclose'
|
||||
import {BooleanOperation, combineShells} from '../booleanOperation'
|
||||
import {Matrix3} from 'math/matrix';
|
||||
|
||||
|
||||
export function Extrude(params, ctx) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import schema from './rotateDatumOpSchema';
|
||||
import {MDatum} from '../../../model/mdatum';
|
||||
import RotateDatumWizard from './RotateDatumWizard';
|
||||
import {Matrix3, ORIGIN} from '../../../../../../modules/math/l3space';
|
||||
import {ORIGIN} from '../../../../../../modules/math/l3space';
|
||||
import {DEG_RAD} from '../../../../math/math';
|
||||
import {Matrix3} from "../../../../../../modules/math/matrix";
|
||||
|
||||
|
||||
function rotate(params, {cadRegistry}) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import {Matrix3} from '../../../../../modules/math/l3space'
|
||||
import Vector from 'math/vector';
|
||||
import * as math from '../../../math/math'
|
||||
import {createShared} from '../../cad-utils'
|
||||
import {TriangulatePolygons} from '../../tess/triangulation';
|
||||
import {Matrix3} from "../../../../../modules/math/matrix";
|
||||
|
||||
function Group(derivedFrom) {
|
||||
this.polygons = [];
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@ import * as tk from '../../../../ui/toolkit.js'
|
|||
import * as workbench from '../workbench'
|
||||
import * as cad_utils from '../../../cad-utils'
|
||||
import Vector from 'math/vector';
|
||||
import {Matrix3, ORIGIN} from '../../../../../../modules/math/l3space'
|
||||
import {ORIGIN} from '../../../../../../modules/math/l3space'
|
||||
import {OpWizard, IMAGINE_MATERIAL, BASE_MATERIAL} from './wizard-commons'
|
||||
import {Matrix3} from 'math/matrix';
|
||||
|
||||
export function ExtrudeWizard(app, face, invert, initParams) {
|
||||
this.invert = invert; // title depends on invert flag
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import {AXIS, IDENTITY_BASIS} from '../../../../../../modules/math/l3space'
|
||||
import {AXIS, IDENTITY_BASIS} from 'math/l3space'
|
||||
import * as tk from '../../../../ui/toolkit.js'
|
||||
import {FACE_COLOR} from '../../../cad-utils'
|
||||
import {Wizard} from './wizard-commons'
|
||||
import {Matrix3} from '../../../../../../modules/math/l3space'
|
||||
|
||||
export function PlaneWizard(app, initParams) {
|
||||
Wizard.call(this, app.viewer, initParams);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
import * as tk from '../../../../ui/toolkit.js'
|
||||
import * as workbench from '../workbench'
|
||||
import * as cad_utils from '../../../cad-utils'
|
||||
import Vector from 'math/vector';
|
||||
import {Matrix3, ORIGIN} from '../../../../../../modules/math/l3space'
|
||||
import {revolveToTriangles} from '../revolve'
|
||||
import {OpWizard, IMAGINARY_SURFACE_MATERIAL, } from './wizard-commons'
|
||||
import {IMAGINARY_SURFACE_MATERIAL, OpWizard,} from './wizard-commons'
|
||||
|
||||
export function RevolveWizard(app, face, initParams) {
|
||||
if (face.sketch3DGroup == null) app.refreshSketchOnFace(face);
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ import Label from "ui/components/controls/Label";
|
|||
import Folder from "ui/components/Folder";
|
||||
import {never} from "lstream";
|
||||
import NumberControl from "ui/components/controls/NumberControl";
|
||||
import {Matrix3} from "math/l3space";
|
||||
|
||||
import {LocationControl} from "./LocationControl";
|
||||
import {Matrix3} from "math/matrix";
|
||||
|
||||
export function LocationDialog() {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import Vector from "math/vector";
|
||||
import {Matrix3} from "math/l3space";
|
||||
import {Matrix3} from "math/matrix";
|
||||
|
||||
export class Location {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import {MObject, MObjectIdGenerator, MRootObject} from './mobject';
|
||||
import CSys from "math/csys";
|
||||
import Vector from "math/vector";
|
||||
import {Matrix3} from "math/l3space";
|
||||
import {Matrix3} from "math/matrix";
|
||||
|
||||
export class MDatum extends MObject {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import {AssemblyNode} from "../assembly/assembly";
|
||||
import {IDENTITY_MATRIX, Matrix3} from "math/l3space";
|
||||
import {IDENTITY_MATRIX} from "math/l3space";
|
||||
import {Matrix3} from "math/matrix";
|
||||
|
||||
export abstract class MObject {
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ import {MBrepFace} from './mface';
|
|||
import {MEdge} from './medge';
|
||||
import {MVertex} from './mvertex';
|
||||
import CSys from 'math/csys';
|
||||
import {Matrix3} from "math/l3space";
|
||||
import {state, StateStream} from "lstream";
|
||||
import {Matrix3} from "math/matrix";
|
||||
|
||||
export class MShell extends MObject {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,12 @@
|
|||
import {AXIS, Matrix3, ORIGIN} from '../../../modules/math/l3space'
|
||||
import * as vec from 'math/vec'
|
||||
import Vector from 'math/vector';
|
||||
import {AXIS, ORIGIN} from '../../../modules/math/l3space'
|
||||
import BrepBuilder from '../brep/brep-builder'
|
||||
import * as BREPPrimitives from '../brep/brep-primitives'
|
||||
import BrepCurve from '../brep/geom/curves/brepCurve';
|
||||
import NurbsCurve from "../brep/geom/curves/nurbsCurve";
|
||||
import {surfaceIntersect} from '../brep/geom/intersection/surfaceSurface';
|
||||
import {closestToCurveParam} from '../brep/geom/curves/closestPoint';
|
||||
import NurbsSurface from '../brep/geom/surfaces/nurbsSurface';
|
||||
import DatumObject3D from './craft/datum/datumObject';
|
||||
import CSys from '../../../modules/math/csys';
|
||||
import {createOctreeFromSurface, sphereOctree, traverseOctree} from "../../../modules/voxels/octree";
|
||||
import {createOctreeFromSurface, traverseOctree} from "../../../modules/voxels/octree";
|
||||
import {Matrix3} from 'math/matrix';
|
||||
|
||||
export function runSandbox({bus, services, services: { viewer, cadScene, cadRegistry, exposure, exposure: {addShellOnScene} }}) {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
import * as sm from './sketchModel'
|
||||
import {Matrix3, AXIS, ORIGIN} from '../../../../modules/math/l3space'
|
||||
import Vector from 'math/vector';
|
||||
import {Graph} from '../../math/graph'
|
||||
import * as math from '../../math/math'
|
||||
import {HashTable} from '../../utils/hashmap'
|
||||
import {Constraints} from '../../sketcher/parametric';
|
||||
import Joints from '../../../../modules/gems/joints';
|
||||
import sketchObjectGlobalId from './sketchObjectGlobalId';
|
||||
import VectorFactory from '../../../../modules/math/vectorFactory';
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import {BasisOrigin} from './shapes/basis-origin';
|
|||
import Vector from 'math/vector';
|
||||
|
||||
import * as draw_utils from './shapes/draw-utils';
|
||||
import {Matrix3} from 'math/l3space';
|
||||
import sketcherStreams, {SketcherStreams} from './sketcherStreams';
|
||||
import {BBox, IO} from "./io";
|
||||
import {NOOP} from "../../../modules/gems/func";
|
||||
|
|
@ -20,6 +19,7 @@ import {Dimension} from "./shapes/dim";
|
|||
import {GroundObjectsGeneratorSchema} from "./generators/groundObjectsGenerator";
|
||||
import {SketchGenerator} from "./generators/sketchGenerator";
|
||||
import {Generator} from "./id-generator";
|
||||
import {Matrix3} from "math/matrix";
|
||||
|
||||
export class Viewer {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue