Skip to content
This repository has been archived by the owner on Apr 25, 2020. It is now read-only.

Commit

Permalink
v2.1.0: expose sin/cos of hour angle on observer rather than hour ang…
Browse files Browse the repository at this point in the history
…le (#15)
  • Loading branch information
Jay LaPorte committed Apr 8, 2019
1 parent edc21b1 commit 474d3a9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions lib/solar.js
Expand Up @@ -149,8 +149,9 @@ function sin_elevation(ms, lat, lon) {

// Solar position classes. Helpful if you need to cache results!
class Location {
constructor(hour_angle, sin_elevation) {
this.hour_angle = hour_angle;
constructor(sin_hour_angle, cos_hour_angle, sin_elevation) {
this.sin_hour_angle = sin_hour_angle;
this.cos_hour_angle = cos_hour_angle;
this.sin_elevation = sin_elevation;
}

Expand Down Expand Up @@ -190,9 +191,12 @@ class Time {
const cos_lat = Math.cos(lat * RAD);
const sin_dec = this.sin_declination;
const cos_dec = Math.sqrt(1 - sin_dec * sin_dec);
const sin_hour_angle = Math.sin(hour_angle);
const cos_hour_angle = Math.cos(hour_angle);
return new Location(
hour_angle,
sin_lat * sin_dec + cos_lat * cos_dec * Math.cos(hour_angle)
sin_hour_angle,
cos_hour_angle,
sin_lat * sin_dec + cos_lat * cos_dec * cos_hour_angle
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "astro",
"version": "2.0.4",
"version": "2.1.0",
"description": "Solar and lunar position calculations",
"main": "index.js",
"devDependencies": {
Expand Down

0 comments on commit 474d3a9

Please sign in to comment.