real world challenge
Posted: Sun Mar 29, 2009 7:34 pm
i was gonna make a nice slide with info on, but some people were inpatient. so this is just the watered down version.
my friends dad worked at this place that did geology scanning type thing where they had these planes fly in circuits with scanning equipment that looked for oil, gold and so on. well turns out that these coords had to have an over all anti clockwise trend, and one day the data was clockwise and cost them millions of dollars. so your task is to write a program. or just complete the skeleton program, that makes sure that date points is anticlockwise over all, and that no two lines bewteen 4 coords cross. ie, it never flys over the same place twice.
that image isn't numbered, but that could be an image. so you can see if you trace one way its clock wise, and trace the other is anti..
here is the skeleton code.
have fun kids.
NOTE: you can add any data structures or functions to the class to help you.
my friends dad worked at this place that did geology scanning type thing where they had these planes fly in circuits with scanning equipment that looked for oil, gold and so on. well turns out that these coords had to have an over all anti clockwise trend, and one day the data was clockwise and cost them millions of dollars. so your task is to write a program. or just complete the skeleton program, that makes sure that date points is anticlockwise over all, and that no two lines bewteen 4 coords cross. ie, it never flys over the same place twice.
that image isn't numbered, but that could be an image. so you can see if you trace one way its clock wise, and trace the other is anti..
here is the skeleton code.
have fun kids.
NOTE: you can add any data structures or functions to the class to help you.
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <math.h>
using namespace std;
struct sVec2;
class cGeo_Calc;
struct sVec2
{
double x;
double y;
};
class cGeo_Calc
{
public:
cGeo_Calc(vector<sVec2> tList);
~cGeo_Calc();
bool crossing(); // you finish this.
bool clock_Wise(); // you finish this.
private:
vector<sVec2> point_List;
};
cGeo_Calc::cGeo_Calc(vector<sVec2> tList)
{
this->point_List = tList;
printf("cGeo_Calc Created with %d data points.\n", this->point_List.size());
}
cGeo_Calc::~cGeo_Calc()
{
}
bool cGeo_Calc::crossing()
{
// TODO : Complete this yourself.
return false;
}
bool cGeo_Calc::clock_Wise()
{
printf("STATUS : ");
if(!this->crossing())
{
printf("ERROR IN DATA, lines cross.\n");
return false;
}
// TODO : Complete this yourself.
return false;
}
////// test bed //////
void test_Bed()
{
vector<sVec2> temp;
sVec2 v;
v.x = 0;
v.y = 0;
for(int a = 0;a <= 10000;a++)
{
v.x = 1000*cos(360*((double)a/10000)/180*3.141592653589793);
v.y = 1000*sin(360*((double)a/10000)/180*3.141592653589793);
temp.push_back(v);
}
cGeo_Calc *test = new cGeo_Calc(temp);
if(test->clock_Wise())
{
printf("Successful, data is anti clock wise.\n\n");
}else
{
printf("Failure, data is clock wise.\n\n");
}
///////////////// test 2 ///////////////////
temp.clear();
v.x = 0;
v.y = 0;
for(int a = 0;a <= 10000;a++)
{
v.x = 1000*cos(360*((double)a/10000)/180*3.141592653589793);
v.y = 1000*sin(360*((double)a/10000)/180*3.141592653589793);
temp.push_back(v);
}
test = new cGeo_Calc(temp);
if(test->clock_Wise())
{
printf("Successful, data is anti clock wise.\n\n");
}else
{
printf("Failure, data is clock wise.\n\n");
}
delete test;
}
////// done bed //////
int main (int argc, char * const argv[])
{
printf("Start of program.\n\n");
test_Bed();
return 0;
}