Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- Online C Compiler.
- Code, Compile, Run and Debug C program online.
- Write your code in this editor and press "Run" button to compile and execute it.
- *******************************************************************************/
- #include <stdio.h>
- #include <stdbool.h>
- int main()
- {
- //GPS declarations
- double courseToBeacon = 340.00;
- double currentDistance = 0.00;
- double maxDistanceToBeacon = 100.00;
- double normalizedDistance = currentDistance / maxDistanceToBeacon;
- // printf(" start normalizedDistance = %f", normalizedDistance);
- //semicircle partitions, use a multiple of 2 & n > 6
- int n = 6;
- double westLowerBound = 270.0;
- double westUpperBound = 270.0 + (90.0 / n);
- double northLowerBound = 360.0 - (90.0 / n);
- double northUpperBound = 0.0 + (90.0 / n);
- double eastLowerBound = 90.0 - (90.0 / n);
- double eastUpperBound = 90.0;
- bool isSouth = ((eastUpperBound < courseToBeacon) && (courseToBeacon < westLowerBound));
- while ((normalizedDistance < 0.95)) {
- // printf(" + normalizedDistance 1 = %f", normalizedDistance);
- printf(" courseToBeacon 1 = %f", courseToBeacon);
- // cardinal directions
- // 345 < x & x <= 15
- bool isNorth = ((northLowerBound < courseToBeacon) || (courseToBeacon <= northUpperBound));
- // 75 < x & x <= 90
- bool isEast = ((eastLowerBound < courseToBeacon) && (courseToBeacon <= eastUpperBound));
- // 90 < x & x <= 270
- bool isSouth = ((eastUpperBound < courseToBeacon) && (courseToBeacon <= westLowerBound));
- // 270 < x & x <= 285
- bool isWest = ((westLowerBound < courseToBeacon) && (courseToBeacon <= westUpperBound));
- // 285 < x & x < 345
- bool isNorthWest = ((westUpperBound < courseToBeacon) && (courseToBeacon <= northLowerBound));
- // 15 < x & x <= 75
- bool isNorthEast = ((northUpperBound < courseToBeacon) && (courseToBeacon <= eastLowerBound));
- if (isWest) {
- printf(" + isWest");
- }
- else if (isEast) {
- printf(" + isEast");
- }
- else if (isNorth) {
- printf(" + isNorth");
- }
- // northwest / northeast
- else if (isNorthWest) {
- printf(" + isNorthWest");
- }
- else if (isNorthEast) {
- printf(" + isNorthEast");
- } else {
- printf(" + wrong");
- }
- // testing if currentDistance updates
- currentDistance += 100.0;
- // printf(" + currentDistance = %f", currentDistance);
- // testing if courseToBeacon updates
- courseToBeacon += 15.0;
- printf(" + courseToBeacon2 = %f", courseToBeacon);
- // get new normalized Distance
- normalizedDistance = currentDistance / maxDistanceToBeacon;
- // printf(" + normalizedDistance = %f + end + .", normalizedDistance);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement