Skip to content

Commit

Permalink
Use a much faster roundTo implementation (no conversion back/forth to…
Browse files Browse the repository at this point in the history
… string).
  • Loading branch information
brcolow committed Dec 26, 2024
1 parent 71e7d03 commit 822e21c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions moody.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { Vector3 } from "./math.js"
const sineOfOneArcsecond = 0.00000484813

function roundTo(n, numDecimalPlaces) {
const multiplicator = Math.pow(10, numDecimalPlaces)
n = parseFloat((n * multiplicator).toFixed(11))
return Math.round(n) / multiplicator
const factor = Math.pow(10, numDecimalPlaces)
return Math.round(n * factor) / factor
}

class Unit {
Expand Down

0 comments on commit 822e21c

Please # to comment.