dev #192

Merged
ysCha merged 2 commits from dev into prd-deploy 2025-07-08 17:21:03 +09:00
Showing only changes of commit a05a63ebdc - Show all commits

View File

@ -312,23 +312,20 @@ export function removeDuplicatePolygons(polygons) {
// 같은 직선상에 있는지 확인 같은 직선이라면 polygon을 생성할 수 없으므로 false // 같은 직선상에 있는지 확인 같은 직선이라면 polygon을 생성할 수 없으므로 false
const isValidPoints = (points) => { const isValidPoints = (points) => {
// x값별로 점들을 그룹화 // 연속된 3개 이상의 점이 같은 x 또는 y 값을 가지는지 확인 (원형 배열로 처리)
const xGroups = {} for (let i = 0; i < points.length; i++) {
const yGroups = {} const point1 = points[i]
const point2 = points[(i + 1) % points.length]
const point3 = points[(i + 2) % points.length]
points.forEach(point => { // x값이 같은 연속된 3개 점 확인
if (!xGroups[point.x]) xGroups[point.x] = [] if (point1.x === point2.x && point2.x === point3.x) {
if (!yGroups[point.y]) yGroups[point.y] = [] return false
xGroups[point.x].push(point) }
yGroups[point.y].push(point) // y값이 같은 연속된 3개 점 확인
}) if (point1.y === point2.y && point2.y === point3.y) {
return false
// 3개 이상 같은 x 또는 y 값을 가지는 점이 있는지 확인
for (const x in xGroups) {
if (xGroups[x].length >= 3) return false
} }
for (const y in yGroups) {
if (yGroups[y].length >= 3) return false
} }
function isColinear(p1, p2, p3) { function isColinear(p1, p2, p3) {