| 1 | /*************************************************************************** |
| 2 | coord.cpp - description |
| 3 | ------------------- |
| 4 | begin : Sat Mar 16 2002 |
| 5 | copyright : (C) 2002 by Michael Bridak |
| 6 | email : [email protected] |
| 7 | $Id: coord.cpp,v 1.7 2003/05/20 17:36:04 mbridak Exp $ |
| 8 | ***************************************************************************/ |
| 9 | |
| 10 | /*************************************************************************** |
| 11 | * * |
| 12 | * This program is free software; you can redistribute it and/or modify * |
| 13 | * it under the terms of the GNU General Public License as published by * |
| 14 | * the Free Software Foundation; either version 2 of the License. * |
| 15 | * . * |
| 16 | * * |
| 17 | ***************************************************************************/ |
| 18 | |
| 19 | #include "coord.h"cxx . . $ `<file>/src/coord.h`/ |
| 20 | |
| 21 | Coordcxx . . $ Coord#::Coordcxx . . $ Coord#Coord(49f6e7a06ebc5aa8).(){ |
| 22 | } |
| 23 | Coordcxx . . $ Coord#::~cxx . . $ Coord#`~Coord`(ced63f7c635d850d).Coordcxx . . $ Coord#(){ |
| 24 | } |
| 25 | |
| 26 | void Coordcxx . . $ Coord#::UpdateLatLoncxx . . $ Coord#UpdateLatLon(49f6e7a06ebc5aa8).() |
| 27 | { |
| 28 | //procedure to update the latitude and longitude of a moving object. |
| 29 | //This is what actually moves an object. |
| 30 | |
| 31 | float amountofchange = 0; |
| 32 | float LongitudePercent = 0; |
| 33 | float LatitudePercent = 0; |
| 34 | LatLonPercentcxx . . $ Coord#LatLonPercent(9c29bf4bc569ebaa).(Headingcxx . . $ Coord#Heading., LongitudePercent, LatitudePercent); |
| 35 | amountofchange = (Speedcxx . . $ Coord#Speed. * 0.555) * LongitudePercent; |
| 36 | if ((Headingcxx . . $ Coord#Heading. > 270) || (Headingcxx . . $ Coord#Heading. < 90)){ |
| 37 | Lon_TotalYardscxx . . $ Coord#Lon_TotalYards. = Lon_TotalYardscxx . . $ Coord#Lon_TotalYards. + amountofchange; |
| 38 | } |
| 39 | if ((Headingcxx . . $ Coord#Heading. < 270) && (Headingcxx . . $ Coord#Heading. > 90)){ |
| 40 | Lon_TotalYardscxx . . $ Coord#Lon_TotalYards. = Lon_TotalYardscxx . . $ Coord#Lon_TotalYards. - amountofchange; |
| 41 | // if (Lon_TotalYards < 0){ |
| 42 | // Lon_TotalYards = 0; |
| 43 | // } |
| 44 | } |
| 45 | amountofchange = (Speedcxx . . $ Coord#Speed. * 0.555) * LatitudePercent; |
| 46 | if ((Headingcxx . . $ Coord#Heading. <= 359) && (Headingcxx . . $ Coord#Heading. > 180)){ |
| 47 | Lat_TotalYardscxx . . $ Coord#Lat_TotalYards. = Lat_TotalYardscxx . . $ Coord#Lat_TotalYards. + amountofchange; |
| 48 | } |
| 49 | if ((Headingcxx . . $ Coord#Heading. > 0) && (Headingcxx . . $ Coord#Heading. < 180)){ |
| 50 | Lat_TotalYardscxx . . $ Coord#Lat_TotalYards. = Lat_TotalYardscxx . . $ Coord#Lat_TotalYards. - amountofchange; |
| 51 | // if (Lat_TotalYards < 0){ |
| 52 | // Lat_TotalYards = 0; |
| 53 | // } |
| 54 | } |
| 55 | |
| 56 | // Important, we need to keep the ships on the map. |
| 57 | // The map is in the upp-erleft corner of the quad so |
| 58 | // higher numbers are up and to the left. |
| 59 | if (Lon_TotalYardscxx . . $ Coord#Lon_TotalYards. < MAP_MINcxx . . $ `src/coord.h:24:9`!) |
| 60 | { |
| 61 | Lon_TotalYardscxx . . $ Coord#Lon_TotalYards. = MAP_MINcxx . . $ `src/coord.h:24:9`!; |
| 62 | Headingcxx . . $ Coord#Heading. = 0; |
| 63 | } |
| 64 | else if (Lon_TotalYardscxx . . $ Coord#Lon_TotalYards. > MAP_MAXcxx . . $ `src/coord.h:27:9`!) |
| 65 | { |
| 66 | Lon_TotalYardscxx . . $ Coord#Lon_TotalYards. = MAP_MAXcxx . . $ `src/coord.h:27:9`!; |
| 67 | Headingcxx . . $ Coord#Heading. = 180; |
| 68 | } |
| 69 | if (Lat_TotalYardscxx . . $ Coord#Lat_TotalYards. < MAP_MINcxx . . $ `src/coord.h:24:9`!) |
| 70 | { |
| 71 | Lat_TotalYardscxx . . $ Coord#Lat_TotalYards. = MAP_MINcxx . . $ `src/coord.h:24:9`!; |
| 72 | Headingcxx . . $ Coord#Heading. = 270; |
| 73 | } |
| 74 | else if (Lat_TotalYardscxx . . $ Coord#Lat_TotalYards. > MAP_MAXcxx . . $ `src/coord.h:27:9`!) |
| 75 | { |
| 76 | Lat_TotalYardscxx . . $ Coord#Lat_TotalYards. = MAP_MAXcxx . . $ `src/coord.h:27:9`!; |
| 77 | Headingcxx . . $ Coord#Heading. = 90; |
| 78 | } |
| 79 | |
| 80 | |
| 81 | /* |
| 82 | Lon_Degrees = (int)Lon_TotalYards / 120000; |
| 83 | Lon_Minutes = ((int)Lon_TotalYards - (Lon_Degrees *120000)) / 2000; |
| 84 | Lon_Seconds = Lon_TotalYards - (Lon_Degrees * 120000) - (Lon_Minutes * 2000) / 33.33; |
| 85 | Lon_SubSeconds = Lon_TotalYards - (Lon_Degrees * 120000) - (Lon_Minutes * 2000) - (Lon_Seconds * 33.33) / 0.555; |
| 86 | |
| 87 | Lat_Degrees = (int)Lat_TotalYards / 120000; |
| 88 | Lat_Minutes = ((int)Lat_TotalYards - (Lat_Degrees *120000)) / 2000; |
| 89 | Lat_Seconds = Lat_TotalYards - (Lat_Degrees * 120000) - (Lat_Minutes * 2000) / 33.33; |
| 90 | Lat_SubSeconds = Lat_TotalYards - (Lat_Degrees * 120000) - (Lat_Minutes * 2000) - (Lat_Seconds * 33.33) / 0.555; |
| 91 | */ |
| 92 | |
| 93 | } |
| 94 | |
| 95 | void Coordcxx . . $ Coord#::LatLonPercentcxx . . $ Coord#LatLonPercent(9c29bf4bc569ebaa).(float heading, float &lonpercent, float &latpercent) |
| 96 | { |
| 97 | //Calculate the % of change of Latitude VS Longitude based on heading" |
| 98 | float llb=0; |
| 99 | if ((heading < 90) && (heading > 0)){ |
| 100 | latpercent = (1.1111111111 * heading); |
| 101 | lonpercent = (100.0 - latpercent); |
| 102 | } |
| 103 | if ((heading > 90) && (heading < 180)){ |
| 104 | llb = (heading - 90.0); |
| 105 | lonpercent = (1.1111111111 * llb); |
| 106 | latpercent = (100.0 - lonpercent); |
| 107 | } |
| 108 | if ((heading > 180) && (heading < 270)){ |
| 109 | llb = (heading - 180.0); |
| 110 | latpercent = (1.1111111111 * llb); |
| 111 | lonpercent = (100.0 - latpercent); |
| 112 | } |
| 113 | if ((heading > 270) && (heading < 360)){ |
| 114 | llb = (heading - 270.0); |
| 115 | lonpercent = (1.1111111111 * llb); |
| 116 | latpercent = (100.0 - lonpercent); |
| 117 | } |
| 118 | if ((heading == 0) || (heading == 360) || (heading == 180)){ |
| 119 | lonpercent = 100.0; |
| 120 | latpercent = 0.0; |
| 121 | } |
| 122 | if ((heading == 270) || (heading == 90)){ |
| 123 | latpercent = 100.0; |
| 124 | lonpercent = 0.0; |
| 125 | } |
| 126 | |
| 127 | lonpercent = lonpercent / 100.0; |
| 128 | latpercent = latpercent / 100.0; |
| 129 | } |