9148c358d0
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를 Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류. - 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로 자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거, 동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거. - 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming, Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business, Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로, 나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는 title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백). 원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지. - 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서. - 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는 지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지. - Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경. - 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
6.0 KiB
6.0 KiB
id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
| id | title | category | status | canonical_id | aliases | duplicate_of | source_trust_level | confidence_score | verification_status | tags | raw_sources | last_reinforced | github_commit | tech_stack | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| wiki-2026-0508-computational-geometry | Computational Geometry (Frontend) | 10_Wiki/Topics | verified | self |
|
none | A | 0.9 | applied |
|
2026-05-10 | pending |
|
Computational Geometry (Frontend)
매 한 줄
"매 pixel 의 math 가 geometry 다". Hit-testing, polygon clipping, convex hull, spatial index — 매 canvas/SVG/Figma-style editor 의 core, 매 numerical robustness + spatial accel structure 가 핵심.
매 핵심
매 fundamental ops
- Point-in-polygon (ray casting / winding number).
- Line-line / segment-segment intersection.
- Polygon-polygon clipping (Sutherland-Hodgman, Weiler-Atherton).
- Convex hull (Graham scan, Andrew's monotone chain).
- Bounding box / sphere.
- Distance: point-segment, point-polygon.
매 spatial accel
- Quadtree — 2D static/dynamic.
- R-tree — bbox-based, dynamic insert/delete (rbush lib).
- Spatial hash — uniform grid.
- BVH — for raycasting in 2D/3D.
매 numerical pitfalls
- Floating-point cross product near zero → epsilon checks.
- Robust orientation predicates (Shewchuk).
- 매 SVG path parsing → degenerate cubic 처리.
매 응용
- Figma-style hit-testing.
- Map polygon labeling / clipping.
- Drag-select rectangle vs many shapes.
- Snap-to-grid / snap-to-edge.
- Boolean ops on shapes (union/intersect/difference).
💻 패턴
Point-in-polygon (ray casting)
type Pt = { x: number; y: number };
export function pointInPolygon(p: Pt, poly: Pt[]): boolean {
let inside = false;
for (let i = 0, j = poly.length - 1; i < poly.length; j = i++) {
const a = poly[i], b = poly[j];
const intersect =
(a.y > p.y) !== (b.y > p.y) &&
p.x < ((b.x - a.x) * (p.y - a.y)) / (b.y - a.y) + a.x;
if (intersect) inside = !inside;
}
return inside;
}
Segment-segment intersection
export function segIntersect(p1: Pt, p2: Pt, p3: Pt, p4: Pt): Pt | null {
const d = (p2.x - p1.x) * (p4.y - p3.y) - (p2.y - p1.y) * (p4.x - p3.x);
if (Math.abs(d) < 1e-10) return null; // parallel
const t = ((p3.x - p1.x) * (p4.y - p3.y) - (p3.y - p1.y) * (p4.x - p3.x)) / d;
const u = ((p3.x - p1.x) * (p2.y - p1.y) - (p3.y - p1.y) * (p2.x - p1.x)) / d;
if (t < 0 || t > 1 || u < 0 || u > 1) return null;
return { x: p1.x + t * (p2.x - p1.x), y: p1.y + t * (p2.y - p1.y) };
}
Convex hull (Andrew's monotone chain)
export function convexHull(pts: Pt[]): Pt[] {
const p = [...pts].sort((a, b) => a.x - b.x || a.y - b.y);
const cross = (o: Pt, a: Pt, b: Pt) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
const lower: Pt[] = [];
for (const pt of p) {
while (lower.length >= 2 && cross(lower[lower.length - 2], lower[lower.length - 1], pt) <= 0) lower.pop();
lower.push(pt);
}
const upper: Pt[] = [];
for (let i = p.length - 1; i >= 0; i--) {
const pt = p[i];
while (upper.length >= 2 && cross(upper[upper.length - 2], upper[upper.length - 1], pt) <= 0) upper.pop();
upper.push(pt);
}
upper.pop(); lower.pop();
return lower.concat(upper);
}
Bounding box
export function bbox(pts: Pt[]): { min: Pt; max: Pt } {
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
for (const { x, y } of pts) {
if (x < minX) minX = x; if (y < minY) minY = y;
if (x > maxX) maxX = x; if (y > maxY) maxY = y;
}
return { min: { x: minX, y: minY }, max: { x: maxX, y: maxY } };
}
R-tree spatial index (rbush)
import RBush from 'rbush';
type Item = { minX: number; minY: number; maxX: number; maxY: number; id: string };
const tree = new RBush<Item>();
tree.load(items);
const hits = tree.search({ minX: 0, minY: 0, maxX: 100, maxY: 100 });
Point-segment distance
export function distPtSeg(p: Pt, a: Pt, b: Pt): number {
const dx = b.x - a.x, dy = b.y - a.y;
const lenSq = dx * dx + dy * dy;
if (lenSq === 0) return Math.hypot(p.x - a.x, p.y - a.y);
let t = ((p.x - a.x) * dx + (p.y - a.y) * dy) / lenSq;
t = Math.max(0, Math.min(1, t));
return Math.hypot(p.x - (a.x + t * dx), p.y - (a.y + t * dy));
}
Polygon clipping (using martinez-polygon-clipping)
import * as martinez from 'martinez-polygon-clipping';
const subject = [[[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]];
const clip = [[[5, 5], [15, 5], [15, 15], [5, 15], [5, 5]]];
const intersection = martinez.intersection(subject, clip);
Snap-to-grid
export const snap = (v: number, grid: number) => Math.round(v / grid) * grid;
export const snapPt = (p: Pt, g: number): Pt => ({ x: snap(p.x, g), y: snap(p.y, g) });
매 결정 기준
| 상황 | Approach |
|---|---|
| 1k+ shape hit-test | R-tree (rbush) |
| Static map polygons | Quadtree pre-built |
| Boolean ops on polygons | martinez-polygon-clipping |
| Hull / triangulation | d3-delaunay, earcut |
| Robust numerics | Shewchuk predicates |
기본값: bbox pre-filter → exact test. Spatial index 매 N>500.
🔗 Graph
- 변형: Computer-Graphics · GIS
- 응용: SVG · WebGL
- Adjacent: Collision-Detection
🤖 LLM 활용
언제: canvas editor, map UI, drag-select, snapping, boolean ops on shapes. 언제 X: 매 trivial fixed UI — 매 CSS layout 으로 충분.
❌ 안티패턴
- Naive O(N) hit-test on 10k shapes: 매 lag — spatial index 필수.
- No epsilon in cross product: 매 collinear 매 wrong branch.
- Re-building spatial tree per frame: 매 only on data change, drag 매 incremental update.
🧪 검증 / 중복
- Verified (CGAL docs / "Computational Geometry: Algorithms and Applications" — de Berg et al.).
- 신뢰도 A.
🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — 2D geometry algorithms + spatial index patterns |