fix(core): refuse bends that double back; use a valid synthetic bend in tests
The earlier synthetic bend (IP3 at (6, 2)) put IP4 ahead of IP3 on the turned line, so the axis folded back on itself. buildPier now refuses a kink behind IP1 along IP1→IP2 or an IP3 behind the kink along the turned direction. Tests use IP3 (9, −3.464), a valid 60° right turn with kink (7, 0). Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5371932cca
commit
c9dae4ff9b
3 files changed
+29
-9
No files matched your search
@@ -203,6 +203,18 @@ export function buildPier(input: PierInput): PierModel {
|
||||
const ip3v: Vec2 = { e: ip3.x, n: ip3.y };
|
||||
const kink = bent ? solveIp4(ip1v, ip2v, ip3v, ip4.angleDeg) : null;
|
||||
const axis = buildAxis(ip1v, ip3v, kink);
|
||||
if (kink) {
|
||||
// The bend must move the axis forward: the kink ahead of IP1 along IP1→IP2, and IP3 ahead of the kink along the turned direction.
|
||||
const d1 = { e: ip2v.e - ip1v.e, n: ip2v.n - ip1v.n };
|
||||
const len1 = Math.hypot(d1.e, d1.n);
|
||||
const rad = (-ip4.angleDeg * Math.PI) / 180;
|
||||
const d2 = { e: (d1.e * Math.cos(rad) - d1.n * Math.sin(rad)) / len1, n: (d1.e * Math.sin(rad) + d1.n * Math.cos(rad)) / len1 };
|
||||
const kinkAhead = (kink.e - ip1v.e) * d1.e + (kink.n - ip1v.n) * d1.n > 0;
|
||||
const ip3Ahead = (ip3v.e - kink.e) * d2.e + (ip3v.n - kink.n) * d2.n > 0;
|
||||
if (!kinkAhead || !ip3Ahead) {
|
||||
throw new Error('꺾임각과 IP 배치가 맞지 않습니다. IP4가 축 뒤로 넘어갑니다. IP3이 꺾인 방향의 앞쪽에 있는지 확인하세요.');
|
||||
}
|
||||
}
|
||||
const lengthIp = axis.length;
|
||||
const sStart = copingSpan(axis, L).sStart;
|
||||
const arcA = kinkArc(axis);
|
||||
|
||||
Reference in new issue
Block a user