Skip to content

Commit 47ce846

Browse files
authored
Merge pull request #70 from WimDeMeester/master
Added the moon phase ratio to the calculation of the illumination of the moon.
2 parents 2ff0d61 + 67ba0b5 commit 47ce846

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to `laravel-astronomy-library` will be documented in this file.
44

5+
## Version 5.4.1
6+
7+
### Added
8+
9+
- Added the moon phase ratio to the calculation of the illumination of the moon.
10+
511
## Version 5.4
612

713
### Added

src/deepskylog/AstronomyLibrary/Targets/Moon.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,11 @@ private function _calculateEquatorialCoordinates(Carbon $date, GeographicalCoord
369369
*
370370
* @param Carbon $date The date for which to calculate the fraction
371371
*
372-
* @return float The illuminated fraction
372+
* @return array The illuminated fraction, the phase ratio
373373
*
374374
* See chapter 58 of Astronomical Algorithms
375375
*/
376-
public function illuminatedFraction(Carbon $date): float
376+
public function illuminatedFraction(Carbon $date): array
377377
{
378378
// T = julian centuries since epoch J2000.0
379379
$T = (Time::getJd($date) - 2451545.0) / 36525.0;
@@ -396,6 +396,6 @@ public function illuminatedFraction(Carbon $date): float
396396

397397
$i = $i - floor($i / 360.0) * 360.0;
398398

399-
return (1 + cos(deg2rad($i))) / 2;
399+
return [round((1 + cos(deg2rad($i))) / 2, 3), $i / 360];
400400
}
401401
}

tests/Unit/TargetTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ public function testMoonIllumination()
958958
{
959959
$date = Carbon::create(1992, 4, 12, 0, 0, 0, 'UTC');
960960
$moon = new Moon();
961-
$illum = $moon->illuminatedFraction($date);
961+
$illum = $moon->illuminatedFraction($date)[0];
962962

963963
$this->assertEqualsWithDelta(0.680, $illum, 0.001);
964964
}

0 commit comments

Comments
 (0)