diff --git a/modules/math/csys.ts b/modules/math/csys.ts index f6f16291..ad938bc8 100644 --- a/modules/math/csys.ts +++ b/modules/math/csys.ts @@ -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 { diff --git a/modules/math/l3space.ts b/modules/math/l3space.ts index 45452b6a..6cb355df 100644 --- a/modules/math/l3space.ts +++ b/modules/math/l3space.ts @@ -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; diff --git a/modules/math/matrix.ts b/modules/math/matrix.ts new file mode 100644 index 00000000..ed0bafee --- /dev/null +++ b/modules/math/matrix.ts @@ -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; + } + +} \ No newline at end of file diff --git a/test/coreTests/testCases/legacy/brep-bool.js b/test/coreTests/testCases/legacy/brep-bool.js index 594d8f9f..92a0e6ba 100644 --- a/test/coreTests/testCases/legacy/brep-bool.js +++ b/test/coreTests/testCases/legacy/brep-bool.js @@ -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; diff --git a/web/app/brep/brep-enclose.js b/web/app/brep/brep-enclose.js index 63cbc2b3..e72b8baa 100644 --- a/web/app/brep/brep-enclose.js +++ b/web/app/brep/brep-enclose.js @@ -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(); diff --git a/web/app/brep/brep-primitives.js b/web/app/brep/brep-primitives.js index 29996701..e6ef39ce 100644 --- a/web/app/brep/brep-primitives.js +++ b/web/app/brep/brep-primitives.js @@ -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; diff --git a/web/app/brep/geom/curves/IsoCurve.ts b/web/app/brep/geom/curves/IsoCurve.ts index 2312e34c..62aa63bf 100644 --- a/web/app/brep/geom/curves/IsoCurve.ts +++ b/web/app/brep/geom/curves/IsoCurve.ts @@ -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 { diff --git a/web/app/brep/geom/curves/boundedCurve.ts b/web/app/brep/geom/curves/boundedCurve.ts index 12a2a3a1..29229836 100644 --- a/web/app/brep/geom/curves/boundedCurve.ts +++ b/web/app/brep/geom/curves/boundedCurve.ts @@ -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 { diff --git a/web/app/brep/geom/curves/brepCurve.ts b/web/app/brep/geom/curves/brepCurve.ts index 049a44e5..c8a65afb 100644 --- a/web/app/brep/geom/curves/brepCurve.ts +++ b/web/app/brep/geom/curves/brepCurve.ts @@ -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 { diff --git a/web/app/brep/geom/curves/nurbsCurve.ts b/web/app/brep/geom/curves/nurbsCurve.ts index 8643f8ed..bb362d6f 100644 --- a/web/app/brep/geom/curves/nurbsCurve.ts +++ b/web/app/brep/geom/curves/nurbsCurve.ts @@ -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 diff --git a/web/app/brep/geom/curves/parametricCurve.ts b/web/app/brep/geom/curves/parametricCurve.ts index 780e3723..d29aa306 100644 --- a/web/app/brep/geom/curves/parametricCurve.ts +++ b/web/app/brep/geom/curves/parametricCurve.ts @@ -1,4 +1,5 @@ -import {Matrix3x4Data, Vec3} from "math/l3space"; +import {Vec3} from "math/l3space"; +import {Matrix3x4Data} from "math/matrix"; export interface ParametricCurve { diff --git a/web/app/brep/geom/impl/plane.ts b/web/app/brep/geom/impl/plane.ts index fa1e2c56..b3b48679 100644 --- a/web/app/brep/geom/impl/plane.ts +++ b/web/app/brep/geom/impl/plane.ts @@ -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 { diff --git a/web/app/brep/geom/surfaces/nullSurface.ts b/web/app/brep/geom/surfaces/nullSurface.ts index 266b39e1..7c6daf0d 100644 --- a/web/app/brep/geom/surfaces/nullSurface.ts +++ b/web/app/brep/geom/surfaces/nullSurface.ts @@ -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 { diff --git a/web/app/brep/geom/surfaces/nurbsSurface.ts b/web/app/brep/geom/surfaces/nurbsSurface.ts index 8a95e74a..f131e91b 100644 --- a/web/app/brep/geom/surfaces/nurbsSurface.ts +++ b/web/app/brep/geom/surfaces/nurbsSurface.ts @@ -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 { diff --git a/web/app/brep/geom/surfaces/parametricSurface.ts b/web/app/brep/geom/surfaces/parametricSurface.ts index c76518ff..96612d11 100644 --- a/web/app/brep/geom/surfaces/parametricSurface.ts +++ b/web/app/brep/geom/surfaces/parametricSurface.ts @@ -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]; diff --git a/web/app/cad/assembly/assemblySolver.ts b/web/app/cad/assembly/assemblySolver.ts index dfd666fa..2f22462e 100644 --- a/web/app/cad/assembly/assemblySolver.ts +++ b/web/app/cad/assembly/assemblySolver.ts @@ -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' { diff --git a/web/app/cad/assembly/dof/EEDOF.ts b/web/app/cad/assembly/dof/EEDOF.ts index f2fc170f..a1d1e52a 100644 --- a/web/app/cad/assembly/dof/EEDOF.ts +++ b/web/app/cad/assembly/dof/EEDOF.ts @@ -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; diff --git a/web/app/cad/assembly/dof/EEEEDOF.ts b/web/app/cad/assembly/dof/EEEEDOF.ts index 89c1e7f1..73641361 100644 --- a/web/app/cad/assembly/dof/EEEEDOF.ts +++ b/web/app/cad/assembly/dof/EEEEDOF.ts @@ -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 { diff --git a/web/app/cad/assembly/dof/PPDOF.ts b/web/app/cad/assembly/dof/PPDOF.ts index fff8b379..7de9a2f3 100644 --- a/web/app/cad/assembly/dof/PPDOF.ts +++ b/web/app/cad/assembly/dof/PPDOF.ts @@ -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 { diff --git a/web/app/cad/assembly/dof/PPEEDOF.ts b/web/app/cad/assembly/dof/PPEEDOF.ts index fed55ed7..ceaa4fdf 100644 --- a/web/app/cad/assembly/dof/PPEEDOF.ts +++ b/web/app/cad/assembly/dof/PPEEDOF.ts @@ -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 { diff --git a/web/app/cad/assembly/dof/PPPPDOF.ts b/web/app/cad/assembly/dof/PPPPDOF.ts index 2d609a19..cdc146c3 100644 --- a/web/app/cad/assembly/dof/PPPPDOF.ts +++ b/web/app/cad/assembly/dof/PPPPDOF.ts @@ -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 { diff --git a/web/app/cad/assembly/dof/assemblyDOF.ts b/web/app/cad/assembly/dof/assemblyDOF.ts index ab42acb2..154930b1 100644 --- a/web/app/cad/assembly/dof/assemblyDOF.ts +++ b/web/app/cad/assembly/dof/assemblyDOF.ts @@ -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; diff --git a/web/app/cad/assembly/dof/conflictDOF.ts b/web/app/cad/assembly/dof/conflictDOF.ts index e9eda224..3e56789b 100644 --- a/web/app/cad/assembly/dof/conflictDOF.ts +++ b/web/app/cad/assembly/dof/conflictDOF.ts @@ -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 { diff --git a/web/app/cad/assembly/dof/sixDOF.ts b/web/app/cad/assembly/dof/sixDOF.ts index cf027653..498b8525 100644 --- a/web/app/cad/assembly/dof/sixDOF.ts +++ b/web/app/cad/assembly/dof/sixDOF.ts @@ -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 { diff --git a/web/app/cad/assembly/ui/StepByStepSimulation.tsx b/web/app/cad/assembly/ui/StepByStepSimulation.tsx index b86cc6a0..438e9100 100644 --- a/web/app/cad/assembly/ui/StepByStepSimulation.tsx +++ b/web/app/cad/assembly/ui/StepByStepSimulation.tsx @@ -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() { diff --git a/web/app/cad/cad-utils.js b/web/app/cad/cad-utils.js index bee31e11..7ac57d02 100644 --- a/web/app/cad/cad-utils.js +++ b/web/app/cad/cad-utils.js @@ -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; diff --git a/web/app/cad/craft/cutExtrude/cutExtrude.js b/web/app/cad/craft/cutExtrude/cutExtrude.js index 0acbd44e..ce23cdda 100644 --- a/web/app/cad/craft/cutExtrude/cutExtrude.js +++ b/web/app/cad/craft/cutExtrude/cutExtrude.js @@ -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) { diff --git a/web/app/cad/craft/datum/rotate/rotateDatumOperation.js b/web/app/cad/craft/datum/rotate/rotateDatumOperation.js index 7cbff395..de682573 100644 --- a/web/app/cad/craft/datum/rotate/rotateDatumOperation.js +++ b/web/app/cad/craft/datum/rotate/rotateDatumOperation.js @@ -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}) { diff --git a/web/app/cad/legacy/mesh/revolve.js b/web/app/cad/legacy/mesh/revolve.js index a0eb7bec..cd8dce36 100644 --- a/web/app/cad/legacy/mesh/revolve.js +++ b/web/app/cad/legacy/mesh/revolve.js @@ -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 = []; diff --git a/web/app/cad/legacy/mesh/wizards/extrude.js b/web/app/cad/legacy/mesh/wizards/extrude.js index 79566f34..9295dcae 100644 --- a/web/app/cad/legacy/mesh/wizards/extrude.js +++ b/web/app/cad/legacy/mesh/wizards/extrude.js @@ -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 diff --git a/web/app/cad/legacy/mesh/wizards/plane.js b/web/app/cad/legacy/mesh/wizards/plane.js index 3fad1d3a..bd9ae452 100644 --- a/web/app/cad/legacy/mesh/wizards/plane.js +++ b/web/app/cad/legacy/mesh/wizards/plane.js @@ -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); diff --git a/web/app/cad/legacy/mesh/wizards/revolve.js b/web/app/cad/legacy/mesh/wizards/revolve.js index dc1097e8..1d5a3978 100644 --- a/web/app/cad/legacy/mesh/wizards/revolve.js +++ b/web/app/cad/legacy/mesh/wizards/revolve.js @@ -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); diff --git a/web/app/cad/location/LocationDialog.tsx b/web/app/cad/location/LocationDialog.tsx index 04e7de3e..ee62a53e 100644 --- a/web/app/cad/location/LocationDialog.tsx +++ b/web/app/cad/location/LocationDialog.tsx @@ -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() { diff --git a/web/app/cad/model/location.ts b/web/app/cad/model/location.ts index 7565d7ca..a0fbf8cd 100644 --- a/web/app/cad/model/location.ts +++ b/web/app/cad/model/location.ts @@ -1,5 +1,5 @@ import Vector from "math/vector"; -import {Matrix3} from "math/l3space"; +import {Matrix3} from "math/matrix"; export class Location { diff --git a/web/app/cad/model/mdatum.ts b/web/app/cad/model/mdatum.ts index f585c92b..ef3c2e63 100644 --- a/web/app/cad/model/mdatum.ts +++ b/web/app/cad/model/mdatum.ts @@ -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 { diff --git a/web/app/cad/model/mobject.ts b/web/app/cad/model/mobject.ts index e81f9d7c..406f8362 100644 --- a/web/app/cad/model/mobject.ts +++ b/web/app/cad/model/mobject.ts @@ -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 { diff --git a/web/app/cad/model/mshell.ts b/web/app/cad/model/mshell.ts index 51b13957..2c5c2dec 100644 --- a/web/app/cad/model/mshell.ts +++ b/web/app/cad/model/mshell.ts @@ -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 { diff --git a/web/app/cad/sandbox.js b/web/app/cad/sandbox.js index 82d96bfd..cd007362 100644 --- a/web/app/cad/sandbox.js +++ b/web/app/cad/sandbox.js @@ -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} }}) { diff --git a/web/app/cad/sketch/sketchReader.js b/web/app/cad/sketch/sketchReader.js index a285c973..6dda629d 100644 --- a/web/app/cad/sketch/sketchReader.js +++ b/web/app/cad/sketch/sketchReader.js @@ -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'; diff --git a/web/app/sketcher/viewer2d.ts b/web/app/sketcher/viewer2d.ts index ea3ba761..789b1ba1 100644 --- a/web/app/sketcher/viewer2d.ts +++ b/web/app/sketcher/viewer2d.ts @@ -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 {