Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Changed implementation of slope calculation
  • Loading branch information
Haarush2006 committed Oct 23, 2025
commit 36e2b1626f94d8cca5fd2d338ace8cbbd3be9dd6
12 changes: 3 additions & 9 deletions Geometry/ConvexHullGraham.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,10 @@ function compare(a, b) {
return 1
}
function orientation(a, b, c) {
// Check orientation of Line(a, b) and Line(b, c)
const alpha = (b.y - a.y) / (b.x - a.x)
const beta = (c.y - b.y) / (c.x - b.x)
const crossProduct = (b.y - a.y) * (c.x - b.x) - (b.x - a.x) * (c.y - b.y);

// Clockwise
if (alpha > beta) return 1
// Anticlockwise
else if (beta > alpha) return -1
// Colinear
return 0
if(crossProduct === 0) return 0;
return (crossProduct > 0) ? 1 : -1;
}

function convexHull(points) {
Expand Down
Loading