How to display horizon line of a setallite.

Sword7

Active member
Joined
Mar 23, 2008
Messages
176
Reaction score
32
Points
28
Location
Gaithersburg, MD
Folks,

I had seen some satellite map that show horizon line around satellite. Does anyone know any formula to draw horizon line around satellite at its current position?

Thanks,
Tim
 
Folks,

I had seen some satellite map that show horizon line around satellite. Does anyone know any formula to draw horizon line around satellite at its current position?

Thanks,
Tim

Hi Tim,

Do you think you could post a picture of what you'are looking for. I'm not sure I quite know what you mean.
 
Hi Tim,

Do you think you could post a picture of what you'are looking for. I'm not sure I quite know what you mean.

Well, I mean world map that Orbiter showed current position of spacecraft with horizon line around it.
 
If you know how to code and you are willing to dig out a bit from my uncommented code here you are (in bold the hot part for your use):

Code:
void draw(OBJHANDLE hmetd,int r, int g, int b){
	
	
	double lngmap,latmap;
	EQU equpos;
	GetEquPosByCoord(hmetd,equpos);
	lngmap=equpos.lng*DEG;
	latmap=equpos.lat*DEG;
	





	if(oapiFindDialog(g_hInst,ID_MAP)){
		HDC clientDC;
	clientDC= GetDC(oapiFindDialog(g_hInst,ID_MAP));
		//clientDC=GetDC(GetDlgItem(hDlg,IDC_STATMAP));
	//HDC testDC;
	//testDC=GetDC(GetDlgItem(hDlg, ID_MAP));
    
	RECT rect;
	Ellipse(clientDC,((lngmap/180*315+315)-5),(-1)*((latmap/90*158-158)-5),((lngmap/180*315+315)+5),(-1)*((latmap/90*158-158)+5));
	

	rect.left=lngmap/180*315+315+6;
		rect.right=lngmap/180*315+315+106;
		rect.bottom=(-1)*(latmap/90*158-158-10);
		rect.top=(-1)*(latmap/90*158-158+10);
	double beta=asin(Getd(hmetd)/(GetAltH(hmetd)+rt));
	
	
	
	
	
	POINT points[37],pointspiu[37],pointsmeno[37];
	

	[B]double phi[37],lambda[37],theta[37];
	double coslat=cos(abs(latmap)*RAD);
	double sinlat=sin(abs(latmap)*RAD);
	double coslong=cos(lngmap*RAD);
	double sinlong=sin(lngmap*RAD);
	double tanbeta=tan(beta);
	double cosbeta=cos(beta);
	double sinbeta=sin(beta);

	for(int pts=0;pts<37;pts++){
		theta[pts]=pts*10*RAD;
		
		if(latmap>=0){
	phi[pts]=asin(cosbeta*sinlat+sinbeta*coslat*cos(theta[pts]));
		}else{
			phi[pts]=(-1)*asin(cosbeta*sinlat+sinbeta*coslat*cos(theta[pts]));
		}

	lambda[pts]=atan2(tanbeta*sin(theta[pts]),coslat-tanbeta*cos(theta[pts])*sinlat);

	points[pts].x=lambda[pts]*DEG*315/180+315+lngmap*315/180;
	[/B]pointspiu[pts].x=points[pts].x+360*315/180;
		pointsmeno[pts].x=points[pts].x-360*315/180;
	[B]points[pts].y=(-1)*phi[pts]*DEG*158/90+158;[/B]
	pointspiu[pts].y=points[pts].y;
	pointsmeno[pts].y=points[pts].y;
	
	}

	HGDIOBJ hPen = NULL;
    HGDIOBJ hPenOld; 


	 hPen = CreatePen(PS_SOLID, 3, RGB(r, g, b));

	  hPenOld=SelectObject(clientDC, hPen); 
    Polyline(clientDC,points,37);
	Polyline(clientDC,pointspiu,37);
	Polyline(clientDC,pointsmeno,37);
	
	DeleteObject(hPen);
	
	
	char objname[50];
	oapiGetObjectName(hmetd,objname,50);
	
	DrawText(clientDC,objname,-1,&rect,DT_SINGLELINE);
	ReleaseDC(hMap, clientDC);
	
	}
	return;
}
 
I think he means a circle that shows the portion of the planet's surface visible to a satellite from it's current altitude.
 
I think he means a circle that shows the portion of the planet's surface visible to a satellite from it's current altitude.

That's exactly what the above code does: it's from my space network plugin
 
Ok, thanks for some replies. I know simple formula for angle view (horizon line).

beta = arccos R / R + h
where beta is planetocentric
R is planet radius
h is altitude above surface.

To to find a distance to horizon view from camera position:

d = R arccos R / R + h

I googled it but found only one source but just math formula (no code):

http://physics.stackexchange.com/questions/151388/how-to-calculate-the-horizon-line-of-a-satellite

Thanks for provide a code to draw a circle around current spacecraft position.

Thanks,
Tim

---------- Post added at 02:17 PM ---------- Previous post was at 02:12 PM ----------

If you know how to code and you are willing to dig out a bit from my uncommented code here you are (in bold the hot part for your use):

(code deleted)

Thanks for providing a code for Windows 32 SDK programming. How about OpenGL code?

Thanks again,
Tim
 
Horizon-Distance-Eqns.jpg
 
Remember, that you also need to project the circle on the sphere to the rectangular map projection that you use.
 
Back
Top