onSolarDisk function

bool onSolarDisk(
  1. Vector3 direction,
  2. Vector3 sunFromEarth
)

Whether direction (from the Earth's centre) falls on the disk of the Sun seen in direction sunFromEarth.

Implementation

bool onSolarDisk(Vector3 direction, Vector3 sunFromEarth) {
  final cosSeparation = direction.unit.dot(sunFromEarth.unit);
  final sinRadius = solarRadius / sunFromEarth.length;
  return cosSeparation > math.sqrt(1 - sinRadius * sinRadius);
}