Skip to content

Commit

Permalink
style(modeling): changes to comply with lint
Browse files Browse the repository at this point in the history
  • Loading branch information
z3dev committed Nov 9, 2024
1 parent fc01384 commit d89354d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 20 deletions.
35 changes: 20 additions & 15 deletions packages/modeling/src/geometries/geom3/fromPointsConvex.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,29 @@ const test = require('ava')
const { fromPointsConvex, validate } = require('./index')

test('fromPointsConvex (uniquePoints)', (t) => {
let out = []
for(x=-9;x<=9;++x)
for(y=-9;y<=9;++y)
for(z=-9;z<=9;++z)
if (x*x+y*y+z*z <= 96)
out.push([x,y,z])
const out = []
for (let x = -9; x <= 9; ++x) {
for (let y = -9; y <= 9; ++y) {
for (let z = -9; z <= 9; ++z) {
if (x * x + y * y + z * z <= 96) out.push([x, y, z])
}
}
}

let obs = fromPointsConvex(out)
const obs = fromPointsConvex(out)
validate(obs)

t.is(obs.polygons.length, 170)
t.true(obs.polygons.every((f) => ([3,4,8,9].indexOf(f.vertices.length) !== -1)))
let c = [0,0,0,0,0,0,0,0,0,0]
t.true(obs.polygons.every((f) => ([3, 4, 8, 9].indexOf(f.vertices.length) !== -1)))

const c = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
obs.polygons.forEach((f) => c[f.vertices.length]++)
t.is(c[3], 120);
t.is(c[4], 24);
t.is(c[8], 18);
t.is(c[9], 8);
let edges2 = 336*2
t.is(c[3], 120)
t.is(c[4], 24)
t.is(c[8], 18)
t.is(c[9], 8)

let edges2 = 336 * 2
obs.polygons.forEach((f) => edges2 -= f.vertices.length)
t.is(edges2, 0);
t.is(edges2, 0)
})
8 changes: 6 additions & 2 deletions packages/modeling/src/maths/OrthoNormalBasis.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ OrthoNormalBasis.GetCartesian = function (xaxisid, yaxisid) {
} 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))
// return new OrthoNormalBasis(new Plane(new Vector3D(planenormal), 0), new Vector3D(rightvector))
}

/*
Expand Down Expand Up @@ -137,11 +137,13 @@ OrthoNormalBasis.GetCartesian_Test=function() {
};
*/

/*
// 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 = {

Expand Down Expand Up @@ -175,8 +177,9 @@ OrthoNormalBasis.prototype = {
const v3 = vec3.add(v1, v1, this.planeorigin)
const v4 = vec3.add(v2, v2, v3)
return v4
},
}

/*
line3Dto2D: function (line3d) {
const a = line3d.point
const b = line3d.direction.plus(a)
Expand All @@ -202,6 +205,7 @@ OrthoNormalBasis.prototype = {
const newbasis = new OrthoNormalBasis(newplane, newrighthandvector)
return newbasis
}
*/
}

module.exports = OrthoNormalBasis
4 changes: 2 additions & 2 deletions packages/modeling/src/primitives/polygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ const polygon = (options) => {
})

// convert the list of sides into a geometry
let geometry = geom2.create(sides)
if (orientation == "clockwise") {
let geometry = geom2.create(sides)
if (orientation === 'clockwise') {
geometry = geom2.reverse(geometry)
}
return geometry
Expand Down
2 changes: 1 addition & 1 deletion packages/modeling/src/primitives/polygon.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test('polygon: providing object.points (array) and object.path (array) creates e
test('polygon: clockwise points', (t) => {
const poly = polygon({
points: [[-10, -0], [-10, -10], [-15, -5]],
orientation: "clockwise",
orientation: 'clockwise'
})
t.is(poly.sides.length, 3)
t.is(measureArea(poly), 25)
Expand Down

0 comments on commit d89354d

Please sign in to comment.