fix(core): clockwise-positive bend angle for IP4 (right turn when travelling IP1→IP2)
Sign convention approved: a right (clockwise) deflection is positive. solveIp4 now rotates the IP1→IP2 direction by −θ. Test covers a +10° right turn with IP4 at (5, 0). Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d0fa9b94eb
commit
d8944e9023
2 files changed
+9
-10
No files matched your search
@@ -167,15 +167,14 @@ function meanN(m: ReturnType<typeof buildPier>, row: '전열' | '후열'): numbe
|
||||
describe('꺾인 코핑 IP4 (spec §4.1)', () => {
|
||||
const cross = (a: { e: number; n: number }, b: { e: number; n: number }) => a.e * b.n - a.n * b.e;
|
||||
|
||||
it('IP4 lies on the IP1→IP2 line and on the line through IP3 turned by the bend angle', () => {
|
||||
const ip1 = { e: 0, n: 0 };
|
||||
const ip2 = { e: 1, n: 0 };
|
||||
const ip3 = { e: 10, n: 2 };
|
||||
const ip4 = solveIp4(ip1, ip2, ip3, 10)!;
|
||||
expect(ip4.n).toBeCloseTo(0, 9);
|
||||
it('right (clockwise) bend of +10° puts IP4 on the IP1→IP2 line, with IP3 on the turned line', () => {
|
||||
const rad = (10 * Math.PI) / 180;
|
||||
const d2 = { e: Math.cos(rad), n: Math.sin(rad) };
|
||||
expect(cross({ e: ip4.e - ip3.e, n: ip4.n - ip3.n }, d2)).toBeCloseTo(0, 9);
|
||||
const d2 = { e: Math.cos(rad), n: -Math.sin(rad) }; // heading east, turning right → south-east
|
||||
const expectedIp4 = { e: 5, n: 0 };
|
||||
const ip3 = { e: expectedIp4.e + 5 * d2.e, n: expectedIp4.n + 5 * d2.n };
|
||||
const ip4 = solveIp4({ e: 0, n: 0 }, { e: 1, n: 0 }, ip3, 10)!;
|
||||
expect(ip4.e).toBeCloseTo(5, 9);
|
||||
expect(ip4.n).toBeCloseTo(0, 9);
|
||||
});
|
||||
|
||||
it('zero angle has no IP4', () => {
|
||||
|
||||
Reference in new issue
Block a user