Skip to content

Commit

Permalink
small refactoring with zodiac systems and whole + equal sign house sy…
Browse files Browse the repository at this point in the history
…stems
  • Loading branch information
0xStarcat committed Sep 30, 2019
1 parent d6ebd9f commit 65f646a
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 15 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The goal is to allow someone to:

=> the positions for all major bodies as they relate to the ecliptic for a given datetime and origin (`Sun`, `Moon`, `Mercury`, `Venus`, `Mars`, `Jupiter`, `Saturn`, `Uranus`, `Neptune`, `Pluto`)

=> the cusps of each astrological sign as they relate to the 2D ecliptic chart for a given datetime, origin, and a particular house system.
=> ~~the cusps of each astrological sign as they relate to the 2D ecliptic chart for a given datetime, origin, and a particular house system.~~

=> ~~the cusps of each house within multiple house systems.~~ (Placidus, Koch, Topocentric, Regiomontanus, Whole Sign, and Equal House added.

Expand All @@ -32,7 +32,9 @@ The goal is to allow someone to:

This is a work in progress. Progress is marked off by items above being ~~struck out~~.

I'm open to requests for house systems. I'm currently stopped at 6 - we have 2 "modern" systems (Topocentric, Koch), 2 "medieval" systems (Placidus, Regiomontanus), and 2 "ancient" systems (Whole Sign, Equal House). My formula resource "An Astrological House Formulary" by Michael P. Munkasey has many more house formulas I can implement if wanted. Hopefully I covered the most popular ones.
- I'm open to requests for house systems. I'm currently stopped at 6 - we have 2 "modern" systems (Topocentric, Koch), 2 "medieval" systems (Placidus, Regiomontanus), and 2 "ancient" systems (Whole Sign, Equal House). My formula resource "An Astrological House Formulary" by Michael P. Munkasey has many more house formulas I can implement if wanted. Hopefully I covered the most popular ones.

- Need to refactor the way house cusps correspond to sidereal and astronomical zodiacs. This includes undoing how signs are determined in ZodiacPosition by zodiac, and instead setting Aries to 0deg for all zodiacs and adjusting the positions that are calculated in Horoscope.js accordingly.

## Installation

Expand Down
6 changes: 3 additions & 3 deletions dist/main.bundle.js

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions src/Horoscope.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Horoscope {
get Midheaven() {
const decimalDegrees = getMidheavenSun({localSiderealTime: this.origin.localSiderealTime})
const sign = getZodiacSign({decimalDegrees: decimalDegrees, zodiac: this._zodiac})
console.log(decimalDegrees, sign)
return new ZodiacPosition({decimalDegrees: decimalDegrees, sign: sign})
}

Expand All @@ -71,7 +72,7 @@ class Horoscope {
let cuspsArray
switch (string) {
case 'equal house':
cuspsArray = calculateEqualHouseCusps({ascendant: this.Ascendant.DecimalDegrees})
cuspsArray = calculateEqualHouseCusps({ascendant: this.Ascendant.DecimalDegrees, startingDegree: Sign.ZodiacStartOffset(this._zodiac)})
break
case 'koch':
cuspsArray = calculateKochHouseCusps({rightAscensionMC: this.origin.localSiderealTime, midheaven: this.Midheaven.DecimalDegrees, ascendant: this.Ascendant.DecimalDegrees, latitude: this.origin.latitude})
Expand All @@ -86,13 +87,14 @@ class Horoscope {
cuspsArray = calculateTopocentricHouseCusps({rightAscensionMC: this.origin.localSiderealTime, midheaven: this.Midheaven.DecimalDegrees, ascendant: this.Ascendant.DecimalDegrees, latitude: this.origin.latitude})
break
case 'whole sign':
cuspsArray = calculateWholeSignHouseCusps({ascendant: this.Ascendant.DecimalDegrees})
cuspsArray = calculateWholeSignHouseCusps({ascendant: this.Ascendant.DecimalDegrees, startingDegree: Sign.ZodiacStartOffset(this._zodiac)})
break
default:
cuspsArray = calculatePlacidianHouseCusps({rightAscensionMC: this.origin.localSiderealTime, midheaven: this.Midheaven.DecimalDegrees, ascendant: this.Ascendant.DecimalDegrees, latitude: this.origin.latitude})
break
}

console.log(cuspsArray)
return cuspsArray.map(cusp => new ZodiacPosition({decimalDegrees: cusp, sign: getZodiacSign({decimalDegrees: cusp, zodiac: this._zodiac})}))
}

Expand Down Expand Up @@ -143,7 +145,7 @@ class Horoscope {

calculateZodiacCusps() {
return new Array(12).fill(undefined).map((c, index) => {
const zodiacOffset = Sign.Formatted(this._zodiac).find((s => s.id === 0)).ZodiacStart
const zodiacOffset = Sign.ZodiacStartOffset(this._zodiac)
return parseFloat(modulo((this.Ascendant.DecimalDegrees - zodiacOffset) - (index * 30), 360).toFixed(4))
})
}
Expand Down
4 changes: 4 additions & 0 deletions src/Sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ class Sign {

}

static ZodiacStartOffset(zodiac) {
return Sign.Formatted(zodiac).find((s => s.id === 0)).ZodiacStart
}

static get Data() {
return [{
id: 0,
Expand Down
18 changes: 12 additions & 6 deletions src/utilities/astrology.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ export const getSignFromDD = decimalDegree => {

const getZodiacSignFromRange = (signs, decimalDegrees) => {
return signs.find(sign => {
const start = sign.ZodiacStart
let start = sign.ZodiacStart
let end = sign.ZodiacEnd
if (start > end) { end += 360 }
if (start > end) {
decimalDegrees = decimalDegrees < start ? decimalDegrees + 360 : decimalDegrees
end += 360
}
console.log(start, end, decimalDegrees)
return start <= decimalDegrees && end > decimalDegrees
})
}
Expand All @@ -40,6 +44,7 @@ export const getZodiacSign = ({decimalDegrees=0.00, zodiac='tropical'}={}) => {
case 'astronomical':
return getZodiacSignFromRange(Sign.Astronomical, decimalDegrees)
case 'sidereal':
console.log(getZodiacSignFromRange(Sign.Sidereal, decimalDegrees))
return getZodiacSignFromRange(Sign.Sidereal, decimalDegrees)
case 'tropical':
return getZodiacSignFromRange(Sign.Tropical, decimalDegrees)
Expand Down Expand Up @@ -378,24 +383,25 @@ export const calculateTopocentricHouseCusps = ({rightAscensionMC=0.00, midheaven
return calculateCusps1(ascendant, midheaven, calculatedCusp)
}

export const calculateEqualHouseCusps = ({ascendant=0.00}={}) => {
export const calculateEqualHouseCusps = ({ascendant=0.00, zodiacStartOffset=0.00}={}) => {
// The ascendant is taken as the first house and each house is 30 degrees further along the zodiac
//////////
// * float ascendant
// returns => [1..12] (array of 12 floats marking the cusp of each house)
/////////
return new Array(12).fill(undefined).map((el, index) => {
return modulo(index ? (index * 30) + ascendant : index + ascendant, 360).toFixed(4)
const startingDegree = ascendant + zodiacStartOffset
return parseFloat(modulo(index ? (index * 30) + startingDegree : index + startingDegree, 360).toFixed(4))
})
}

export const calculateWholeSignHouseCusps = ({ascendant=0.00}={}) => {
export const calculateWholeSignHouseCusps = ({ascendant=0.00, zodiacStartOffset=0.00}={}) => {
// The ascendant is taken as the first house and each house is assigned to each of the signs in zodiacal order, with each of the twelve houses exactly coinciding with the start and end of each sign
//////////
// * float ascendant
// returns => [1..12] (array of 12 floats marking the cusp of each house)
/////////
const startingDegree = Math.floor(ascendant / 30) * 30
const startingDegree = Math.floor(modulo(ascendant + zodiacStartOffset, 360) / 30) * 30
return new Array(12).fill(undefined).map((el, index) => {
return modulo(index ? (index * 30) + startingDegree : index + startingDegree, 360)
})
Expand Down
2 changes: 1 addition & 1 deletion tests/Horoscope.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('Midheaven & ascendant calculations', () => {

describe('House cusp calculation', () => {
test('Equal House', () => {
expect(new Horoscope({origin: defaultOrigin, houseSystem: 'equal house'}).HouseCusps.map(c => c.DecimalDegrees)).toEqual(["169.4304","199.4304","229.4304","259.4304","289.4304","319.4304","349.4304","19.4304","49.4304","79.4304","109.4304","139.4304"])
expect(new Horoscope({origin: defaultOrigin, houseSystem: 'equal house'}).HouseCusps.map(c => c.DecimalDegrees)).toEqual([169.4304, 199.4304, 229.4304, 259.4304, 289.4304, 319.4304, 349.4304, 19.4304, 49.4304, 79.4304, 109.4304, 139.4304,])
})

test('Koch', () => {
Expand Down

0 comments on commit 65f646a

Please sign in to comment.