View unanswered posts | View active topics It is currently Wed Sep 23, 2020 3:58 pm

 Page 1 of 1 [ 1 post ]
 Print view Previous topic | Next topic
HELP ... NXT not computing properly ACOS math function
Author Message
Rookie

Joined: Fri Aug 14, 2009 11:36 pm
Posts: 15
HELP ... NXT not computing properly ACOS math function
Hi!

I'm posting my question previously from NXT IDE forum to this section as it may be more appropriate here. Also as a background, the 2 latitudes and longitudes inputs will be provided by an external bluetooth GPS. I am just making sure that this computational section of the proposed bigger program works and here I am hitting a wall .

Any help will be much appreciated.

Thanks.

-----------

Hi!

I'm trying to compute the distance between two lat long locations using Great Circle distance formula. All aspects of the formula works as expected except when acos value is computed! The results of running the program on the nxt running 1.4 firmware can be found in the 2nd image. The values that are not being computed properly starts on line 4 down to line 8. It should be a straight forward computations but for some reason, it is not coming out right. The first image shows the "right" values computed in excel.

Hope somebody out there can help.

Thanks.

The program is as follows:
 Code:  task main(){   {float LatA = 38.95425556;float LatB = 38.96098333;float LonA = -92.37601944;float LonB = -92.36897778;float RadLatA = (LatA/180)*PI;float RadLatB = (LatB/180)*PI;float SinLatA = sin(RadLatA);float SinLatB   = sin(RadLatB);float CosLatA   = cos(RadLatA);float CosLatB   = cos(RadLatB);float CosLonB_LonA = cos((LonB/180)*PI-(LonA/180)*PI);float Distrad   = acos(SinLatA*SinLatB+CosLatA*CosLatB*CosLonB_LonA);float Distdeg   = (Distrad/PI)*180;float Distance_m = 1.852*60*Distdeg*1000;nxtDisplayTextLine(0,"sina: %3.8f", SinLatA); //display target GPS headingnxtDisplayTextLine(1,"sinb: %3.8f", SinLatB); //display target GPS headingnxtDisplayTextLine(2,"cosa: %3.8f", CosLatA); //display target GPS headingnxtDisplayTextLine(3,"cosb: %3.8f", CosLatB); //display target GPS headingnxtDisplayTextLine(4,"coslbla: %3.8f", CosLonB_LonA); //display target GPS headingnxtDisplayTextLine(5,"Drad: %3.8", Distrad); //display target GPS headingnxtDisplayTextLine(6,"Ddeg: %3.8f", Distdeg); //display target GPS headingnxtDisplayTextLine(7,"D_m: %3.8f", Distance_m); //display target GPS heading      wait1Msec(6000);   }}

 Attachments: File comment: Excel result nxtout_compare.jpg [ 35.38 KiB | Viewed 3341 times ] File comment: NXT display nxtout.jpg [ 41.63 KiB | Viewed 3340 times ]
Sat Aug 15, 2009 9:19 am
Display posts from previous:  Sort by
 Page 1 of 1 [ 1 post ]

#### Who is online

Users browsing this forum: No registered users and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.