Calculating the ascendant and midheaven #340
-
I am trying to calculate the ascendant and midheaven astrological points. My understanding is that the ascendant is calculated by determining the ecliptic longitude of due east on the horizon at a specific place and time. The midheaven is the ecliptic longitude of the zenith. I have tried implementing this using astronomy-engine, but my implementation seems to produce incorrect results. I am unsure whether it is a mistake in my understanding of the astrology, or if it's a bug in the code, but any help would be appreciated. export function calculateAscendant(params: {
latitude: number;
longitude: number;
date: Date;
}) {
const {latitude, longitude, date} = params;
const observer = new Astronomy.Observer(latitude, longitude, 0);
const horizVector: Astronomy.Vector = new Astronomy.Vector(
0, // north-south
1, // west-east
0, // up-down
new Astronomy.AstroTime(date)
);
const rotation = Astronomy.Rotation_HOR_EQJ(date, observer);
const eqjVector = Astronomy.RotateVector(rotation, horizVector);
const ecliptic = Astronomy.Ecliptic(eqjVector);
return ecliptic.elon;
} To get the midheaven, I instead initialize the const horizVector: Astronomy.Vector = new Astronomy.Vector(
0, // north-south
0, // west-east
1, // up-down
new Astronomy.AstroTime(date)
); Note, a similar question was asked before here. Also, thank you for this library! I love this project. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 9 replies
-
So far your approach looks mostly correct. I spotted one problem with the vector you intended to point due east. It actually points west: x = north, y = west, z = up. So the first vector should be (0, -1, 0). Your midheaven calculation looks correct. Did it give you the expected answer? |
Beta Was this translation helpful? Give feedback.
-
Makes sense. In case it proves useful to anyone else, here's an implementation of the Meeus formulas for ascendant and midheaven using astronomy-engine to get the ecliptic obliquity and sidereal time: import * as Astronomy from 'astronomy-engine';
function calculateAscendant(params: {
latitude: number;
longitude: number;
date: Date;
}) {
const {date, latitude} = params;
const localSiderealRadians = localSiderealTimeRadians(params);
const eclipticObliquity = degreesToRadians(
Astronomy.e_tilt(new Astronomy.AstroTime(date)).tobl
);
const x =
Math.sin(localSiderealRadians) * Math.cos(eclipticObliquity) +
Math.tan(degreesToRadians(latitude)) * Math.sin(eclipticObliquity);
const y = -1 * Math.cos(localSiderealRadians);
const celestialLongitudeRadians = Math.atan(y / x);
let ascendantDegrees = radiansToDegrees(celestialLongitudeRadians);
// Correcting the quadrant
if (x < 0) {
ascendantDegrees += 180;
} else {
ascendantDegrees += 360;
}
if (ascendantDegrees < 180) {
ascendantDegrees += 180;
} else {
ascendantDegrees -= 180;
}
return ascendantDegrees;
}
function calculateMidheaven(params: {
latitude: number;
longitude: number;
date: Date;
}) {
const {date} = params;
const localSiderealRadians = localSiderealTimeRadians(params);
const eclipticObliquity = degreesToRadians(
Astronomy.e_tilt(new Astronomy.AstroTime(date)).tobl
);
const numerator = Math.tan(localSiderealRadians);
const denominator = Math.cos(degreesToRadians(eclipticObliquity));
let midheavenDegrees = radiansToDegrees(Math.atan(numerator / denominator));
// Correcting the quadrant
if (midheavenDegrees < 0) {
midheavenDegrees += 360;
}
const localSiderealDegrees = radiansToDegrees(localSiderealRadians);
if (midheavenDegrees > localSiderealDegrees) {
midheavenDegrees -= 180;
}
if (midheavenDegrees < 0) {
midheavenDegrees += 180;
}
if (midheavenDegrees < 180 && localSiderealDegrees >= 180) {
midheavenDegrees += 180;
}
midheavenDegrees = (midheavenDegrees + 360) % 360;
return midheavenDegrees;
}
export function localSiderealTimeRadians(params: {
longitude: number;
date: Date;
}): number {
const {longitude, date} = params;
const grenichSiderealTime = Astronomy.SiderealTime(date);
const localSiderealTime = grenichSiderealTime + degreesToHours(longitude);
let localSiderealDegrees = hoursToDegrees(localSiderealTime);
localSiderealDegrees = (localSiderealDegrees + 360) % 360;
const localSiderealRadians = degreesToRadians(localSiderealDegrees);
return localSiderealRadians;
}
function hoursToDegrees(hours: number): number {
return hours * 15;
}
function degreesToHours(degrees: number): number {
return degrees / 15;
}
function degreesToRadians(degrees: number): number {
return degrees / 180 * Math.PI
}
function radiansToDegrees(radians: number): number {
return radians * 180 / Math.PI;
} |
Beta Was this translation helpful? Give feedback.
-
@KurtPreston good job kurt. I ended up implementing the same - asc, midheaven and lunar nodes. I was able to verify asc and lunar nodes but not mid heaven. Any source where i can verify the same ? |
Beta Was this translation helpful? Give feedback.
Makes sense. In case it proves useful to anyone else, here's an implementation of the Meeus formulas for ascendant and midheaven using astronomy-engine to get the ecliptic obliquity and sidereal time: