compassDirections function

List<Vector3> compassDirections({
  1. int numSides = 4,
  2. Vector3 startVec = RIGHT,
})

Implementation

List<Vector3> compassDirections({int numSides = 4, Vector3 startVec = RIGHT}) {
  var angle = TAU / numSides;

  var rootsOfUnity = [
    for (var k in range(end: numSides)) Complex.exp(angle: angle * k)
  ];

  var complexResults = [
    for (var u in rootsOfUnity)
      u * Complex(real: startVec.x, imaginary: startVec.y)
  ];

  return [for (var c in complexResults) Vector3(c.real, c.imaginary, 0)];
}