SimonHFrost/merry-beats-3d

View on GitHub
javascripts/merryMaths.js

Summary

Maintainability
A
0 mins
Test Coverage
function MerryMaths () {}

MerryMaths.prototype.getPositionsAroundCircle = function (numberOfPositions, radius) {
  var circle = Math.PI * 2

  var everyXDegrees = circle / numberOfPositions

  var result = []
  for (var i = 0; i < numberOfPositions; i++) {
    var currentDegrees = i * everyXDegrees

    var x = Math.cos(currentDegrees) * radius
    var z = Math.sin(currentDegrees) * radius

    result.push([x, z])
  }

  return result
}