panchang-ts 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +21 -12
- package/dist/index.js +21 -12
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -76,6 +76,13 @@ var JUPITER_GM = 2825345909524226e-22;
|
|
|
76
76
|
var SATURN_GM = 8459715185680659e-23;
|
|
77
77
|
var URANUS_GM = 1292024916781969e-23;
|
|
78
78
|
var NEPTUNE_GM = 1524358900784276e-23;
|
|
79
|
+
function VerifyBoolean(b) {
|
|
80
|
+
if (b !== true && b !== false) {
|
|
81
|
+
console.trace();
|
|
82
|
+
throw `Value is not boolean: ${b}`;
|
|
83
|
+
}
|
|
84
|
+
return b;
|
|
85
|
+
}
|
|
79
86
|
function VerifyNumber(x) {
|
|
80
87
|
if (!Number.isFinite(x)) {
|
|
81
88
|
console.trace();
|
|
@@ -1598,6 +1605,8 @@ function SunPosition(date) {
|
|
|
1598
1605
|
}
|
|
1599
1606
|
function Equator(body, date, observer, ofdate, aberration) {
|
|
1600
1607
|
VerifyObserver(observer);
|
|
1608
|
+
VerifyBoolean(ofdate);
|
|
1609
|
+
VerifyBoolean(aberration);
|
|
1601
1610
|
const time = MakeTime(date);
|
|
1602
1611
|
const gc_observer = geo_pos(time, observer);
|
|
1603
1612
|
const gc = GeoVector(body, time, aberration);
|
|
@@ -2103,24 +2112,30 @@ var BodyPosition = class {
|
|
|
2103
2112
|
}
|
|
2104
2113
|
};
|
|
2105
2114
|
function BackdatePosition(date, observerBody, targetBody, aberration) {
|
|
2115
|
+
VerifyBoolean(aberration);
|
|
2106
2116
|
const time = MakeTime(date);
|
|
2107
2117
|
if (UserDefinedStar(targetBody)) {
|
|
2108
2118
|
const tvec = HelioVector(targetBody, time);
|
|
2109
|
-
{
|
|
2119
|
+
if (aberration) {
|
|
2110
2120
|
const ostate = HelioState(observerBody, time);
|
|
2111
2121
|
const rvec = new Vector(tvec.x - ostate.x, tvec.y - ostate.y, tvec.z - ostate.z, time);
|
|
2112
2122
|
const s = C_AUDAY / rvec.Length();
|
|
2113
2123
|
return new Vector(rvec.x + ostate.vx / s, rvec.y + ostate.vy / s, rvec.z + ostate.vz / s, time);
|
|
2114
2124
|
}
|
|
2125
|
+
const ovec = HelioVector(observerBody, time);
|
|
2126
|
+
return new Vector(tvec.x - ovec.x, tvec.y - ovec.y, tvec.z - ovec.z, time);
|
|
2115
2127
|
}
|
|
2116
2128
|
let observerPos;
|
|
2117
|
-
{
|
|
2129
|
+
if (aberration) {
|
|
2118
2130
|
observerPos = new Vector(0, 0, 0, time);
|
|
2131
|
+
} else {
|
|
2132
|
+
observerPos = HelioVector(observerBody, time);
|
|
2119
2133
|
}
|
|
2120
2134
|
const bpos = new BodyPosition(observerBody, targetBody, aberration, observerPos);
|
|
2121
2135
|
return CorrectLightTravel((t) => bpos.Position(t), time);
|
|
2122
2136
|
}
|
|
2123
2137
|
function GeoVector(body, date, aberration) {
|
|
2138
|
+
VerifyBoolean(aberration);
|
|
2124
2139
|
const time = MakeTime(date);
|
|
2125
2140
|
switch (body) {
|
|
2126
2141
|
case Body.Earth:
|
|
@@ -2266,13 +2281,6 @@ function Search(f, t1, t2, options) {
|
|
|
2266
2281
|
return null;
|
|
2267
2282
|
}
|
|
2268
2283
|
}
|
|
2269
|
-
function EclipticLongitude(body, date) {
|
|
2270
|
-
if (body === Body.Sun)
|
|
2271
|
-
throw "Cannot calculate heliocentric longitude of the Sun.";
|
|
2272
|
-
const hv = HelioVector(body, date);
|
|
2273
|
-
const eclip = Ecliptic(hv);
|
|
2274
|
-
return eclip.elon;
|
|
2275
|
-
}
|
|
2276
2284
|
var AtmosphereInfo = class {
|
|
2277
2285
|
constructor(pressure, temperature, density) {
|
|
2278
2286
|
this.pressure = pressure;
|
|
@@ -4028,12 +4036,13 @@ function meanObliquity(T) {
|
|
|
4028
4036
|
return 23.439291111 - 0.013004167 * T - 164e-9 * T * T + 504e-9 * T * T * T;
|
|
4029
4037
|
}
|
|
4030
4038
|
function getTropicalPlanetLongitude(body, date) {
|
|
4031
|
-
|
|
4039
|
+
const vec = GeoVector(body, MakeTime(date), true);
|
|
4040
|
+
return Ecliptic(vec).elon;
|
|
4032
4041
|
}
|
|
4033
4042
|
function isRetrograde(body, date) {
|
|
4034
4043
|
const dt = 36e5;
|
|
4035
|
-
const lon0 =
|
|
4036
|
-
const lon1 =
|
|
4044
|
+
const lon0 = Ecliptic(GeoVector(body, MakeTime(new Date(date.getTime() - dt)), false)).elon;
|
|
4045
|
+
const lon1 = Ecliptic(GeoVector(body, MakeTime(new Date(date.getTime() + dt)), false)).elon;
|
|
4037
4046
|
let delta = lon1 - lon0;
|
|
4038
4047
|
if (delta > 180) delta -= 360;
|
|
4039
4048
|
if (delta < -180) delta += 360;
|
package/dist/index.js
CHANGED
|
@@ -74,6 +74,13 @@ var JUPITER_GM = 2825345909524226e-22;
|
|
|
74
74
|
var SATURN_GM = 8459715185680659e-23;
|
|
75
75
|
var URANUS_GM = 1292024916781969e-23;
|
|
76
76
|
var NEPTUNE_GM = 1524358900784276e-23;
|
|
77
|
+
function VerifyBoolean(b) {
|
|
78
|
+
if (b !== true && b !== false) {
|
|
79
|
+
console.trace();
|
|
80
|
+
throw `Value is not boolean: ${b}`;
|
|
81
|
+
}
|
|
82
|
+
return b;
|
|
83
|
+
}
|
|
77
84
|
function VerifyNumber(x) {
|
|
78
85
|
if (!Number.isFinite(x)) {
|
|
79
86
|
console.trace();
|
|
@@ -1596,6 +1603,8 @@ function SunPosition(date) {
|
|
|
1596
1603
|
}
|
|
1597
1604
|
function Equator(body, date, observer, ofdate, aberration) {
|
|
1598
1605
|
VerifyObserver(observer);
|
|
1606
|
+
VerifyBoolean(ofdate);
|
|
1607
|
+
VerifyBoolean(aberration);
|
|
1599
1608
|
const time = MakeTime(date);
|
|
1600
1609
|
const gc_observer = geo_pos(time, observer);
|
|
1601
1610
|
const gc = GeoVector(body, time, aberration);
|
|
@@ -2101,24 +2110,30 @@ var BodyPosition = class {
|
|
|
2101
2110
|
}
|
|
2102
2111
|
};
|
|
2103
2112
|
function BackdatePosition(date, observerBody, targetBody, aberration) {
|
|
2113
|
+
VerifyBoolean(aberration);
|
|
2104
2114
|
const time = MakeTime(date);
|
|
2105
2115
|
if (UserDefinedStar(targetBody)) {
|
|
2106
2116
|
const tvec = HelioVector(targetBody, time);
|
|
2107
|
-
{
|
|
2117
|
+
if (aberration) {
|
|
2108
2118
|
const ostate = HelioState(observerBody, time);
|
|
2109
2119
|
const rvec = new Vector(tvec.x - ostate.x, tvec.y - ostate.y, tvec.z - ostate.z, time);
|
|
2110
2120
|
const s = C_AUDAY / rvec.Length();
|
|
2111
2121
|
return new Vector(rvec.x + ostate.vx / s, rvec.y + ostate.vy / s, rvec.z + ostate.vz / s, time);
|
|
2112
2122
|
}
|
|
2123
|
+
const ovec = HelioVector(observerBody, time);
|
|
2124
|
+
return new Vector(tvec.x - ovec.x, tvec.y - ovec.y, tvec.z - ovec.z, time);
|
|
2113
2125
|
}
|
|
2114
2126
|
let observerPos;
|
|
2115
|
-
{
|
|
2127
|
+
if (aberration) {
|
|
2116
2128
|
observerPos = new Vector(0, 0, 0, time);
|
|
2129
|
+
} else {
|
|
2130
|
+
observerPos = HelioVector(observerBody, time);
|
|
2117
2131
|
}
|
|
2118
2132
|
const bpos = new BodyPosition(observerBody, targetBody, aberration, observerPos);
|
|
2119
2133
|
return CorrectLightTravel((t) => bpos.Position(t), time);
|
|
2120
2134
|
}
|
|
2121
2135
|
function GeoVector(body, date, aberration) {
|
|
2136
|
+
VerifyBoolean(aberration);
|
|
2122
2137
|
const time = MakeTime(date);
|
|
2123
2138
|
switch (body) {
|
|
2124
2139
|
case Body.Earth:
|
|
@@ -2264,13 +2279,6 @@ function Search(f, t1, t2, options) {
|
|
|
2264
2279
|
return null;
|
|
2265
2280
|
}
|
|
2266
2281
|
}
|
|
2267
|
-
function EclipticLongitude(body, date) {
|
|
2268
|
-
if (body === Body.Sun)
|
|
2269
|
-
throw "Cannot calculate heliocentric longitude of the Sun.";
|
|
2270
|
-
const hv = HelioVector(body, date);
|
|
2271
|
-
const eclip = Ecliptic(hv);
|
|
2272
|
-
return eclip.elon;
|
|
2273
|
-
}
|
|
2274
2282
|
var AtmosphereInfo = class {
|
|
2275
2283
|
constructor(pressure, temperature, density) {
|
|
2276
2284
|
this.pressure = pressure;
|
|
@@ -4026,12 +4034,13 @@ function meanObliquity(T) {
|
|
|
4026
4034
|
return 23.439291111 - 0.013004167 * T - 164e-9 * T * T + 504e-9 * T * T * T;
|
|
4027
4035
|
}
|
|
4028
4036
|
function getTropicalPlanetLongitude(body, date) {
|
|
4029
|
-
|
|
4037
|
+
const vec = GeoVector(body, MakeTime(date), true);
|
|
4038
|
+
return Ecliptic(vec).elon;
|
|
4030
4039
|
}
|
|
4031
4040
|
function isRetrograde(body, date) {
|
|
4032
4041
|
const dt = 36e5;
|
|
4033
|
-
const lon0 =
|
|
4034
|
-
const lon1 =
|
|
4042
|
+
const lon0 = Ecliptic(GeoVector(body, MakeTime(new Date(date.getTime() - dt)), false)).elon;
|
|
4043
|
+
const lon1 = Ecliptic(GeoVector(body, MakeTime(new Date(date.getTime() + dt)), false)).elon;
|
|
4035
4044
|
let delta = lon1 - lon0;
|
|
4036
4045
|
if (delta > 180) delta -= 360;
|
|
4037
4046
|
if (delta < -180) delta += 360;
|
package/package.json
CHANGED