fix(titan): Add runaway rotations protection
This commit is contained in:
parent
02c7e01c5d
commit
9ac1ed560e
2 changed files with 80 additions and 4 deletions
|
@ -18,6 +18,7 @@ function titanBack({
|
||||||
Snippet,
|
Snippet,
|
||||||
sa,
|
sa,
|
||||||
absoluteOptions,
|
absoluteOptions,
|
||||||
|
log,
|
||||||
part,
|
part,
|
||||||
}) {
|
}) {
|
||||||
/*
|
/*
|
||||||
|
@ -102,6 +103,8 @@ function titanBack({
|
||||||
.rotate(options.crossSeamCurveAngle, points.fork)
|
.rotate(options.crossSeamCurveAngle, points.fork)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let adjustment_warning = false
|
||||||
|
|
||||||
// Let's get to work
|
// Let's get to work
|
||||||
points.waistX = new Point(-1 * measurements.waistBackArc * (1 + options.waistEase), 0)
|
points.waistX = new Point(-1 * measurements.waistBackArc * (1 + options.waistEase), 0)
|
||||||
points.upperLegY = new Point(0, measurements.waistToUpperLeg)
|
points.upperLegY = new Point(0, measurements.waistToUpperLeg)
|
||||||
|
@ -173,20 +176,41 @@ function titanBack({
|
||||||
// Should we fit the cross seam?
|
// Should we fit the cross seam?
|
||||||
if (options.fitCrossSeam && options.fitCrossSeamBack) {
|
if (options.fitCrossSeam && options.fitCrossSeamBack) {
|
||||||
let rotate = ['waistIn', 'waistOut']
|
let rotate = ['waistIn', 'waistOut']
|
||||||
|
let saved = []
|
||||||
let delta = crossSeamDelta()
|
let delta = crossSeamDelta()
|
||||||
|
let previous_delta = delta
|
||||||
let run = 0
|
let run = 0
|
||||||
do {
|
do {
|
||||||
|
previous_delta = delta
|
||||||
run++
|
run++
|
||||||
// Remedy A: Slash and spread
|
// Remedy A: Slash and spread
|
||||||
for (const i of rotate) points[i] = points[i].rotate(delta / 15, points.seatOut)
|
for (const i of rotate) {
|
||||||
|
saved[i] = points[i]
|
||||||
|
points[i] = points[i].rotate(delta / 15, points.seatOut)
|
||||||
|
}
|
||||||
// Remedy B: Nudge the fork inwards/outwards
|
// Remedy B: Nudge the fork inwards/outwards
|
||||||
|
saved.fork = points.fork
|
||||||
points.fork = points.fork.shift(0, delta / 5)
|
points.fork = points.fork.shift(0, delta / 5)
|
||||||
|
saved.forkCp2 = points.forkCp2
|
||||||
points.forkCp2 = points.crossSeamCurveCp2.rotate(-90, points.fork)
|
points.forkCp2 = points.crossSeamCurveCp2.rotate(-90, points.fork)
|
||||||
drawCrossSeam()
|
drawCrossSeam()
|
||||||
delta = crossSeamDelta()
|
delta = crossSeamDelta()
|
||||||
// Uncomment the line beloe this to see all iterations
|
// Uncomment the line beloe this to see all iterations
|
||||||
// paths[`try${run}`] = drawPath().attr('class', 'dotted')
|
// paths[`try${run}`] = drawPath().attr('class', 'dotted')
|
||||||
} while (Math.abs(delta) > 1 && run < 15)
|
} while (Math.abs(delta) > 1 && run < 15 && Math.abs(delta) < Math.abs(previous_delta))
|
||||||
|
if (Math.abs(delta) > Math.abs(previous_delta)) {
|
||||||
|
// The rotations started to produce worse results.
|
||||||
|
// Revert back to the previous rotation.
|
||||||
|
for (const i of rotate) {
|
||||||
|
points[i] = saved[i]
|
||||||
|
}
|
||||||
|
points.fork = saved.fork
|
||||||
|
points.forkCp2 = saved.forkCp2
|
||||||
|
}
|
||||||
|
if (Math.abs(delta) > 1 || Math.abs(delta) > Math.abs(previous_delta)) {
|
||||||
|
log.warning('Unable to adjust the back crotch seam to fit the given measurements.')
|
||||||
|
adjustment_warning = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store inseam & outseam length
|
// Store inseam & outseam length
|
||||||
|
@ -494,6 +518,19 @@ function titanBack({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (adjustment_warning) {
|
||||||
|
log.warning(
|
||||||
|
'We were not able to generate the Back pattern piece correctly. ' +
|
||||||
|
'Manual fitting and alteration of this and other pattern pieces ' +
|
||||||
|
'are likely to be needed. ' +
|
||||||
|
'First, please retake your measurements and generate a new pattern ' +
|
||||||
|
'using the new measurements. ' +
|
||||||
|
'If you still see this warning with the new pattern, then please ' +
|
||||||
|
'make a test garment, check fit, and make alterations as necessary ' +
|
||||||
|
'before trying to make the final garment.'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return part
|
return part
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ function titanFront({
|
||||||
Snippet,
|
Snippet,
|
||||||
sa,
|
sa,
|
||||||
absoluteOptions,
|
absoluteOptions,
|
||||||
|
log,
|
||||||
part,
|
part,
|
||||||
}) {
|
}) {
|
||||||
/*
|
/*
|
||||||
|
@ -173,6 +174,8 @@ function titanFront({
|
||||||
const adaptOutseam = () => adaptSeam('out')
|
const adaptOutseam = () => adaptSeam('out')
|
||||||
const adaptInseam = () => adaptSeam('in')
|
const adaptInseam = () => adaptSeam('in')
|
||||||
|
|
||||||
|
let adjustment_warning = false
|
||||||
|
|
||||||
// Let's get to work
|
// Let's get to work
|
||||||
points.waistX = new Point(measurements.waistFrontArc * (1 + options.waistEase), 0)
|
points.waistX = new Point(measurements.waistFrontArc * (1 + options.waistEase), 0)
|
||||||
points.upperLegY = new Point(0, measurements.waistToUpperLeg)
|
points.upperLegY = new Point(0, measurements.waistToUpperLeg)
|
||||||
|
@ -235,19 +238,42 @@ function titanFront({
|
||||||
|
|
||||||
if (options.fitCrossSeam && options.fitCrossSeamFront) {
|
if (options.fitCrossSeam && options.fitCrossSeamFront) {
|
||||||
let delta = crotchSeamDelta()
|
let delta = crotchSeamDelta()
|
||||||
|
let previous_delta = delta
|
||||||
let rotate = ['waistIn', 'waistOut', 'cfWaist']
|
let rotate = ['waistIn', 'waistOut', 'cfWaist']
|
||||||
|
let saved = []
|
||||||
let run = 0
|
let run = 0
|
||||||
do {
|
do {
|
||||||
|
previous_delta = delta
|
||||||
run++
|
run++
|
||||||
// Remedy A: Slash and spread
|
// Remedy A: Slash and spread
|
||||||
for (const i of rotate) points[i] = points[i].rotate(delta / -15, points.seatOut)
|
for (const i of rotate) {
|
||||||
|
saved[i] = points[i]
|
||||||
|
points[i] = points[i].rotate(delta / -15, points.seatOut)
|
||||||
|
}
|
||||||
// Remedy B: Nudge the fork inwards/outwards
|
// Remedy B: Nudge the fork inwards/outwards
|
||||||
|
saved.fork = points.fork
|
||||||
points.fork = points.fork.shift(180, delta / 5)
|
points.fork = points.fork.shift(180, delta / 5)
|
||||||
drawCrotchSeam()
|
drawCrotchSeam()
|
||||||
delta = crotchSeamDelta()
|
delta = crotchSeamDelta()
|
||||||
// Uncomment the line below this to see all iterations
|
// Uncomment the line below this to see all iterations
|
||||||
// paths[`try${run}`] = drawPath().attr('class', 'dotted')
|
// paths[`try${run}`] = drawPath().attr('class', 'dotted')
|
||||||
} while (Math.abs(delta) > 1 && run < 15)
|
} while (Math.abs(delta) > 1 && run < 15 && Math.abs(delta) < Math.abs(previous_delta))
|
||||||
|
if (Math.abs(delta) > Math.abs(previous_delta)) {
|
||||||
|
// The rotations started to produce worse results.
|
||||||
|
// Revert back to the previous rotation.
|
||||||
|
for (const i of rotate) {
|
||||||
|
points[i] = saved[i]
|
||||||
|
}
|
||||||
|
points.fork = saved.fork
|
||||||
|
}
|
||||||
|
if (Math.abs(delta) > 1 || Math.abs(delta) > Math.abs(previous_delta)) {
|
||||||
|
log.warning(
|
||||||
|
'Unable to adjust the front crotch seam to fit the given measurements, after ' +
|
||||||
|
run +
|
||||||
|
' iterations.'
|
||||||
|
)
|
||||||
|
adjustment_warning = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Uncomment this to see the outline prior to fitting the inseam & outseam
|
// Uncomment this to see the outline prior to fitting the inseam & outseam
|
||||||
|
@ -563,6 +589,19 @@ function titanFront({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (adjustment_warning) {
|
||||||
|
log.warning(
|
||||||
|
'We were not able to generate the Front pattern piece correctly. ' +
|
||||||
|
'Manual fitting and alteration of this and other pattern pieces ' +
|
||||||
|
'are likely to be needed. ' +
|
||||||
|
'First, please retake your measurements and generate a new pattern ' +
|
||||||
|
'using the new measurements. ' +
|
||||||
|
'If you still see this warning with the new pattern, then please ' +
|
||||||
|
'make a test garment, check fit, and make alterations as necessary ' +
|
||||||
|
'before trying to make the final garment.'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return part
|
return part
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue