feat(CAD): 331-1 각도 고정 <각도 → 길이 · 시퀀스 첫 점 숫자 무시
- 새 input-angle-lock — 다음 한 점만 고정 방향(동쪽 0° 반시계) · 커서 · 클릭은 고정 직선 위로 · 숫자는 그 방향 길이 · 한 점 · Esc · 새 명령이면 풂 · 커서 옆 안내 「각도 30° 고정 — 길이 입력」 - input-patterns — 숫자 음수 · .5 허용 · 각도 고정 꼴 · 점 글 해석 한 곳(parsePointText) - Enter 해석 차례 — 자유 글 단계만 원문 먼저 → 각도 고정 → 점 · 거리 → 단계 선택지 → 명령 이름 - 선 · 시퀀스 미리보기도 고정 방향 · 시퀀스 첫 점의 거리 · 상대 좌표는 무시(도구 멈춤 · 「Error in tool actor」 없앰) - 시험 resources/tester/cad/keyboard-chain.test.ts Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013QyNXY2TUKXCFMwAca2APG
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* 각도 고정 `<각도` — 오토캐드 각도 재지정. 다음 한 점만 기준점에서 그 방향(동쪽 0° 반시계 +).
|
||||
* 커서 · 클릭은 고정 방향 직선 위로 내리고 · 숫자는 그 방향 길이. 점 하나 쓰면 · Esc · 새 명령이면 풂.
|
||||
*/
|
||||
import { Point } from '@flatten-js/core';
|
||||
import { polarToPoint } from './input-patterns.ts';
|
||||
|
||||
let lockedDegrees: number | null = null;
|
||||
|
||||
export const getAngleLock = (): number | null => lockedDegrees;
|
||||
|
||||
export const setAngleLock = (degrees: number | null) => {
|
||||
lockedDegrees = degrees;
|
||||
};
|
||||
|
||||
/** 커서 옆 안내 줄 */
|
||||
export const angleLockHint = (): string | null =>
|
||||
lockedDegrees === null ? null : `각도 ${lockedDegrees}° 고정 — 길이 입력`;
|
||||
|
||||
/** 기준점에서 고정 방향으로 거리만큼 간 점 */
|
||||
export function pointAtLock(base: Point, distance: number): Point {
|
||||
const offset = polarToPoint(distance, lockedDegrees ?? 0);
|
||||
return new Point(base.x + offset.x, base.y + offset.y);
|
||||
}
|
||||
|
||||
/** 점을 기준점 · 고정 방향 직선 위로 내림(커서 · 클릭) */
|
||||
export function projectOnLock(base: Point, point: Point): Point {
|
||||
const unit = polarToPoint(1, lockedDegrees ?? 0);
|
||||
const along = (point.x - base.x) * unit.x + (point.y - base.y) * unit.y;
|
||||
return new Point(base.x + unit.x * along, base.y + unit.y * along);
|
||||
}
|
||||
Reference in New Issue
Block a user