How to display horizon line of a setallite.

Sword7

Member
Joined
Mar 23, 2008
Messages
143
Reaction score
18
Points
18
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
 

n72.75

Move slow and try not to break too much.
Orbiter Contributor
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 21, 2008
Messages
2,701
Reaction score
1,362
Points
128
Location
Saco, ME
Website
mwhume.space
Preferred Pronouns
he/him
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.
 

Sword7

Member
Joined
Mar 23, 2008
Messages
143
Reaction score
18
Points
18
Location
Gaithersburg, MD
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.
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,667
Reaction score
105
Points
78
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;
}
 

Andy44

owner: Oil Creek Astronautix
Addon Developer
Joined
Nov 22, 2007
Messages
7,620
Reaction score
7
Points
113
Location
In the Mid-Atlantic states
I think he means a circle that shows the portion of the planet's surface visible to a satellite from it's current altitude.
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,667
Reaction score
105
Points
78
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
 

Sword7

Member
Joined
Mar 23, 2008
Messages
143
Reaction score
18
Points
18
Location
Gaithersburg, MD
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
 

perseus

Addon Developer
Addon Developer
Joined
May 31, 2008
Messages
316
Reaction score
1
Points
18
Horizon-Distance-Eqns.jpg
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,676
Reaction score
2,406
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Remember, that you also need to project the circle on the sphere to the rectangular map projection that you use.
 
Top