ADVERTISEMENT

One of the works done by our Robotics and Machine Learning division,
SELF-LEVELING QUADCOPTER
Arduino based Quadcopter.
Self-leveling is acheived by the aligning the quadcopter using the readings from the gryo as well as the accelerometer.
A four channel RC transmitter is used to control the movement of the quadcopter when in flight. Kindly subscribe to our YouTube Channel and stay tuned.

Tuesday 26 April 2016

CSE1002:PP7:List Of points

LIST OF POINTS
QUESTION:

Design a class point with datamembers name of the point(string), value in x-axis and value in y-axis. Provide functions to get the details of a point, print the details of a point and a function to compute distance between the point and a given point. Design a class mobileSpace, with a list of points representing the latitude and longitude of the mobile towers and a point to represent a mobile phone, provide member functions to get details and determine the tower that shall be connected to the phone. Use STL for implementation.

UML:



CODE:

void point::get()
{
cin>>name;
cin>>x>>y;
}
void point::print()
{
cout<<name<<endl;
}
float point::dist(point p)
{
return sqrt((p.x-x)*(p.x-x)+(p.y-y)*(p.y-y));
}
void mobile::get()
{
cin>>num_Tower_Pts;
int i;
for(i=0;i<num_Tower_Pts;i++)
{
point temp;
temp.get();
tower_Pts.push_back(temp);
}
mobile_Pt.get();
}
point mobile::find_Min()
{
int i;
float minv=100000000000000000000000000.0;
point minp;
list<point>::iterator it = tower_Pts.begin();
for(i=0;i<num_Tower_Pts;i++)
{
if(mobile_Pt.dist(*it)<minv)
{
minv=mobile_Pt.dist(*it);
minp=*it;
}it++;
}
return minp;

}

No comments:

Post a Comment