From 0070e9e4468de548a02d5bb30a1783c2a2450e54 Mon Sep 17 00:00:00 2001 From: z3dev Date: Sun, 10 Nov 2024 10:17:17 +0900 Subject: [PATCH] style(modeling): removed unused untested functions from OrthoNormalBasis --- .../modeling/src/maths/OrthoNormalBasis.js | 152 ------------------ 1 file changed, 152 deletions(-) diff --git a/packages/modeling/src/maths/OrthoNormalBasis.js b/packages/modeling/src/maths/OrthoNormalBasis.js index 04f671bdd..a794a0b2e 100644 --- a/packages/modeling/src/maths/OrthoNormalBasis.js +++ b/packages/modeling/src/maths/OrthoNormalBasis.js @@ -21,130 +21,6 @@ const OrthoNormalBasis = function (plane, rightvector) { this.planeorigin = vec3.scale(vec3.create(), plane, plane[3]) } -// Get an orthonormal basis for the standard XYZ planes. -// Parameters: the names of two 3D axes. The 2d x axis will map to the first given 3D axis, the 2d y -// axis will map to the second. -// Prepend the axis with a "-" to invert the direction of this axis. -// For example: OrthoNormalBasis.GetCartesian("-Y","Z") -// will return an orthonormal basis where the 2d X axis maps to the 3D inverted Y axis, and -// the 2d Y axis maps to the 3D Z axis. -OrthoNormalBasis.GetCartesian = function (xaxisid, yaxisid) { - const axisid = xaxisid + '/' + yaxisid - let planenormal, rightvector - if (axisid === 'X/Y') { - planenormal = [0, 0, 1] - rightvector = [1, 0, 0] - } else if (axisid === 'Y/-X') { - planenormal = [0, 0, 1] - rightvector = [0, 1, 0] - } else if (axisid === '-X/-Y') { - planenormal = [0, 0, 1] - rightvector = [-1, 0, 0] - } else if (axisid === '-Y/X') { - planenormal = [0, 0, 1] - rightvector = [0, -1, 0] - } else if (axisid === '-X/Y') { - planenormal = [0, 0, -1] - rightvector = [-1, 0, 0] - } else if (axisid === '-Y/-X') { - planenormal = [0, 0, -1] - rightvector = [0, -1, 0] - } else if (axisid === 'X/-Y') { - planenormal = [0, 0, -1] - rightvector = [1, 0, 0] - } else if (axisid === 'Y/X') { - planenormal = [0, 0, -1] - rightvector = [0, 1, 0] - } else if (axisid === 'X/Z') { - planenormal = [0, -1, 0] - rightvector = [1, 0, 0] - } else if (axisid === 'Z/-X') { - planenormal = [0, -1, 0] - rightvector = [0, 0, 1] - } else if (axisid === '-X/-Z') { - planenormal = [0, -1, 0] - rightvector = [-1, 0, 0] - } else if (axisid === '-Z/X') { - planenormal = [0, -1, 0] - rightvector = [0, 0, -1] - } else if (axisid === '-X/Z') { - planenormal = [0, 1, 0] - rightvector = [-1, 0, 0] - } else if (axisid === '-Z/-X') { - planenormal = [0, 1, 0] - rightvector = [0, 0, -1] - } else if (axisid === 'X/-Z') { - planenormal = [0, 1, 0] - rightvector = [1, 0, 0] - } else if (axisid === 'Z/X') { - planenormal = [0, 1, 0] - rightvector = [0, 0, 1] - } else if (axisid === 'Y/Z') { - planenormal = [1, 0, 0] - rightvector = [0, 1, 0] - } else if (axisid === 'Z/-Y') { - planenormal = [1, 0, 0] - rightvector = [0, 0, 1] - } else if (axisid === '-Y/-Z') { - planenormal = [1, 0, 0] - rightvector = [0, -1, 0] - } else if (axisid === '-Z/Y') { - planenormal = [1, 0, 0] - rightvector = [0, 0, -1] - } else if (axisid === '-Y/Z') { - planenormal = [-1, 0, 0] - rightvector = [0, -1, 0] - } else if (axisid === '-Z/-Y') { - planenormal = [-1, 0, 0] - rightvector = [0, 0, -1] - } else if (axisid === 'Y/-Z') { - planenormal = [-1, 0, 0] - rightvector = [0, 1, 0] - } else if (axisid === 'Z/Y') { - planenormal = [-1, 0, 0] - rightvector = [0, 0, 1] - } else { - throw new Error('OrthoNormalBasis.GetCartesian: invalid combination of axis identifiers. Should pass two string arguments from [X,Y,Z,-X,-Y,-Z], being two different axes.') - } - // return new OrthoNormalBasis(new Plane(new Vector3D(planenormal), 0), new Vector3D(rightvector)) -} - -/* -// test code for OrthoNormalBasis.GetCartesian() -OrthoNormalBasis.GetCartesian_Test=function() { - let axisnames=["X","Y","Z","-X","-Y","-Z"]; - let axisvectors=[[1,0,0], [0,1,0], [0,0,1], [-1,0,0], [0,-1,0], [0,0,-1]]; - for(let axis1=0; axis1 < 3; axis1++) { - for(let axis1inverted=0; axis1inverted < 2; axis1inverted++) { - let axis1name=axisnames[axis1+3*axis1inverted]; - let axis1vector=axisvectors[axis1+3*axis1inverted]; - for(let axis2=0; axis2 < 3; axis2++) { - if(axis2 != axis1) { - for(let axis2inverted=0; axis2inverted < 2; axis2inverted++) { - let axis2name=axisnames[axis2+3*axis2inverted]; - let axis2vector=axisvectors[axis2+3*axis2inverted]; - let orthobasis=OrthoNormalBasis.GetCartesian(axis1name, axis2name); - let test1=orthobasis.to3D(new Vector2D([1,0])); - let test2=orthobasis.to3D(new Vector2D([0,1])); - let expected1=new Vector3D(axis1vector); - let expected2=new Vector3D(axis2vector); - let d1=test1.distanceTo(expected1); - let d2=test2.distanceTo(expected2); - if( (d1 > 0.01) || (d2 > 0.01) ) { - throw new Error("Wrong!"); - }}}}}} - throw new Error("OK"); -}; -*/ - -/* -// The z=0 plane, with the 3D x and y vectors mapped to the 2D x and y vector -OrthoNormalBasis.Z0Plane = function () { - const plane = new Plane(new Vector3D([0, 0, 1]), 0) - return new OrthoNormalBasis(plane, new Vector3D([1, 0, 0])) -} -*/ - OrthoNormalBasis.prototype = { getProjectionMatrix: function () { @@ -178,34 +54,6 @@ OrthoNormalBasis.prototype = { const v4 = vec3.add(v2, v2, v3) return v4 } - -/* - line3Dto2D: function (line3d) { - const a = line3d.point - const b = line3d.direction.plus(a) - const a2d = this.to2D(a) - const b2d = this.to2D(b) - return Line2D.fromPoints(a2d, b2d) - }, - - line2Dto3D: function (line2d) { - const a = line2d.origin() - const b = line2d.direction().plus(a) - const a3d = this.to3D(a) - const b3d = this.to3D(b) - return Line3D.fromPoints(a3d, b3d) - }, - - transform: function (matrix4x4) { - // todo: this may not work properly in case of mirroring - const newplane = this.plane.transform(matrix4x4) - const rightpointTransformed = this.u.transform(matrix4x4) - const originTransformed = new Vector3D(0, 0, 0).transform(matrix4x4) - const newrighthandvector = rightpointTransformed.minus(originTransformed) - const newbasis = new OrthoNormalBasis(newplane, newrighthandvector) - return newbasis - } -*/ } module.exports = OrthoNormalBasis