ns-allinone-2.35/satellite/satposition.cc
void PolarSatPosition::set(double Altitude, double Lon, double Alpha, double Incl)
{
	if (Altitude < 0) {
		fprintf(stderr, "PolarSatPosition:  altitude out of \
		   bounds: %f\n", Altitude);
		exit(1);
	}
	initial_.r = Altitude + EARTH_RADIUS; // Altitude in km above the earth
	if (Alpha < 0 || Alpha >= 360) {
		fprintf(stderr, "PolarSatPosition:  alpha out of bounds: %f\n", 
		    Alpha);
		exit(1);
	}
	initial_.theta = DEG_TO_RAD(Alpha);
	if (Lon < -180 || Lon > 180) {
		fprintf(stderr, "PolarSatPosition:  lon out of bounds: %f\n", 
		    Lon);
		exit(1);
	}
	if (Lon < 0)
		initial_.phi = DEG_TO_RAD(360 + Lon);
	else
		initial_.phi = DEG_TO_RAD(Lon);
	if (Incl < 0 || Incl > 180) {
		// retrograde orbits = (90 < Inclination < 180)
		fprintf(stderr, "PolarSatPosition:  inclination out of \
		    bounds: %f\n", Incl); 
		exit(1);
	}
	inclination_ = DEG_TO_RAD(Incl);
	// XXX: can't use "num = pow(initial_.r,3)" here because of linux lib
	double num = initial_.r * initial_.r * initial_.r;
	period_ = 2 * PI * sqrt(num/MU); // seconds
}
//
// Since it is easier to compute instantaneous orbit position based on a
// coordinate system centered on the orbit itself, we keep initial coordinates
// specified in terms of the satellite orbit, and convert to true spherical 
// coordinates in coord().
// Initial satellite position is specified as follows:
// initial_.theta specifies initial angle with respect to "ascending node"
// i.e., zero is at equator (ascending)-- this is the $alpha parameter in Otcl
// initial_.phi specifies East longitude of "ascending node"  
// -- this is the $lon parameter in OTcl
// Note that with this system, only theta changes with time
//
Since it is easier to compute instantaneous orbit position based on a
coordinate system centered on the orbit itself, we keep initial coordinates
specified in terms of the satellite orbit, and convert to true spherical
coordinates in coord().
Initial satellite position is specified as follows:
initial_.theta specifies initial angle with respect to "ascending node"
i.e., zero is at equator (ascending)-- this is the $alpha parameter in Otcl
initial_.phi specifies East longitude of "ascending node"
this is the $lon parameter in OTcl
Note that with this system, only theta changes with time
Since it is easier to compute instantaneous orbit position based on a coordinate system centered on the orbit itself we keep initial coordinates specified in terms of the satellite orbit and convert to true spherical coordinates in coord () . Initial satellite position is specified as follows : initial_ . theta specifies initial angle with respect to " ascending node " i . e . zero is at equator ( ascending ) -- this is the $alpha parameter in Otcl initial_ . phi specifies East longitude of " ascending node " this is the $lon parameter in OTcl Note that with this system only theta changes with time
void PolarSatPosition::set(double Altitude, double Lon, double Alpha, double Incl)
{
	if (Altitude < 0) {
		fprintf(stderr, "PolarSatPosition:  altitude out of \
		   bounds: %f\n", Altitude);
		exit(1);
	}
	initial_.r = Altitude + EARTH_RADIUS; 
	if (Alpha < 0 || Alpha >= 360) {
		fprintf(stderr, "PolarSatPosition:  alpha out of bounds: %f\n", 
		    Alpha);
		exit(1);
	}
	initial_.theta = DEG_TO_RAD(Alpha);
	if (Lon < -180 || Lon > 180) {
		fprintf(stderr, "PolarSatPosition:  lon out of bounds: %f\n", 
		    Lon);
		exit(1);
	}
	if (Lon < 0)
		initial_.phi = DEG_TO_RAD(360 + Lon);
	else
		initial_.phi = DEG_TO_RAD(Lon);
	if (Incl < 0 || Incl > 180) {
		fprintf(stderr, "PolarSatPosition:  inclination out of \
		    bounds: %f\n", Incl); 
		exit(1);
	}
	inclination_ = DEG_TO_RAD(Incl);
	double num = initial_.r * initial_.r * initial_.r;
	period_ = 2 * PI * sqrt(num/MU); 
}
void PolarSatPosition :: set ( double Altitude , double Lon , double Alpha , double Incl ) { if ( Altitude < 0 ) { fprintf ( stderr , " \
 \n " , Altitude ) ; exit ( 1 ) ; } initial_ . r = Altitude + EARTH_RADIUS ; if ( Alpha < 0 || Alpha >= 360 ) { fprintf ( stderr , " \n " , Alpha ) ; exit ( 1 ) ; } initial_ . theta = DEG_TO_RAD ( Alpha ) ; if ( Lon < -180 || Lon > 180 ) { fprintf ( stderr , " \n " , Lon ) ; exit ( 1 ) ; } if ( Lon < 0 ) initial_ . phi = DEG_TO_RAD ( 360 + Lon ) ; else initial_ . phi = DEG_TO_RAD ( Lon ) ; if ( Incl < 0 || Incl > 180 ) { fprintf ( stderr , " \
 \n " , Incl ) ; exit ( 1 ) ; } inclination_ = DEG_TO_RAD ( Incl ) ; double num = initial_ . r * initial_ . r * initial_ . r ; period_ = 2 * PI * sqrt ( num / MU ) ; }
Since it is easier to compute instantaneous orbit position based on a
coordinate system centered on the orbit itself, we keep initial coordinates
specified in terms of the satellite orbit, and convert to true spherical
coordinates in coord().
Since it is easier to compute instantaneous orbit position based on a coordinate system centered on the orbit itself we keep initial coordinates specified in terms of the satellite orbit and convert to true spherical coordinates in coord () .
// Altitude in km above the earth // retrograde orbits = (90 < Inclination < 180) // XXX: can't use "num = pow(initial_.r,3)" here because of linux lib // seconds