CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Unexpected result...

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Tomi
Guest







Unexpected result...
PostPosted: Thu Mar 27, 2003 12:58 pm     Reply with quote

Just tried to compile (and to make fun for myself Smile ) 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
Sherpa Doug
Guest







Re: Unexpected result...
PostPosted: Thu Mar 27, 2003 2:13 pm     Reply with quote

:=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
Ron
Guest







Re: Unexpected result...
PostPosted: Fri Mar 28, 2003 2:29 am     Reply with quote

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
Ron
Guest







Re: Unexpected result...
PostPosted: Fri Mar 28, 2003 2:31 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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