![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Tomi Guest
|
Unexpected result... |
Posted: Thu Mar 27, 2003 12:58 pm |
|
|
Just tried to compile (and to make fun for myself ) the following sequence (the snippet calculates the distance between two points and converts SiRF x,y,z coordinates of a GPS to longitude, latitude and height coordinates).
And after downloading believe or not, the right numbers appeared on the LCD !
float distance,atm;
float x,y,z,a,b,e,ee,N,p,th,fi;
distance = 0.0;
atm = gXPos - gRefXPos;
atm *= atm;
distance += atm;
atm = gYPos - gRefYPos;
atm *= atm;
distance += atm;
atm = gZPos - gRefZPos;
atm *= atm;
distance += atm;
distance = sqrt(distance);
DeltaD = distance;
x = gXPos;y = gYPos;z = gZPos;
a = 6378137.0; b = 6356752.31424518; // Earth constants
e = sqrt((a*a-b*b)/a/a);
ee = sqrt((a*a-b*b)/b/b);
p = sqrt(x*x+y*y);
th = atan(z*a/p/b);
if (fabs(x) > 1.0e-40) Lon = atan(y/x)/PI*180.0;
else Lon = 90.0;
fi = z + ee*ee*b*sin(th)*sin(th)*sin(th);
fi /= p - e*e*a*cos(th)*cos(th)*cos(th);
fi = atan(fi);
Lat = fi/PI*180.0;
N = a/sqrt(1-e*e*sin(fi)*sin(fi));
N = p/cos(fi) - N;
Height = N;
___________________________
This message was ported from CCS's old forum
Original Post ID: 13154 |
|
![](templates/subSilver/images/spacer.gif) |
Sherpa Doug Guest
|
Re: Unexpected result... |
Posted: Thu Mar 27, 2003 2:13 pm |
|
|
:=Just tried to compile (and to make fun for myself <img src="http://www.ccsinfo.com/pix/forum/smile.gif" border="0"> ) the following sequence (the snippet calculates the distance between two points and converts SiRF x,y,z coordinates of a GPS to longitude, latitude and height coordinates).
:=And after downloading believe or not, the right numbers appeared on the LCD !
:=
:= float distance,atm;
:= float x,y,z,a,b,e,ee,N,p,th,fi;
:=
:= distance = 0.0;
:= atm = gXPos - gRefXPos;
:= atm *= atm;
:= distance += atm;
:= atm = gYPos - gRefYPos;
:= atm *= atm;
:= distance += atm;
:= atm = gZPos - gRefZPos;
:= atm *= atm;
:= distance += atm;
:= distance = sqrt(distance);
:= DeltaD = distance;
:=
:= x = gXPos;y = gYPos;z = gZPos;
:= a = 6378137.0; b = 6356752.31424518; // Earth constants
:= e = sqrt((a*a-b*b)/a/a);
:= ee = sqrt((a*a-b*b)/b/b);
:= p = sqrt(x*x+y*y);
:= th = atan(z*a/p/b);
:= if (fabs(x) > 1.0e-40) Lon = atan(y/x)/PI*180.0;
:= else Lon = 90.0;
:= fi = z + ee*ee*b*sin(th)*sin(th)*sin(th);
:= fi /= p - e*e*a*cos(th)*cos(th)*cos(th);
:= fi = atan(fi);
:= Lat = fi/PI*180.0;
:= N = a/sqrt(1-e*e*sin(fi)*sin(fi));
:= N = p/cos(fi) - N;
:= Height = N;
:=
There is no better way to astonish yourself than to try something really stupid... and have if work!
As written it seems the problem is solved at compile time.
___________________________
This message was ported from CCS's old forum
Original Post ID: 13158 |
|
![](templates/subSilver/images/spacer.gif) |
Ron Guest
|
Re: Unexpected result... |
Posted: Fri Mar 28, 2003 2:29 am |
|
|
Maybe for your next challenge you should try these calculations:
<a href="http://ralph.bucher.home.att.net/project.html" TARGET="_blank">http://ralph.bucher.home.att.net/project.html</a>
If it doesn't work, I certainly hope the American Navy is not using CCS on their Tomahawks!
Ron
:=Just tried to compile (and to make fun for myself <img src="http://www.ccsinfo.com/pix/forum/smile.gif" border="0"> ) the following sequence (the snippet calculates the distance between two points and converts SiRF x,y,z coordinates of a GPS to longitude, latitude and height coordinates).
:=And after downloading believe or not, the right numbers appeared on the LCD !
:=
:= float distance,atm;
:= float x,y,z,a,b,e,ee,N,p,th,fi;
:=
:= distance = 0.0;
:= atm = gXPos - gRefXPos;
:= atm *= atm;
:= distance += atm;
:= atm = gYPos - gRefYPos;
:= atm *= atm;
:= distance += atm;
:= atm = gZPos - gRefZPos;
:= atm *= atm;
:= distance += atm;
:= distance = sqrt(distance);
:= DeltaD = distance;
:=
:= x = gXPos;y = gYPos;z = gZPos;
:= a = 6378137.0; b = 6356752.31424518; // Earth constants
:= e = sqrt((a*a-b*b)/a/a);
:= ee = sqrt((a*a-b*b)/b/b);
:= p = sqrt(x*x+y*y);
:= th = atan(z*a/p/b);
:= if (fabs(x) > 1.0e-40) Lon = atan(y/x)/PI*180.0;
:= else Lon = 90.0;
:= fi = z + ee*ee*b*sin(th)*sin(th)*sin(th);
:= fi /= p - e*e*a*cos(th)*cos(th)*cos(th);
:= fi = atan(fi);
:= Lat = fi/PI*180.0;
:= N = a/sqrt(1-e*e*sin(fi)*sin(fi));
:= N = p/cos(fi) - N;
:= Height = N;
:=
:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 13179 |
|
![](templates/subSilver/images/spacer.gif) |
Ron Guest
|
Re: Unexpected result... |
Posted: Fri Mar 28, 2003 2:31 am |
|
|
Maybe for your next challenge you should try these calculations:
<a href="http://ralph.bucher.home.att.net/project.html" TARGET="_blank">http://ralph.bucher.home.att.net/project.html</a>
If it doesn't work, I certainly hope the American Navy is not using CCS on their Tomahawks!
Ron
:=Just tried to compile (and to make fun for myself <img src="http://www.ccsinfo.com/pix/forum/smile.gif" border="0"> ) the following sequence (the snippet calculates the distance between two points and converts SiRF x,y,z coordinates of a GPS to longitude, latitude and height coordinates).
:=And after downloading believe or not, the right numbers appeared on the LCD !
:=
:= float distance,atm;
:= float x,y,z,a,b,e,ee,N,p,th,fi;
:=
:= distance = 0.0;
:= atm = gXPos - gRefXPos;
:= atm *= atm;
:= distance += atm;
:= atm = gYPos - gRefYPos;
:= atm *= atm;
:= distance += atm;
:= atm = gZPos - gRefZPos;
:= atm *= atm;
:= distance += atm;
:= distance = sqrt(distance);
:= DeltaD = distance;
:=
:= x = gXPos;y = gYPos;z = gZPos;
:= a = 6378137.0; b = 6356752.31424518; // Earth constants
:= e = sqrt((a*a-b*b)/a/a);
:= ee = sqrt((a*a-b*b)/b/b);
:= p = sqrt(x*x+y*y);
:= th = atan(z*a/p/b);
:= if (fabs(x) > 1.0e-40) Lon = atan(y/x)/PI*180.0;
:= else Lon = 90.0;
:= fi = z + ee*ee*b*sin(th)*sin(th)*sin(th);
:= fi /= p - e*e*a*cos(th)*cos(th)*cos(th);
:= fi = atan(fi);
:= Lat = fi/PI*180.0;
:= N = a/sqrt(1-e*e*sin(fi)*sin(fi));
:= N = p/cos(fi) - N;
:= Height = N;
:=
:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 13182 |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|