Exemple #1
0
int main (void)
{
	int dir, oppDir;

	die[CURR] = 0;
	die[NORTH] = 3;
	die[SOUTH] = 2;
	die[EAST] = 1;
	die[WEST] = 4;

	die[CURR] = 2;
	die[NORTH] = 0;
	die[SOUTH] = 5;
	die[EAST] = 4;
	die[WEST] = 1;

	dir = NORTH;
	oppDir = SOUTH;
	

	outState();
	die[dir] = die[CURR];
	die[CURR] = die[oppDir];
	die[oppDir] = 5 - die[dir];	

	outState();

	die[dir] = die[CURR];
	die[CURR] = die[oppDir];
	die[oppDir] = 5 - die[dir];	
	
	outState();
	die[dir] = die[CURR];
	die[CURR] = die[oppDir];
	die[oppDir] = 5 - die[dir];	
	
	outState();
	die[dir] = die[CURR];
	die[CURR] = die[oppDir];
	die[oppDir] = 5 - die[dir];	
	
	outState();


/*

	curr = $80	; 
	dir = $85	; 

	ldx CURR		;
	lda curr, x	; 
	ldx dir			; die[dir] = die[CURR];
	sta curr, x	; 

	ldx oppDir		;
	lda arrayaddr, x	;
	ldx curr		; die[curr] = die[oppdir]
	sta arrayaddr, x	;

	ldx dir
	lda #5
	sec
	sbc curr,x
	ldx oppDir
	sta curr, x
	


	

	


*/
	

	return 0;
}
RealArray PhysicalMeasurement::IonosphereCorrection(Real freq, Rvector3 r1, Rvector3 r2, Real epoch)
{
   RealArray ionoCorrection;

   if (ionosphere != NULL)
   {
   	// 1. Set wave length:
   	Real wavelength = GmatPhysicalConstants::SPEED_OF_LIGHT_VACUUM / (freq*1.0e6);		// unit: meter
   	ionosphere->SetWaveLength(wavelength);

   	// 2. Set time:
   	ionosphere->SetTime(epoch);															// unit: Julian day

   	// 3. Set station and spacecraft positions:
   	GroundstationInterface* gs 	= (GroundstationInterface*)participants[0];
   	CoordinateSystem* cs = gs->GetBodyFixedCoordinateSystem();
   	Rvector inState(6, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
	Rvector outState(6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
//   	Rvector bogusOut 		= cs->FromMJ2000Eq(epoch, bogusIn, true);
//   	Rmatrix33 R_g_j2k    = cs->GetLastRotationMatrix().Transpose();
	CoordinateConverter* cv = new CoordinateConverter();
	A1Mjd time(epoch);
	CoordinateSystem* fk5cs = Moderator::Instance()->GetCoordinateSystem("EarthMJ2000Eq");
	cv->Convert(time, inState, cs, outState, fk5cs);				// convert EarthFK5 coordinate system to EarthBodyFixed coordinate system
	Rmatrix33 R_g_j2k    = cv->GetLastRotationMatrix().Transpose();
//   	MessageInterface::ShowMessage("[ %f  %f  %f\n", R_g_j2k.GetElement(0,0), R_g_j2k.GetElement(0,1), R_g_j2k.GetElement(0,2));
//   	MessageInterface::ShowMessage("  %f  %f  %f\n", R_g_j2k.GetElement(1,0), R_g_j2k.GetElement(1,1), R_g_j2k.GetElement(1,2));
//   	MessageInterface::ShowMessage("  %f  %f  %f]\n", R_g_j2k.GetElement(2,0), R_g_j2k.GetElement(2,1), R_g_j2k.GetElement(2,2));

   	ionosphere->SetStationPosition(R_g_j2k*r1);											// unit: km
   	ionosphere->SetSpacecraftPosition(R_g_j2k*r2);										// unit: km

   	// 4. Set earth radius:
	SpacePoint* earth 	= (SpacePoint*)gs->GetRefObject(Gmat::SPACE_POINT, "Earth");
   	Real earthRadius 	= earth->GetRealParameter("EquatorialRadius");
   	ionosphere->SetEarthRadius(earthRadius);											// unit: km

#ifdef DEBUG_IONOSPHERE_MEDIA_CORRECTION
	MessageInterface::ShowMessage("      *Run Ionosphere media correction for:\n");
	MessageInterface::ShowMessage("         +Earth radius = %lf km\n", earthRadius);
	MessageInterface::ShowMessage("         +Wave length = %.12lf m\n", wavelength);
	MessageInterface::ShowMessage("         +Time = %.12lf\n", epoch);
	MessageInterface::ShowMessage("         +Station location in Earth body fixed coordinate system (km):\n"
		                          "            (%s)", (R_g_j2k*r1).ToString().c_str()); 
	MessageInterface::ShowMessage("         +Spacecraft location in Earth body fixed coordinate system (km):\n"
		                          "            (%s)", (R_g_j2k*r2).ToString().c_str());
#endif

	// 5. Run ionosphere correction:
   	ionoCorrection = ionosphere->Correction();
   	Real rangeCorrection = ionoCorrection[0]*GmatMathConstants::M_TO_KM;				// unit: meter

#ifdef DEBUG_IONOSPHERE_MEDIA_CORRECTION
	MessageInterface::ShowMessage("      *Ionosphere media correction result:\n");
	MessageInterface::ShowMessage("         +Range correction = %.12lf m\n", rangeCorrection*GmatMathConstants::KM_TO_M);
#endif
   }
   else
   {
   	ionoCorrection.push_back(0.0);
   	ionoCorrection.push_back(0.0);
   	ionoCorrection.push_back(0.0);
   }

   return ionoCorrection;
}