I am trying to draw natal chart using swedll32.dll in c#. when I call function swe_calc_ut() using dllimport very first it gives me correct result . but If i call any other function of swedll32.dll before this and after that make a call to swe_calc_ut() then it returns NaN values in result double[]. here is the code..
Main.cs
Class Main
{
UniversalTOBUTJD = Sweph.swe_julday(birthTimeUTC.Year, birthTimeUTC.Month,
birthTimeUTC.Day, birthTimeUTC.TimeOfDay.TotalHours);
double[] tret = new Double[6] { 0, 0, 0, 0, 0, 0 };
Sweph.swe_calc_ut(UniversalTOBUTJD , 0, 0, tret);**/// this returns NaN in tret arrey**
}
and if I try like below: here I used hard coded value for universal time, which I got by calling Sweph.swe_julday() function
{
Sweph.swe_calc_ut(2443436.659722222, 0, 0, tret); **/// this returns correct values in tret array**
UniversalTOBUTJD = Sweph.swe_julday(birthTimeUTC.Year, birthTimeUTC.Month,
birthTimeUTC.Day, birthTimeUTC.TimeOfDay.TotalHours);
double[] tret = new Double[6] { 0, 0, 0, 0, 0, 0 };
}
Sweph.cs Class Sweph {
[DllImport("swedll32.dll", CharSet = CharSet.Ansi, EntryPoint = "swe_julday")]
public extern static double xyz_swe_julday(int year, int month, int day, double hour, int gregflag); //no
/// <summary>
/// swe_julday - It computes year, month, day and hour from a Julian day number
/// </summary>
/// <param name="year">Year</param>
/// <param name="month">Month</param>
/// <param name="day">Day</param>
/// <param name="hour">Hour</param>
/// <returns>Returns the Julian day</returns>
public static double swe_julday(int year, int month, int day, double hour)
{
return xyz_swe_julday(year, month, day, hour, 1);
}
[DllImport("swedll32.dll", CharSet = CharSet.Ansi, EntryPoint = "swe_calc_ut")]
private extern static int xyz_swe_calc_ut(double tjd_ut, int ipl, int iflag,
double[] xx, StringBuilder serr);
/// <summary>
/// swe_calc_ut - Compute a planet or other bodies
/// </summary>
/// <param name="tjd_ut">Julian day, Universal Time</param>
/// <param name="ipl">planet number</param>
/// <param name="addFlags">a 32bit integercontaining bit flags that indicate what kind of computation wanted</param>
/// <param name="xx">array of 6 doubles for Longitude,latitude,distance,speed in long, speed in lat and speed in dist</param>
//public static void getPlanet(double tjd_ut, int ipl, int addFlags, double[] xx)
public static void swe_calc_ut(double tjd_ut, int ipl, int addFlags, double[] xx)
{
StringBuilder serr = new StringBuilder(256);
int ret = xyz_swe_calc_ut(tjd_ut, ipl, iflag | addFlags, xx, serr);
}
}
please help I really stuck here.