toCartesian method

dynamic toCartesian()

Converts the lat long values to cartesian coordinates

Implementation

toCartesian() {
  final w = radians(lat);
  final l = radians(long);
  final h = height;
  final a = ellipsoids[datum["ellipsoid"]]!["a"]!;
  final f = ellipsoids[datum["ellipsoid"]]!["f"]!;

  final sinw = math.sin(w);
  final cosw = math.cos(w);
  final sinl = math.sin(l);
  final cosl = math.cos(l);

  final eSq = 2*f - f*f;
  final v = a / math.sqrt(1 - eSq*sinw*sinw);

  final x = (v+h) * cosw * cosl;
  final y = (v+h) * cosw * sinl;
  final z = (v*(1-eSq)+h) * sinw;

  return new Cartesian(x, y, z, this.datum);
}