Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 8 additions & 7 deletions Geometry/ConvexHullGraham.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ function compare(a, b) {
if (a.x === b.x && a.y < b.y) return -1
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)
// Calculate the cross product value
// This helps determine the direction of the turn
const val = (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
if (val > 0) return 1
// Counterclockwise
if (val < 0) return -1
// Collinear
return 0
}

Expand Down
4 changes: 2 additions & 2 deletions Maths/MobiusFunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ export const mobiusFunction = (number) => {
return primeFactorsArray.length !== new Set(primeFactorsArray).size
? 0
: primeFactorsArray.length % 2 === 0
? 1
: -1
? 1
: -1
}
2 changes: 1 addition & 1 deletion String/GenerateGUID.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const Guid = () => {
const pattern = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
let currentDateMilliseconds = new Date().getTime()
return pattern.replace(/[xy]/g, (currentChar) => {
const randomChar = (currentDateMilliseconds + Math.random() * 16) % 16 | 0
const randomChar = ((currentDateMilliseconds + Math.random() * 16) % 16) | 0
currentDateMilliseconds = Math.floor(currentDateMilliseconds / 16)
return (
currentChar === 'x' ? randomChar : (randomChar & 0x7) | 0x8
Expand Down
Loading
Loading