FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fixed Geometry Orientation Feature by ishika-negi · Pull Request #1901 · TheAlgorithms/JavaScript · GitHub

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (3) .lock  (1) All 2 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
15 changes: 8 additions & 7 deletions Geometry/ConvexHullGraham.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL