cartesianToSpherical property

List<List<num>> cartesianToSpherical

Converts a list of Cartesian coordinates to a list of Polar Spherical coordinates:

  • [x, y, z] -> [r, theta, phi],
  • theta is the angle between the z-axis and the line connecting the origin with the point [x, y, z],
  • phi is the angle between the x-axis and the line connecting the origin with the projection point of [x, y, z] onto the x-y plane.

Implementation

List<List<num>> get cartesianToSpherical {
  try {
    return List<List<num>>.generate(
        length, (index) => this[index].cartesianToSpherical);
  } on RangeError catch (e, _) {
    throw ErrorOfType<IndexOutOfRange>(
        message: 'Error in getter <cartesianToSpherical>.',
        invalidState: 'Could not access list '
            'element with index:<${e.invalidValue}>.',
        expectedState: 'A set of coordinates as a List<num> with length 3.');
  }
}