refactor: ortho scale
This commit is contained in:
parent
ed264d8f0b
commit
46cdc32485
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user