Пример #1
0
/*****************************************************
**
**   LagnaVimsottariDasaExpert   ---   getPortion 
**
******************************************************/
double LagnaVimsottariDasaExpert::getPortion( const Horoscope *h, int &nak )
{
	Calculator *calculator = CalculatorFactory().getCalculator();
	double mlen = h->getVedicLength( OASCENDANT );
	nak = (int)( mlen / NAKSHATRA_LEN );
	return calculator->calcAscendantPortion( h->getDataSet(), mlen );
}
Пример #2
0
/*****************************************************
**
**   EphemExpert   ---   calcLength
**
******************************************************/
int EphemExpert::calcLength()
{
	int i, p, ret = 0;
	unsigned int i1;
	double dummy;
	Calculator *calculator = CalculatorFactory().getCalculator();

	planetdata.clear();
	for ( i1 = 0; i1 < chartprops->getPlanetList().size(); i1++ )
	{
		p = chartprops->getPlanetList()[i1];
		if ( p == OASCENDANT || p == OMERIDIAN || p > MAX_EPHEM_OBJECTS ) continue;
		EphemPlanetData pdata( p );
		for ( i = 0; i <= nb_days; i++ ) // calc length and retrogression
		{
			//d->setDate( i+1, month, year, -tz );
			d->setDate( jd[i] );
			calculator->calcPositionSpeed( d, p, pdata.len[i], dummy, pdata.speed[i], true, chartprops->isVedic() );
			pdata.retro[i] = ( pdata.speed[i] < 0 );
			pdata.rasi[i] = getRasi( pdata.len[i] );
			pdata.nakshatra[i] = getNakshatra( pdata.len[i], N27 );
		}

		if ( pdata.len[0] == 0 && p != OARIES ) ret++;

		planetdata.push_back( pdata );
	}
	clen = true;
	return ret;
}
Пример #3
0
/*****************************************************
**
**   TextHelper   ---   writeAstronomicalData
**
******************************************************/
int TextHelper::writeAstronomicalData()
{
	wxString pname;
	int p, ret = 0;

	Calculator *calculator = CalculatorFactory().getCalculator();
	Formatter *f = Formatter::get();
	Lang lang;

	vector<int> obs1 = chartprops->getPlanetList();
	vector<int> obs;
	for ( unsigned int i = 0; i < obs1.size(); i++ )
	{
		if ( obs1[i] < MAX_EPHEM_OBJECTS ) obs.push_back( obs1[i] );
	}

	if ( show_header ) writer->writeHeader1( _( "Astronomical Positions" ));
	Table table( 4, obs.size() + 1 );
	table.setHeader( 0,  _( "Planet" ));
	table.setHeader( 1,  _( "Longitude" ));
	table.setHeader( 2,  _( "Latitute" ));
	table.setHeader( 3,  _( "Speed (deg/day)" ));
	table.col_line[0] = true;
	table.col_alignment[0] = Align::Right;
	table.col_alignment[1] = Align::Right;

	int line = 1;
	for ( unsigned int i = 0; i < obs.size(); i++ )
	{
		p = obs[i];
		if ( horoscope->getTropicalLength( p ) == 0 ) ret++;
		pname = writer->getObjectName( p, TLARGE);
		table.setEntry( 0, line, pname );
		table.setEntry( 1, line, writer->getPosFormatted( horoscope->getTropicalLength( p ), horoscope->isRetrograde( p ), DEG_PRECISION_MORE ));

		if ( p != OASCENDANT && p != OMERIDIAN )
		{
			table.setEntry( 2, line, f->getLatitudeFormatted( horoscope->getLatitude( p ), DEG_PRECISION_MORE ));
			table.setEntry( 3, line, f->getLenFormatted( horoscope->getSpeed( p ), DEG_PRECISION_MORE ));
		}
		line++;
	}
	writer->writeTable( table );

	Table t2( 2, 5 );
	t2.setHeader( 0,  _( "Name" ));
	t2.setHeader( 1,  _( "Value" ));
	writer->writeHeader2( _( "Ayanamsa" ));
	line = 1;
	for ( int i = 0; i < NB_AYANAMSAS; i++ )
	{
		t2.setEntry( 0, line, lang.getAyanamsaName( i+1 ));
		t2.setEntry( 1, line, f->getDegreesFormatted( calculator->calcAyanamsa( horoscope->getJD(), i+1 ), DEG_PRECISION_MORE ));
		line++;
	}
	t2.setEntry( 0, 4, _( "Custom" ) );
	t2.setEntry( 1, 4, f->getDegreesFormatted( calculator->calcAyanamsa( horoscope->getJD(), 4 ), DEG_PRECISION_MORE ));
	writer->writeTable( t2 );
	return ret;
}
Пример #4
0
/*****************************************************
**
**   MainWindowStatusbar   ---   OnPlanetTimer
**
******************************************************/
void MainWindowStatusbar::OnPlanetTimer( wxTimerEvent& )
{
	wxString t0, t1;
	double mlen, asclen, dummy, nakportion;
	Lang lang;
	Calculator *calculator = CalculatorFactory().getCalculator();
	DataSet d;
	SheetFormatter fmt;

	d.setCurrentDate();
	d.setLocation( *config->defaultLocation );
	asclen = calculator->calcAscendantAya( d.getJD(), d.getLocation()->getLatitude(),
		d.getLocation()->getLongitude(), config->preferVedic );

	calculator->calcPosition( &d, OMOON, mlen, dummy, true, config->preferVedic );

	t0 << fmt.fragment2PlainText( fmt.getObjectName( OASCENDANT, TF_MEDIUM ))
	 << SPACE
	 << fmt.fragment2PlainText( fmt.getPosFormatted( asclen ));
	SetStatusText( t0, 0 );

	t1 << fmt.fragment2PlainText( fmt.getObjectName( OMOON, TF_MEDIUM ))
	 << SPACE
	 << fmt.fragment2PlainText( fmt.getPosFormatted( mlen ));
	if ( config->preferVedic )
	{
		nakportion = (int)(getNakshatraLongitude27( mlen ) * 10000 /NAKSHATRA_LEN );
		nakportion /= 100;

		t1 << SPACE << nakportion << wxT( "%" ) << SPACE
			<< lang.getNakshatra27Name( ::getNakshatra27( mlen ), TF_MEDIUM );
	}
	SetStatusText( t1, 1 );
}
Пример #5
0
/*****************************************************
**
**   LagnaVimsottariDasaExpert   ---   getPortion
**
******************************************************/
double LagnaVimsottariDasaExpert::getPortion( Nakshatra &nak )
{
	Calculator *calculator = CalculatorFactory().getCalculator();
	double mlen = horoscope->getVedicLongitude( OASCENDANT );
	nak = (Nakshatra)( mlen / NAKSHATRA_LEN );
	return calculator->calcAscendantPortion( horoscope->getDataSet(), mlen );
}
Пример #6
0
/*****************************************************
**
**   GenericNakshatraDasaExpert   ---   getPortion
**
******************************************************/
double GenericNakshatraDasaExpert::getPortion( Nakshatra &nak )
{
	// Generic Calculation based upon the Moon, overwritten by Lagna Vimsottari Dasa
	Calculator *calculator = CalculatorFactory().getCalculator();
	double mlen = horoscope->getVedicLongitude( OMOON );
	nak = (Nakshatra)( mlen / NAKSHATRA_LEN );
	return calculator->calcNakshatraPortion( horoscope->getDataSet(), mlen, false );
}
Пример #7
0
/*****************************************************
**
**   EphemExpert   ---   testIngressEvent
**
******************************************************/
void EphemExpert::testIngressEvent( const int& t1, const int &t2, const int &planet, const int &type, const bool &r )
{
	double tjd, targetlen;
	if ( t1 != t2 )
	{
		Calculator *calculator = CalculatorFactory().getCalculator();
		targetlen = ( r ? t1 : t2 ) * ( type ? 13.3333333333 : 30 );
		tjd = calculator->calcPlanetaryEvent( d, targetlen, planet, chartprops->isVedic() );
		ingressEvents.push_back( IngressEvent( tjd, planet, t2, type ));
	}
}
Пример #8
0
/*****************************************************
**
**   EphemExpert   ---   addLunarEvent
**
******************************************************/
void EphemExpert::addLunarEvent( const int &stdate, const double& target, const double& sdiff, const double &ediff )
{
	double slen, mlen, cjd;
	Calculator *calculator = CalculatorFactory().getCalculator();

	d->setDate( jd[stdate] + ( target - sdiff ) / ( ediff - sdiff ));

	cjd = calculator->calcSunMoonEvent( d, target, slen, mlen );
	double aya = calculator->calcAyanamsa( cjd, config->vAyanamsa );
	lunarEvents.push_back( LunarEvent( target, cjd,
	                                   chartprops->isVedic() ? red_deg( slen - aya ) : slen,
	                                   chartprops->isVedic() ? red_deg( mlen - aya ) : mlen ));
}
Пример #9
0
/*****************************************************
**
**   EphemExpert   ---   calcKP
**
******************************************************/
void EphemExpert::calcKP( const int &dasa )
{
	KPEvent *e;
	vector<KPEvent>::iterator iter;

	Calculator *calculator = CalculatorFactory().getCalculator();
	DasaExpert *expert = DasaExpertFactory::get()->getDasaExpert( dasa );
	if ( ! expert->hasKpFeatures() || dasa == 2 ) return;

	if ( !clen  ) calcLength();
	kpevents = expert->getKPEventList( planetdata[OMOON].len[0], planetdata[OMOON].len[nb_days], jd[0] ); // calculates all lord/sublord events

	for ( iter = kpevents.begin(); iter != kpevents.end(); iter++ )
	{
		e = (KPEvent*)(&(*iter));
		d->setDate( e->jd );
		e->jd = calculator->calcPlanetaryEvent( d, e->len, 1, chartprops->isVedic() ); // get the dates for the events
	}
	ckp = true;
	mydasa = dasa;
}
Пример #10
0
/*****************************************************
**
**   EphemExpert   ---   calcDetails
**
******************************************************/
void EphemExpert::calcDetails()
{
	int i;
	Calculator *calculator = CalculatorFactory().getCalculator();
	double mlen, slen, dummy, diff;

	for ( i = 0; i < nb_days; i++ )
	{
		d->setDate( i+1, month, year, 0 ); // Must be 0, correct offset will follow in formatting

		// Only the time will be affected: location ist default! (not 0 - 0)
		st[i] = calculator->calcSiderealTime( d->getJD(), d->getLocation()->getLongitude() );
		calculator->calcSunRiseSunSet( d, &sunrise[i], &sunset[i] );

		d->setDate( sunrise[i] );
		calculator->calcPosition( d, OMOON, mlen, dummy, false, false );
		calculator->calcPosition( d, OSUN, slen, dummy, false, false );
		diff = red_deg( mlen - slen );
		tithi[i] = (int)(diff/12);
	}

	cdetails = true;
}
Пример #11
0
/*****************************************************
**
**   TextHelper   ---   writeVedicPlanetReport
**
******************************************************/
int TextHelper::writeVedicPlanetReport()
{
	VargaExpert expert;
	int i, j;
	Lang lang;
	Calculator *calculator = CalculatorFactory().getCalculator();
	wxString s1;
	double len;
	int ret = 0;

	VargaHoroscope chart( horoscope, 0 );
	VargaHoroscope nchart( horoscope, 1 );
	JaiminiExpert jexpert( &nchart );
	jexpert.calcCharaKarakas();
	NakshatraExpert nexpert;

	if ( show_header ) writer->writeHeader1( _( "Vedic Planets" ));
	vector<int> obs = chartprops->getVedicPlanetList();
	Table table( 5, obs.size() + 1 );
	table.setHeader( 0,  _( "Planet" ));
	table.setHeader( 1,  _( "Length" ));
	table.setHeader( 2,  _( "Karaka" ));
	table.setHeader( 3,  _( "Navamsa" ));
	table.setHeader( 4,  _( "Nakshatra" ));
	table.col_alignment[0] = Align::Center;
	table.col_alignment[1] = Align::Right;
	table.col_alignment[3] = Align::Center;

	//const int inode = config->iLunarNodeMode == LUNAR_NODE_TRUE ? OTRUENODE : OMEANNODE;
	int line = 1;
	for ( unsigned int p = 0; p < obs.size(); p++ )
	{
		i = obs[p];
		len = horoscope->getVedicLength( i );
		if ( len == 0 ) ret++;
		table.setEntry( 0, line,  writer->getObjectName( i, TLARGE, true ));
		table.setEntry( 1, line,  writer->getPosFormatted( len, horoscope->isRetrograde( i )));

		if ( i <= OSATURN ) j = i;
		else if ( i == OMEANNODE || i == OTRUENODE ) j = 7;
		else j = -1;
		if ( j != -1 )  table.setEntry( 2, line, lang.getKarakaName( jexpert.getCharaKarakaProperty( j )));

		table.setEntry( 3, line, writer->getSignName(nchart.getRasi( i ), config->signPrecision ));
		table.setEntry( 4, line, lang.getNakshatraName( getNakshatra( len, N27), N27, TLARGE ) );
		line++;
	}
	writer->writeTable( table );

	writer->writeHeader2( _( "Qualities" ));
	Table t4( 2, 5 );
	t4.setHeader( 0,  _( "Quality" ));
	t4.setHeader( 1,  _( "Value" ));
	double mlen = horoscope->getVedicLength( OMOON );

	line = 1;
	t4.setEntry( 0, line, _( "Varna" ) );
	t4.setEntry( 1, line++, lang.getVarnaName( getVarna( mlen )));

	t4.setEntry( 0, line, _( "Yoni" ) );
	t4.setEntry( 1, line++, lang.getYoniName( nexpert.getYoni( mlen )));

	t4.setEntry( 0, line, _( "Gana" ) );
	t4.setEntry( 1, line++, lang.getGanaName( nexpert.getGana( mlen )));

	t4.setEntry( 0, line, _( "Nadi" ) );
	t4.setEntry( 1, line++, lang.getNadiName( nexpert.getNadi( mlen )));
	writer->writeTable( t4 );

	writer->writeHeader2( _( "Moon's Nakshatra and Pada Portions" ));
	Table t5( 3, 3 );
	t5.setHeader( 0,  _( "Quality" ));
	t5.setHeader( 1,  _( "Value" ));
	t5.setHeader( 2,  _( "Value (Percent)" ));
	t5.setEntry( 0, 1, _( "Nakshatra" ) );
	double nportion = calculator->calcNakshatraPortion( horoscope->getDataSet(), mlen, false );
	s1.Printf( wxT( "%1.6f" ), nportion );
	t5.setEntry( 1, 1, s1 );

	s1.Printf( wxT( "%01.2f%%" ), 100.0 * nportion );
	t5.setEntry( 2, 1, s1 );

	t5.setEntry( 0, 2, _( "Pada" ) );
	double pportion = calculator->calcNakshatraPortion( horoscope->getDataSet(), mlen, true );
	s1.Printf( wxT( "%1.6f" ), pportion );
	t5.setEntry( 1, 2, s1 );

	s1.Printf( wxT( "%01.2f%%" ), 100.0 * pportion );
	t5.setEntry( 2, 2, s1 );

	writer->writeTable( t5 );

	return ret;
}
Пример #12
0
/*****************************************************
**
**   HoraExpert   ---   update
**
******************************************************/
void HoraExpert::update( const double &jd )
{
	const ObjectId lordseq[7] = { OSATURN, OJUPITER, OMARS, OSUN, OVENUS, OMERCURY, OMOON };
	const ObjectId rev_lordseq[7] = { OVENUS, OSATURN, OMERCURY, OJUPITER, OMOON, OMARS, OSUN };

	Calculator *calculator = CalculatorFactory().getCalculator();
	DateTimeFormatter *formatter = DateTimeFormatter::get();

	int i, weekday, day, month, year;

	double sunrise = calculator->calcNextSolarEvent( SOLAR_EVENT_SUNRISE, jd, location->getLatitude(), location->getLongitude());
	double sunset = calculator->calcNextSolarEvent( SOLAR_EVENT_SUNSET, sunrise, location->getLatitude(), location->getLongitude());
	double sunrise_next = calculator->calcNextSolarEvent( SOLAR_EVENT_SUNRISE, sunset, location->getLatitude(), location->getLongitude());

	weekday = getWeekDay( sunrise );
	dinaLord = lordseq[ ( rev_lordseq[weekday] ) % 7 ];



#ifdef HORA_DEB
	wxString s;
	printf( "##################  DEBUG ######################\n" );
	location->dump( s );
	s = formatter->getFullDateStringFromJD( jd );
	printf( "full date: %s\n", str2char( s ));
	printf( "jd: %s\n", str2char( formatter->getFullDateStringFromJD( jd )));
	printf( "sunrise: %s\n", str2char( formatter->getFullDateStringFromJD( sunrise )));
	printf( "sunset: %s\n", str2char( formatter->getFullDateStringFromJD( sunset )));
	printf( "sunrise NEXT: %s\n", str2char( formatter->getFullDateStringFromJD( sunrise_next )));
	printf( "WEEKDAY %d\n", weekday );
	printf( "dinalord %d\n", dinaLord );
	printf( "##################  END DEBUG  ######################\n" );
#endif

	for ( i = 0; i < 24; i++ )
	{
		horaLord[i] = lordseq[ ( rev_lordseq[weekday] + i ) % 7 ];
	}

	double daydur = sunset - sunrise;
	double daystep = daydur / 12;

	double nightdur = sunrise_next - sunset;
	double nightstep = nightdur / 12;

	currentHoraLord = horaLord[0];
	horaStart[24] = sunrise_next;

	for ( i = 0; i < 12; i++ )
	{
		horaStart[i] = sunrise + i * daystep;
		if ( horaStart[i] < jd ) currentHoraLord = horaLord[i];
	}
	for ( i = 0; i < 12; i++ )
	{
		horaStart[i+12] = sunset + i * nightstep;
		if ( horaStart[i+12] < jd ) currentHoraLord = horaLord[i+12];
	}

	// calculate lords of month and year
	formatter->calculateDateIntegers( sunrise, day, month, year );

	// lord of 1st day of year
	weekday = getWeekDay( calculator->calc_jd( year, 1, 1, 12 ));
	varshaLord = lordseq[ ( rev_lordseq[weekday] ) % 7 ];

	// lord of 1st day ov month
	weekday = getWeekDay( calculator->calc_jd( year, month, 1, 12 ));
	masaLord = lordseq[ ( rev_lordseq[weekday] ) % 7 ];
}
Пример #13
0
/*****************************************************
**
**   Formatter   ---   getDateIntsFromJD
**
******************************************************/
void Formatter::getDateIntsFromJD( const double &jd, int &day, int &month, int &year, const int format )
{
	double ut = 0;
	CalculatorFactory().getCalculator()->getDateIntsFromJD( jd, year, month, day, ut );
}