Guest guest Posted August 5, 2002 Report Share Posted August 5, 2002 Kelly, This is the code you asked me for, thanks, good luck. Cheers, -- Das Goravani , President 2852 Willamette St, #353 Eugene, Oregon, 97405 USA Voice: or <> Home of "Goravani Jyotish" Vedic Astrology Software , and more... #include <stdio.h> #include <math.h> #define JULIAN_2000 2451544L #define JULIAN_1900 2415020L #define JULIAN_1950 2433282L #define JULIAN_CENTURY (JULIAN_2000 - JULIAN_1900) #define JULIAN_1700 (JULIAN_1900 - 2 * JULIAN_CENTURY) #define DEGREE_CHAR ' ' #define integer(x) ((int)(floor(x))) typedef enum {FALSE, TRUE} BOOL; typedef enum {LAHIRI_AYANAMSA, TROPICAL_AYANAMSA, B_V_RAMAN_AYANAMSA, SRI_YUKTESWAR_AYANAMSA, FAGAN_BRADLEY_AYANAMSA, J_N_BHASIN_AYANAMSA, KRISHNAMURTI_AYANAMSA, DELUCE_AYANAMSA, USHA_SHASHI_AYANAMSA, SUNDARA_RAJAN_AYANAMSA, LARRY_ELY_AYANAMSA, SHILL_POND_AYANAMSA, HOUCK_AYANAMSA} iAYANAMSA; typedef struct { int month, day, year; } DATE; typedef struct { int hours, minutes, seconds; } TIME; /* Forward function declarations. */ static double calcJulianDate (const DATE *date); static double degsMinsSecsToDouble (int degs, int mins, int secs); static double timeToDouble (const TIME *time); static double secsToDegs (double x); static double fMod360 (double x); static double dSin (double x); static const char *angleStr (double angle); static void doubleToDegsMinsSecs (double angle, int *degs, int *mins, double *secs); /* Global variables. Usually you'd pass the data in thru these. */ static TIME birthTime = {7, 22, 0}; /* For 7:22 AM. */ static TIME timeZone = {6, 0, 0}; /* For CDT (time zone 6). */ static TIME DST = {1, 0, 0}; /* For daylight savings being in effect.*/ static BOOL westTimeZone = TRUE; static DATE birthDate = {6, 12, 1963}; static iAYANAMSA ayanamsaStyle = LAHIRI_AYANAMSA; void main (void) { double fBirthTime, fTimeZone, fDST, fGMT, aT, aT2; double julian, nutation, ayanamsa = 0; fBirthTime = timeToDouble (&birthTime); fTimeZone = timeToDouble (&timeZone); fDST = timeToDouble (&DST); fGMT = fBirthTime - fDST + (westTimeZone ? fTimeZone : -fTimeZone); julian = calcJulianDate (&birthDate); julian += fGMT / 24.0; aT = (julian - JULIAN_1900 - 0.5) / (365.25 * 100.0); aT2 = aT * aT; /* Precession and Nutation */ { double ln, ms; ln = fMod360 (259.183275 - 1934.142008 * aT + (2e-6 * aT + 0.002078) * aT2); ms = 279.5955778 + 36000.76892 * aT + 0.0003025 * aT2; /* mean long of sun */ nutation = (-(17.2327 + 0.01737 * aT) * dSin (ln) - 1.273 * dSin (2.0 * ms)) / 3600.0; } /* AYANAMSA */ switch (ayanamsaStyle) { case LAHIRI_AYANAMSA: /* 22¿27'37.57" at 01/01/1900 with 50.2564" per year */ ayanamsa = secsToDegs (80857.57 + (5025.64 + 1.11 * aT) * aT); ayanamsa += nutation; break; case B_V_RAMAN_AYANAMSA: /* 21¿00'51.98" at 01/01/1900 with 50.2564" per year */ ayanamsa = secsToDegs (75651.984 + (5025.64 + 1.11 * aT) * aT); ayanamsa += nutation; break; case SRI_YUKTESWAR_AYANAMSA: /* To match David Frawley's "The Astrology of Seers" in 1/1/1950 */ /* 21¿00'41" at 01/01/1900 with 54" per year */ ayanamsa = secsToDegs (75641.0 + (5400.0 + 1.11 * aT) * aT); /* ayanamsa += nutation; */ break; case J_N_BHASIN_AYANAMSA: /* 21¿20'37.69" at 01/01/1900 with 50.2564" per year */ ayanamsa = secsToDegs (76837.69199 + (5025.64 + 1.11 * aT) * aT); ayanamsa += nutation; break; case FAGAN_BRADLEY_AYANAMSA: /* 23¿20'38.15" at 01/01/1900 with 50.2564" per year */ ayanamsa = secsToDegs (84038.148 + (5025.64 + 1.11 * aT) * aT); ayanamsa += nutation; break; case KRISHNAMURTI_AYANAMSA: /* 22¿22'09.59" at 01/01/1900 with 50.23" per year */ ayanamsa = secsToDegs (80529.588 + (5023.0 + 1.11 * aT) * aT); ayanamsa += nutation; break; case DELUCE_AYANAMSA: /* 26¿24'46.98" at 01/01/1900 with 50.2564" per year */ ayanamsa = secsToDegs (95086.98 + (5025.64 + 1.11 * aT) * aT); ayanamsa += nutation; break; case USHA_SHASHI_AYANAMSA: /* 18¿39'39.46" at 01/01/1900 with 50.2564" per year */ ayanamsa = secsToDegs (67179.456 + (5025.64 + 1.11 * aT) * aT); ayanamsa += nutation; break; case SUNDARA_RAJAN_AYANAMSA: /* 21¿30'25.24" at 01/01/1900 with 50.2564" per year */ ayanamsa = secsToDegs (77425.236 + (5025.64 + 1.11 * aT) * aT); ayanamsa += nutation; break; case LARRY_ELY_AYANAMSA: /* 26¿36'39.79" at 01/01/1900 with 50.2564" per year */ ayanamsa = secsToDegs (95799.78 + (5025.64 + 1.11 * aT) * aT); ayanamsa += nutation; break; case SHILL_POND_AYANAMSA: /* 19¿10'37.81" at 01/01/1900 with 50.2564" per year */ ayanamsa = secsToDegs (69037.812 + (5025.64 + 1.11 * aT) * aT); ayanamsa += nutation; break; case HOUCK_AYANAMSA: /* 22¿22'27.57" at 01/01/1900 with 50.2564" per year */ ayanamsa = secsToDegs (80547.57 + (5025.64 + 1.11 * aT) * aT); ayanamsa += nutation; break; case TROPICAL_AYANAMSA: ayanamsa = -nutation; break; } printf ("The ayanamsa is: %s\n", angleStr (ayanamsa)); } static double calcJulianDate (const DATE *date) { double im, julian; /* JULIAN & WEEKDAY */ im = 12.0 * (date->year + 4800.0) + date->month - 3.0; julian = (2.0 * (im - floor (im / 12.0) * 12.0) + 7.0 + 365.0 * im) / 12.0; julian = floor (julian) + date->day + floor (im / 48.0) - 32083.0; if (julian > 2299171.0) julian += floor (im / 4800.0) - floor (im / 1200.0) + 38.0; return julian; } static double degsMinsSecsToDouble (int degs, int mins, int secs) { return degs + (mins + (secs / 60.0)) / 60.0; } static double timeToDouble (const TIME *time) { return degsMinsSecsToDouble (time->hours, time->minutes, time->seconds); } static double secsToDegs (double x) /* convert x from seconds to degrees */ { return x / 3600.0; } static double fMod360 (double x) { x = fmod (x, 360.0); if (x < 0.0) x += 360.0; return x; } static double dSin (double x) /* Returns the sin of x, where x is in degrees instead of radians. */ { return sin (M_PI / 180.0 * x); } static const char *angleStr (double angle) { static char buf[20]; int degs, mins; double secs; doubleToDegsMinsSecs (angle, °s, &mins, &secs); sprintf (buf, "%d%c%02d'%02.4f\"", degs, DEGREE_CHAR, mins, secs); return buf; } static void doubleToDegsMinsSecs (double angle, int *degs, int *mins, double *secs) { BOOL negative = FALSE; if (angle < 0.0) { angle = -angle; negative = TRUE; } *degs = integer (angle); angle = (angle - *degs) * 60.0; *mins = integer (angle); angle = (angle - *mins) * 60.0; *secs = angle; if (negative) *degs = -(*degs); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.