refactor: ortho scale

This commit is contained in:
cha0s 2021-03-28 10:39:01 -05:00
parent ed264d8f0b
commit 46cdc32485
2 changed files with 7 additions and 3 deletions

View File

@ -126,7 +126,7 @@ const c = [
Vector.fromDirection(3),
];
export function ortho(vs) {
export function ortho(vs, k) {
if (vs.length < 4) {
throw new TypeError('Vertice.ortho(): vs.length < 4');
}
@ -142,6 +142,10 @@ export function ortho(vs) {
const sorted = [vs[0]];
let d = 0;
let walk = 0;
const kc = [];
for (let i = 0; i < c.length; i++) {
kc[i] = Vector.scale(c[i], k);
}
// eslint-disable-next-line no-labels, no-restricted-syntax
select:
// eslint-disable-next-line no-constant-condition
@ -149,7 +153,7 @@ export function ortho(vs) {
for (let i = 0; i < 4; i++) {
// eslint-disable-next-line no-bitwise
const s = (i + d + 3) & 3;
const v = index(Vector.add(vs[walk], c[s]));
const v = index(Vector.add(vs[walk], kc[s]));
if (vs[0] === v) {
return sorted;
}

View File

@ -87,7 +87,7 @@ export default (latus) => {
}
}
}
const hull = Vertice.removeCollinear(Vertice.ortho(Vertice.unique(body)));
const hull = Vertice.removeCollinear(Vertice.ortho(Vertice.unique(body), 1));
if (hull.length > 0) {
hulls.push(hull);
}