Compare commits
No commits in common. "71d92f12b853437f5b7fdc8cbc1faa68cbac397b" and "d72444199f18ce5785538d1e004f17e1ee5943de" have entirely different histories.
71d92f12b8
...
d72444199f
@ -312,22 +312,6 @@ export function removeDuplicatePolygons(polygons) {
|
|||||||
|
|
||||||
// 같은 직선상에 있는지 확인 같은 직선이라면 polygon을 생성할 수 없으므로 false
|
// 같은 직선상에 있는지 확인 같은 직선이라면 polygon을 생성할 수 없으므로 false
|
||||||
const isValidPoints = (points) => {
|
const isValidPoints = (points) => {
|
||||||
// 연속된 3개 이상의 점이 같은 x 또는 y 값을 가지는지 확인 (원형 배열로 처리)
|
|
||||||
for (let i = 0; i < points.length; i++) {
|
|
||||||
const point1 = points[i]
|
|
||||||
const point2 = points[(i + 1) % points.length]
|
|
||||||
const point3 = points[(i + 2) % points.length]
|
|
||||||
|
|
||||||
// x값이 같은 연속된 3개 점 확인
|
|
||||||
if (point1.x === point2.x && point2.x === point3.x) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
// y값이 같은 연속된 3개 점 확인
|
|
||||||
if (point1.y === point2.y && point2.y === point3.y) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function isColinear(p1, p2, p3) {
|
function isColinear(p1, p2, p3) {
|
||||||
return (p2.x - p1.x) * (p3.y - p1.y) === (p3.x - p1.x) * (p2.y - p1.y)
|
return (p2.x - p1.x) * (p3.y - p1.y) === (p3.x - p1.x) * (p2.y - p1.y)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user