MCPcopy
hub / github.com/TheAlgorithms/JavaScript / orientation

Function orientation

Geometry/ConvexHullGraham.js:15–26  ·  view source on GitHub ↗
(a, b, c)

Source from the content-addressed store, hash-verified

13 return 1
14}
15function orientation(a, b, c) {
16 // Check orientation of Line(a, b) and Line(b, c)
17 const alpha = (b.y - a.y) / (b.x - a.x)
18 const beta = (c.y - b.y) / (c.x - b.x)
19
20 // Clockwise
21 if (alpha > beta) return 1
22 // Anticlockwise
23 else if (beta > alpha) return -1
24 // Colinear
25 return 0
26}
27
28function convexHull(points) {
29 const pointsLen = points.length

Callers 1

convexHullFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected