From bbc147598130358af4e1cbd8bf000c3c634ff574 Mon Sep 17 00:00:00 2001 From: Wim De Meester Date: Fri, 31 Jul 2020 12:43:45 +0200 Subject: [PATCH 1/3] Calculate if three bodies are in a straight line. --- changelog.md | 6 +++ readme.md | 6 +++ .../Coordinates/EquatorialCoordinates.php | 42 +++++++++++++++++++ tests/Unit/EquatorialCoordinatesTest.php | 23 +++++++++- 4 files changed, 76 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index e50f885..ff325b3 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,12 @@ All notable changes to `laravel-astronomy-library` will be documented in this file. +## Version 4.5 + +### Added + +- Added methods to check if three bodies are in a straight line and to calculate the deviation from a straight line. + ## Version 4.4 ### Added diff --git a/readme.md b/readme.md index d049f29..c89c5be 100644 --- a/readme.md +++ b/readme.md @@ -195,6 +195,12 @@ $galactic = $coords->convertToGalactic(); $parallacticAngle = $coords->getParallacticAngle($geo_coords, $siderial_time); $hour_angle = $coords->getHourAngle($siderial_time); $angular_separation = $coords->angularSeparation($coords2)->getCoordinate(); + +// Check if three bodies are in a straight line +$castor = new EquatorialCoordinates(7.571222, 31.89756); +$pollux = new EquatorialCoordinates(7.750002778, 28.03681); +$mars = new EquatorialCoordinates(8.022644129, 21.472188347); +$isInStraightLine = $mars->isInStraightLine($castor, $pollux); ``` ### Coordinate methods on ecliptical coordinates diff --git a/src/deepskylog/AstronomyLibrary/Coordinates/EquatorialCoordinates.php b/src/deepskylog/AstronomyLibrary/Coordinates/EquatorialCoordinates.php index 8eb7fca..513f11b 100644 --- a/src/deepskylog/AstronomyLibrary/Coordinates/EquatorialCoordinates.php +++ b/src/deepskylog/AstronomyLibrary/Coordinates/EquatorialCoordinates.php @@ -327,4 +327,46 @@ public function angularSeparation( return new Coordinate($d); } + + /** + * Returns true if the three bodies are in a straight line. + * + * @param EquatorialCoordinates $coords2 The coordinates of the second object + * @param EquatorialCoordinates $coords3 The coordinates of the thirds object + * @param float $threshold The threshold for the method + * (default value is 10e-06) + * + * @return bool True if the three bodies are in a straight line + */ + public function isInStraightLine( + self $coords2, + self $coords3, + float $threshold = 1e-6 + ): bool { + $result = tan(deg2rad($this->getDeclination()->getCoordinate())) * + sin( + deg2rad( + $coords2->getRA()->getCoordinate() * 15.0 + - $coords3->getRA()->getCoordinate() * 15.0 + ) + ) + tan(deg2rad($coords2->getDeclination()->getCoordinate())) * + sin( + deg2rad( + $coords3->getRA()->getCoordinate() * 15.0 + - $this->getRA()->getCoordinate() * 15.0 + ) + ) + tan(deg2rad($coords3->getDeclination()->getCoordinate())) * + sin( + deg2rad( + $this->getRA()->getCoordinate() * 15.0 + - $coords2->getRA()->getCoordinate() * 15.0 + ) + ); + + if (abs($result) < $threshold) { + return true; + } + + return false; + } } diff --git a/tests/Unit/EquatorialCoordinatesTest.php b/tests/Unit/EquatorialCoordinatesTest.php index 13b5b99..ab70e11 100644 --- a/tests/Unit/EquatorialCoordinatesTest.php +++ b/tests/Unit/EquatorialCoordinatesTest.php @@ -36,7 +36,7 @@ class EquatorialCoordinatesTest extends BaseTestCase * * @var string */ - protected $appPath = __DIR__.'/../../vendor/laravel/laravel/bootstrap/app.php'; + protected $appPath = __DIR__ . '/../../vendor/laravel/laravel/bootstrap/app.php'; /** * Setup the test environment. @@ -216,4 +216,25 @@ public function testAngularSeparation() 0.0001 ); } + + /** + * Test bodies in straight line/**. + * + * @return None + */ + public function testBodiesInStraightLine() + { + // Castor + $castor = new EquatorialCoordinates(7.571222, 31.89756); + // Pollux + $pollux = new EquatorialCoordinates(7.750002778, 28.03681); + + // Mars on Sep 30, 1994 + $mars = new EquatorialCoordinates(7.97293055, 21.58983); + $this->assertFalse($mars->isInStraightLine($castor, $pollux)); + + // Mars on Oct 1, 1994, 5h TD + $mars = new EquatorialCoordinates(8.022644129, 21.472188347); + $this->assertTrue($mars->isInStraightLine($castor, $pollux)); + } } From 29cc4d3d82344428b7e7ec1e9e28cd8ee65055bb Mon Sep 17 00:00:00 2001 From: Wim De Meester Date: Fri, 31 Jul 2020 14:52:16 +0200 Subject: [PATCH 2/3] Added method to calculate the deviation from a straight line --- .../Coordinates/EclipticalCoordinates.php | 3 ++ .../Coordinates/EquatorialCoordinates.php | 54 ++++++++++++++++++- .../Coordinates/GalacticCoordinates.php | 1 + .../Coordinates/HorizontalCoordinates.php | 7 ++- .../AstronomyLibrary/Targets/Moon.php | 2 +- .../AstronomyLibrary/Targets/Target.php | 28 ++++++---- src/deepskylog/AstronomyLibrary/Time.php | 14 ++--- tests/Unit/EquatorialCoordinatesTest.php | 37 ++++++++++++- 8 files changed, 124 insertions(+), 22 deletions(-) diff --git a/src/deepskylog/AstronomyLibrary/Coordinates/EclipticalCoordinates.php b/src/deepskylog/AstronomyLibrary/Coordinates/EclipticalCoordinates.php index a3094a4..b15a189 100644 --- a/src/deepskylog/AstronomyLibrary/Coordinates/EclipticalCoordinates.php +++ b/src/deepskylog/AstronomyLibrary/Coordinates/EclipticalCoordinates.php @@ -108,6 +108,7 @@ public function printLatitude(): string /** * Converts the ecliptical coordinates to equatorial coordinates. + * Chapter 13 of Astronomical Algorithms. * * @param float $nutObliquity The nutation in obliquity * @@ -141,6 +142,7 @@ public function convertToEquatorial(float $nutObliquity): EquatorialCoordinates /** * Converts the ecliptical coordinates to equatorial coordinates in * the J2000 equinox. + * Chapter 13 of Astronomical Algorithms. * * @return EquatorialCoordinates The equatorial coordinates */ @@ -152,6 +154,7 @@ public function convertToEquatorialJ2000(): EquatorialCoordinates /** * Converts the ecliptical coordinates to equatorial coordinates in * the B1950 equinox. + * Chapter 13 of Astronomical Algorithms. * * @return EquatorialCoordinates The equatorial coordinates */ diff --git a/src/deepskylog/AstronomyLibrary/Coordinates/EquatorialCoordinates.php b/src/deepskylog/AstronomyLibrary/Coordinates/EquatorialCoordinates.php index 513f11b..b1e3197 100644 --- a/src/deepskylog/AstronomyLibrary/Coordinates/EquatorialCoordinates.php +++ b/src/deepskylog/AstronomyLibrary/Coordinates/EquatorialCoordinates.php @@ -111,6 +111,7 @@ public function printRA(): string /** * Converts the equatorial coordinates to ecliptical coordinates in * the current equinox. + * Chapter 13 of Astronomical Algorithms. * * @param float $nutObliquity The nutation in obliquity * @@ -144,6 +145,7 @@ public function convertToEcliptical(float $nutObliquity): EclipticalCoordinates /** * Converts the equatorial coordinates to ecliptical coordinates in * the J2000 equinox. + * Chapter 13 of Astronomical Algorithms. * * @return EclipticalCoordinates The ecliptical coordinates */ @@ -155,6 +157,7 @@ public function convertToEclipticalJ2000(): EclipticalCoordinates /** * Converts the equatorial coordinates to ecliptical coordinates in * the B1950 equinox. + * Chapter 13 of Astronomical Algorithms. * * @return EclipticalCoordinates The ecliptical coordinates */ @@ -165,6 +168,7 @@ public function convertToEclipticalB1950(): EclipticalCoordinates /** * Converts the equatorial coordinates to local horizontal coordinates. + * Chapter 13 of Astronomical Algorithms. * * @param GeographicalCoordinates $geo_coords the geographical * coordinates @@ -204,6 +208,7 @@ public function convertToHorizontal( /** * Converts the equatorial coordinates to galactic coordinates. + * Chapter 13 of Astronomical Algorithms. * * @return GalacticCoordinates The galactic coordinates */ @@ -236,7 +241,7 @@ public function convertToGalactic(): GalacticCoordinates * Returns the parallactic angle of the object. The parallactic angle is * negative before and positive after the passage throught the southern * meridian. This is the effect of the moon that is lying down at moonrise. - * Astronomical Algorithms - chapter 13. + * Chapter 14 of Astronomical Algorithms. * * @param GeographicalCoordinates $geo_coords the geographical * coordinates @@ -282,6 +287,7 @@ public function getHourAngle(Carbon $siderial_time): float /** * Returns the angular separation between these coordinates and other * equatorial coordinates. + * Chapter 17 of Astronomical Algorithms. * * @param EquatorialCoordinates $coords2 the coordinates of the second object * @@ -330,6 +336,7 @@ public function angularSeparation( /** * Returns true if the three bodies are in a straight line. + * Chapter 19 of Astronomical Algorithms. * * @param EquatorialCoordinates $coords2 The coordinates of the second object * @param EquatorialCoordinates $coords3 The coordinates of the thirds object @@ -369,4 +376,49 @@ public function isInStraightLine( return false; } + + /** + * Returns the deviation from a straight line. + * Chapter 19 of Astronomical Algorithms. + * + * @param EquatorialCoordinates $coords2 The coordinates of the first object + * @param EquatorialCoordinates $coords3 The coordinates of the second object + * + * @return Coordinate the deviation from the straight line + */ + public function deviationFromStraightLine( + self $coords2, + self $coords3 + ): Coordinate { + $X1 = cos(deg2rad($coords2->getDeclination()->getCoordinate())) * + cos(deg2rad($coords2->getRA()->getCoordinate() * 15.0)); + $Y1 = cos(deg2rad($coords2->getDeclination()->getCoordinate())) * + sin(deg2rad($coords2->getRA()->getCoordinate() * 15.0)); + $Z1 = sin(deg2rad($coords2->getDeclination()->getCoordinate())); + + $X2 = cos(deg2rad($coords3->getDeclination()->getCoordinate())) * + cos(deg2rad($coords3->getRA()->getCoordinate() * 15.0)); + $Y2 = cos(deg2rad($coords3->getDeclination()->getCoordinate())) * + sin(deg2rad($coords3->getRA()->getCoordinate() * 15.0)); + $Z2 = sin(deg2rad($coords3->getDeclination()->getCoordinate())); + + $A = $Y1 * $Z2 - $Z1 * $Y2; + $B = $Z1 * $X2 - $X1 * $Z2; + $C = $X1 * $Y2 - $Y1 * $X2; + + $m = tan(deg2rad($this->getRA()->getCoordinate() * 15.0)); + $n = tan(deg2rad($this->getDeclination()->getCoordinate())) + / cos(deg2rad($this->getRA()->getCoordinate() * 15.0)); + + $omega = rad2deg( + abs( + asin( + ($A + $B * $m + $C * $n) / + (sqrt($A * $A + $B * $B + $C * $C) * sqrt(1 + $m * $m + $n * $n)) + ) + ) + ); + + return new Coordinate($omega, 0.0, 90.0); + } } diff --git a/src/deepskylog/AstronomyLibrary/Coordinates/GalacticCoordinates.php b/src/deepskylog/AstronomyLibrary/Coordinates/GalacticCoordinates.php index 0b12103..3709e91 100644 --- a/src/deepskylog/AstronomyLibrary/Coordinates/GalacticCoordinates.php +++ b/src/deepskylog/AstronomyLibrary/Coordinates/GalacticCoordinates.php @@ -108,6 +108,7 @@ public function printLatitude(): string /** * Converts the galactic coordinates to equatorial coordinates. + * Chapter 13 of Astronomical Algorithms. * * @return EquatorialCoordinates The equatorial coordinates */ diff --git a/src/deepskylog/AstronomyLibrary/Coordinates/HorizontalCoordinates.php b/src/deepskylog/AstronomyLibrary/Coordinates/HorizontalCoordinates.php index f93f4f0..3abcf3d 100644 --- a/src/deepskylog/AstronomyLibrary/Coordinates/HorizontalCoordinates.php +++ b/src/deepskylog/AstronomyLibrary/Coordinates/HorizontalCoordinates.php @@ -110,6 +110,7 @@ public function printAltitude(): string /** * Converts the local horizontal coordinates to equatorial coordinates. + * Chapter 13 of Astronomical Algorithms. * * @param GeographicalCoordinates $geo_coords the geographical * coordinates @@ -178,8 +179,9 @@ public function convertToEquatorial( /** * Calculates the refaction (in minutes of arc) if the apparent * height is given. + * Chapter 16 of Astronomical Algorithms. * - * @return float The refraction in minutes of arc. + * @return float the refraction in minutes of arc */ public function calculateRefractionFromApparentAltitude(): float { @@ -196,8 +198,9 @@ public function calculateRefractionFromApparentAltitude(): float /** * Calculates the refaction (in minutes of arc) if the true * height is given. + * Chapter 16 of Astronomical Algorithms. * - * @return float The refraction in minutes of arc. + * @return float the refraction in minutes of arc */ public function calculateRefractionFromTrueAltitude(): float { diff --git a/src/deepskylog/AstronomyLibrary/Targets/Moon.php b/src/deepskylog/AstronomyLibrary/Targets/Moon.php index 9344560..0f190ec 100644 --- a/src/deepskylog/AstronomyLibrary/Targets/Moon.php +++ b/src/deepskylog/AstronomyLibrary/Targets/Moon.php @@ -38,7 +38,7 @@ public function __construct() /** * Calculates the horizontal moon parallax. * - * To implement from chapter 29. + * To implement from chapter 30. * * @return float the horizontal moon parallax */ diff --git a/src/deepskylog/AstronomyLibrary/Targets/Target.php b/src/deepskylog/AstronomyLibrary/Targets/Target.php index 00db2a9..63e26a3 100644 --- a/src/deepskylog/AstronomyLibrary/Targets/Target.php +++ b/src/deepskylog/AstronomyLibrary/Targets/Target.php @@ -209,12 +209,13 @@ public function getEquatorialCoordinatesTomorrow(): EquatorialCoordinates /** * Get the transit time of this object. + * Chapter 15 of Astronomical Algorithms. * * @return Carbon the transit time of the object **/ public function getTransit(): Carbon { - if (! $this->_transit) { + if (!$this->_transit) { throw new RuntimeException( 'First execute the calculateEphemerides method' ); @@ -225,13 +226,14 @@ public function getTransit(): Carbon /** * Get the rising time of this object. + * Chapter 15 of Astronomical Algorithms. * * @return Carbon The rising time of the object or null if the object does not * set **/ public function getRising(): ?Carbon { - if (! $this->_transit) { + if (!$this->_transit) { throw new RuntimeException( 'First execute the calculateEphemerides method' ); @@ -242,13 +244,14 @@ public function getRising(): ?Carbon /** * Get the setting time of this object. + * Chapter 15 of Astronomical Algorithms. * * @return Carbon The setting time of the object or null if the object does * not set **/ public function getSetting(): ?Carbon { - if (! $this->_transit) { + if (!$this->_transit) { throw new RuntimeException( 'First execute the calculateEphemerides method' ); @@ -259,12 +262,13 @@ public function getSetting(): ?Carbon /** * Get the maximum height of the target during the year. + * Chapter 15 of Astronomical Algorithms. * * @return Coordinate the maximum height of the target during the year **/ public function getMaxHeight(): ?Coordinate { - if (! $this->_transit) { + if (!$this->_transit) { throw new RuntimeException( 'First execute the calculateEphemerides method' ); @@ -278,12 +282,13 @@ public function getMaxHeight(): ?Coordinate * no astronomical darkness during the night, the maximum height * during the nautical brightness is taken. If there is also no * nautical brightness, null is returned. + * Chapter 15 of Astronomical Algorithms. * * @return Coordinate the maximum height of the target during the year **/ public function getMaxHeightAtNight(): ?Coordinate { - if (! $this->_transit) { + if (!$this->_transit) { throw new RuntimeException( 'First execute the calculateEphemerides method' ); @@ -294,12 +299,13 @@ public function getMaxHeightAtNight(): ?Coordinate /** * Get the best time to observe this target at the given date. + * Chapter 15 of Astronomical Algorithms. * * @return Carbon The best time to observe the target at the given date **/ public function getBestTimeToObserve(): ?Carbon { - if (! $this->_transit) { + if (!$this->_transit) { throw new RuntimeException( 'First execute the calculateEphemerides method' ); @@ -310,6 +316,7 @@ public function getBestTimeToObserve(): ?Carbon /** * Calculate rising and the setting of the object. + * Chapter 15 of Astronomical Algorithms. * * @param GeographicalCoordinates $geo_coords The geographical * coordinates of the observer @@ -552,7 +559,7 @@ public function calculateEphemerides( } } - if (! $during_night) { + if (!$during_night) { $th = new Coordinate($transitHeight, -90.0, 90.0); // Calculate the height at the end of the night @@ -654,6 +661,7 @@ public function calculateEphemerides( /** * Calculates the height of the object at a given moment. + * Chapter 15 of Astronomical Algorithms. * * @param float $theta0 Theta0 of the target * @param float $time The time to calculate the @@ -689,7 +697,7 @@ private function _calculateHeight( $theta = $this->_calculateTheta($theta0, $time); $n = $this->_calculateN($time, $deltaT); - if (! $targetDoesNotMove) { + if (!$targetDoesNotMove) { $alphaInterpol = $this->_interpolate( $this->getEquatorialCoordinatesToday()->getRA()->getCoordinate(), $n, @@ -877,7 +885,7 @@ public function altitudeGraph( GeographicalCoordinates $geo_coords, Carbon $date ): string { - if (! $this->_altitudeChart) { + if (!$this->_altitudeChart) { $image = imagecreatetruecolor(1000, 400); // Show the night @@ -1046,7 +1054,7 @@ public function altitudeGraph( $rawImageBytes = ob_get_clean(); $this->_altitudeChart = ""; + . base64_encode($rawImageBytes) . "' />"; } return $this->_altitudeChart; diff --git a/src/deepskylog/AstronomyLibrary/Time.php b/src/deepskylog/AstronomyLibrary/Time.php index 83e8287..ac73f35 100644 --- a/src/deepskylog/AstronomyLibrary/Time.php +++ b/src/deepskylog/AstronomyLibrary/Time.php @@ -140,7 +140,7 @@ public static function fromJd(float $jd): Carbon /** * Returns the dynamical time as the time + delta t. - * Chapter 9 in Astronomical Algorithms. + * Chapter 10 in Astronomical Algorithms. * * @param Carbon $date The date * @@ -153,7 +153,7 @@ public static function dynamicalTime(Carbon $date): Carbon /** * Calculates delta t for the given date. - * Chapter 9 in Astronomical Algorithms. + * Chapter 10 in Astronomical Algorithms. * * @param Carbon $date The date * @@ -221,7 +221,7 @@ public static function deltaT(Carbon $date): float /** * Calculates the mean siderial time for the given date. - * Chapter 11 in Astronomical Algorithms. + * Chapter 12 in Astronomical Algorithms. * * @param Carbon $date The date * @param GeographicalCoordinates $coords The geographical coordinates @@ -265,7 +265,7 @@ public static function meanSiderialTime( /** * Calculates the apparent siderial time for the given date. - * Chapter 11 in Astronomical Algorithms. + * Chapter 12 in Astronomical Algorithms. * * @param Carbon $date The date * @param GeographicalCoordinates $coords The geographical coordinates @@ -280,7 +280,7 @@ public static function apparentSiderialTime( ): Carbon { $date = $date->copy()->timezone('UTC'); $siderialTime = self::meanSiderialTime($date, $coords); - if (! $nutation) { + if (!$nutation) { $jd = self::getJd($date); $nutation = self::nutation($jd); @@ -296,7 +296,7 @@ public static function apparentSiderialTime( /** * Calculates the apparent siderial time for the given date, at midnight, * in Greenwich. - * Chapter 11 in Astronomical Algorithms. + * Chapter 12 in Astronomical Algorithms. * * @param Carbon $date The date * @@ -316,7 +316,7 @@ public static function apparentSiderialTimeGreenwich( /** * Calculates the nutation for the given julian day. - * Chapter 21 of Astronomical Algorithms. + * Chapter 22 of Astronomical Algorithms. * * @param float $jd The Julian day * diff --git a/tests/Unit/EquatorialCoordinatesTest.php b/tests/Unit/EquatorialCoordinatesTest.php index ab70e11..9352ccd 100644 --- a/tests/Unit/EquatorialCoordinatesTest.php +++ b/tests/Unit/EquatorialCoordinatesTest.php @@ -218,7 +218,7 @@ public function testAngularSeparation() } /** - * Test bodies in straight line/**. + * Test bodies in straight line. * * @return None */ @@ -237,4 +237,39 @@ public function testBodiesInStraightLine() $mars = new EquatorialCoordinates(8.022644129, 21.472188347); $this->assertTrue($mars->isInStraightLine($castor, $pollux)); } + + /** + * Test deviation of three bodies from a straight line. + * + * @return None + */ + public function testDeviationFromStraightLine() + { + // Delta Ori + $delta = new EquatorialCoordinates(5.5334444, -0.29913888); + // Epsilon Ori + $eps = new EquatorialCoordinates(5.60355833, -1.20194444); + // Ksi Ori + $ksi = new EquatorialCoordinates(5.679311111, -1.94258333); + $this->assertEqualsWithDelta( + $eps->deviationFromStraightLine($delta, $ksi)->getCoordinate(), + 0.089876, + 0.001 + ); + + // Alpha Uma + $alpha = new EquatorialCoordinates(11.062129444, 61.750894444); + + // Beta Uma + $beta = new EquatorialCoordinates(11.030689444, 56.3824027778); + + // Polaris + $polaris = new EquatorialCoordinates(2.530195556, 89.26408889); + + $this->assertEqualsWithDelta( + $polaris->deviationFromStraightLine($alpha, $beta)->getCoordinate(), + 1.91853, + 0.001 + ); + } } From 5cb5a7e9109e64ca4cc59ef173f3bd8c478812cf Mon Sep 17 00:00:00 2001 From: Wim De Meester Date: Fri, 31 Jul 2020 12:52:32 +0000 Subject: [PATCH 3/3] Apply fixes from StyleCI --- .../AstronomyLibrary/Targets/Target.php | 20 +++++++++---------- src/deepskylog/AstronomyLibrary/Time.php | 2 +- tests/Unit/EquatorialCoordinatesTest.php | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/deepskylog/AstronomyLibrary/Targets/Target.php b/src/deepskylog/AstronomyLibrary/Targets/Target.php index 63e26a3..98410fb 100644 --- a/src/deepskylog/AstronomyLibrary/Targets/Target.php +++ b/src/deepskylog/AstronomyLibrary/Targets/Target.php @@ -215,7 +215,7 @@ public function getEquatorialCoordinatesTomorrow(): EquatorialCoordinates **/ public function getTransit(): Carbon { - if (!$this->_transit) { + if (! $this->_transit) { throw new RuntimeException( 'First execute the calculateEphemerides method' ); @@ -233,7 +233,7 @@ public function getTransit(): Carbon **/ public function getRising(): ?Carbon { - if (!$this->_transit) { + if (! $this->_transit) { throw new RuntimeException( 'First execute the calculateEphemerides method' ); @@ -251,7 +251,7 @@ public function getRising(): ?Carbon **/ public function getSetting(): ?Carbon { - if (!$this->_transit) { + if (! $this->_transit) { throw new RuntimeException( 'First execute the calculateEphemerides method' ); @@ -268,7 +268,7 @@ public function getSetting(): ?Carbon **/ public function getMaxHeight(): ?Coordinate { - if (!$this->_transit) { + if (! $this->_transit) { throw new RuntimeException( 'First execute the calculateEphemerides method' ); @@ -288,7 +288,7 @@ public function getMaxHeight(): ?Coordinate **/ public function getMaxHeightAtNight(): ?Coordinate { - if (!$this->_transit) { + if (! $this->_transit) { throw new RuntimeException( 'First execute the calculateEphemerides method' ); @@ -305,7 +305,7 @@ public function getMaxHeightAtNight(): ?Coordinate **/ public function getBestTimeToObserve(): ?Carbon { - if (!$this->_transit) { + if (! $this->_transit) { throw new RuntimeException( 'First execute the calculateEphemerides method' ); @@ -559,7 +559,7 @@ public function calculateEphemerides( } } - if (!$during_night) { + if (! $during_night) { $th = new Coordinate($transitHeight, -90.0, 90.0); // Calculate the height at the end of the night @@ -697,7 +697,7 @@ private function _calculateHeight( $theta = $this->_calculateTheta($theta0, $time); $n = $this->_calculateN($time, $deltaT); - if (!$targetDoesNotMove) { + if (! $targetDoesNotMove) { $alphaInterpol = $this->_interpolate( $this->getEquatorialCoordinatesToday()->getRA()->getCoordinate(), $n, @@ -885,7 +885,7 @@ public function altitudeGraph( GeographicalCoordinates $geo_coords, Carbon $date ): string { - if (!$this->_altitudeChart) { + if (! $this->_altitudeChart) { $image = imagecreatetruecolor(1000, 400); // Show the night @@ -1054,7 +1054,7 @@ public function altitudeGraph( $rawImageBytes = ob_get_clean(); $this->_altitudeChart = ""; + .base64_encode($rawImageBytes)."' />"; } return $this->_altitudeChart; diff --git a/src/deepskylog/AstronomyLibrary/Time.php b/src/deepskylog/AstronomyLibrary/Time.php index ac73f35..0b5d3f0 100644 --- a/src/deepskylog/AstronomyLibrary/Time.php +++ b/src/deepskylog/AstronomyLibrary/Time.php @@ -280,7 +280,7 @@ public static function apparentSiderialTime( ): Carbon { $date = $date->copy()->timezone('UTC'); $siderialTime = self::meanSiderialTime($date, $coords); - if (!$nutation) { + if (! $nutation) { $jd = self::getJd($date); $nutation = self::nutation($jd); diff --git a/tests/Unit/EquatorialCoordinatesTest.php b/tests/Unit/EquatorialCoordinatesTest.php index 9352ccd..d27e880 100644 --- a/tests/Unit/EquatorialCoordinatesTest.php +++ b/tests/Unit/EquatorialCoordinatesTest.php @@ -36,7 +36,7 @@ class EquatorialCoordinatesTest extends BaseTestCase * * @var string */ - protected $appPath = __DIR__ . '/../../vendor/laravel/laravel/bootstrap/app.php'; + protected $appPath = __DIR__.'/../../vendor/laravel/laravel/bootstrap/app.php'; /** * Setup the test environment.