Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[BUG]: ConvexHull algorithm crashes with division by zero on vertical lines #1815

Open
Labels
bugSomething isn't working
@bhautikrathod9

Description

@bhautikrathod9

Description

The current ConvexHull implementation has a critical bug in theorientation function that causes division by zero when processing points that share the same x-coordinate (vertical lines).

Location

File:Geometry/ConvexHull.js
Function:orientation(a, b, c)

Expected Behavior

The algorithm should handle vertical lines correctly and return the proper convex hull vertices.

Actual Behavior

Current Implementation (Buggy):

functionorientation(a,b,c){constalpha=(b.y-a.y)/(b.x-a.x)// ❌ Division by zero!constbeta=(c.y-b.y)/(c.x-b.x)// ❌ Division by zero!if(alpha>beta)return1elseif(beta>alpha)return-1return0}

Problem:

When b.x === a.x or c.x === b.x, the division results in Infinity or NaN, causing incorrect results or crashes.
Steps to Reproduce

import{convexHull}from'./Geometry/ConvexHull.js'// Points with same x-coordinate (vertical line)constpoints=[{x:2,y:0},{x:2,y:1},// Same x as above{x:2,y:2},// Same x as above{x:0,y:1},{x:4,y:1}]convexHull(points)// ❌ Returns incorrect result or crashes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp