This commit is contained in:
parent
0c0f08b350
commit
171fbf1927
1 changed files with 2589 additions and 37 deletions
|
|
@ -6,6 +6,7 @@ export function flooringMetrics(plan: FlooringPlan, s: FlooringSettings) {
|
|||
let ripCuts = 0;
|
||||
let patternPenalty = 0;
|
||||
let repeats = 0;
|
||||
let nearH = 0;
|
||||
let similarSteps = 0;
|
||||
let staircases = 0;
|
||||
for (const piece of plan.pieces) {
|
||||
|
|
@ -32,6 +33,8 @@ export function flooringMetrics(plan: FlooringPlan, s: FlooringSettings) {
|
|||
if (recent.length >= 2) {
|
||||
const movement = step(recent.at(-1)!, phase);
|
||||
const previous = step(recent.at(-2)!, recent.at(-1)!);
|
||||
// Near-aligned joints with one intervening row still read as an H at the scale of the boards.
|
||||
if (Math.abs(step(recent.at(-2)!, phase)) < Math.min(s.width, s.length / 6) - 0.01) nearH++;
|
||||
patternPenalty += Number(Math.abs(Math.abs(movement) - s.length / 2) <= 0.01);
|
||||
for (let distance = 2; distance <= recent.length; distance++) {
|
||||
if (Math.abs(step(recent.at(-distance)!, phase)) <= similar) {
|
||||
|
|
@ -59,6 +62,7 @@ export function flooringMetrics(plan: FlooringPlan, s: FlooringSettings) {
|
|||
ripCuts,
|
||||
patternPenalty,
|
||||
repeats,
|
||||
nearH,
|
||||
similarSteps,
|
||||
staircases,
|
||||
boards: plan.boardCount,
|
||||
|
|
@ -78,7 +82,7 @@ export function skirtingMetrics(plan: SkirtingPlan) {
|
|||
}
|
||||
|
||||
export function compareFlooring(
|
||||
a: ReturnType<typeof flooringMetrics>,
|
||||
a: Omit<ReturnType<typeof flooringMetrics>, 'nearH'>,
|
||||
b: typeof a,
|
||||
random = false,
|
||||
) {
|
||||
|
|
@ -93,6 +97,19 @@ export function compareFlooring(
|
|||
);
|
||||
}
|
||||
|
||||
/** Current appearance score adds broad H alignments; the original metric stays comparable. */
|
||||
export function compareCurrentFlooring(
|
||||
a: ReturnType<typeof flooringMetrics>,
|
||||
b: typeof a,
|
||||
random = false,
|
||||
) {
|
||||
return compareFlooring(
|
||||
{ ...a, patternPenalty: a.patternPenalty + 12 * a.nearH },
|
||||
{ ...b, patternPenalty: b.patternPenalty + 12 * b.nearH },
|
||||
random,
|
||||
);
|
||||
}
|
||||
|
||||
export function compareSkirting(a: ReturnType<typeof skirtingMetrics>, b: typeof a) {
|
||||
return a.errors - b.errors || a.cuts - b.cuts || a.waste - b.waste;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue