#include<iostream>
#include<cmath>
#include "point.h"
using namespace std;
Point::Point()
{
x = 0.0;
y = 0.0;
}
Point::Point(double xvalue, double yvalue)
{
SetAll(xvalue, yvalue);
}
void Point::SetAll(double xvalue, double yvalue)
{
x = xvalue;
y = yvalue;
return;
}
double Point::GetX(void) const
{
return x;
}
double Point::GetY(void) const
{
return y;
}
double Point::Distance(Point p)
{
return sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y));
}
double Point::Slope(Point p)
{
double slope = 0;
double xdelta = x - p.x;
double ydelta = y - p.y;
if(xdelta != 0)
{
slope = ydelta/xdelta;
}
else
{
return UNDEFINED;
}
return slope;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPGNtYXRoPgojaW5jbHVkZSAicG9pbnQuaCIKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKClBvaW50OjpQb2ludCgpCnsKCXggPSAwLjA7Cgl5ID0gMC4wOwp9CgpQb2ludDo6UG9pbnQoZG91YmxlIHh2YWx1ZSwgZG91YmxlIHl2YWx1ZSkKewoJU2V0QWxsKHh2YWx1ZSwgeXZhbHVlKTsKfQoKdm9pZCBQb2ludDo6U2V0QWxsKGRvdWJsZSB4dmFsdWUsIGRvdWJsZSB5dmFsdWUpCnsKCXggPSB4dmFsdWU7Cgl5ID0geXZhbHVlOwoJcmV0dXJuOwp9Cgpkb3VibGUgUG9pbnQ6OkdldFgodm9pZCkgY29uc3QKewoJcmV0dXJuIHg7Cn0KCmRvdWJsZSBQb2ludDo6R2V0WSh2b2lkKSBjb25zdAp7CglyZXR1cm4geTsKfQoKZG91YmxlIFBvaW50OjpEaXN0YW5jZShQb2ludCBwKQp7CglyZXR1cm4gc3FydCgoeCAtIHAueCkgKiAoeCAtIHAueCkgKyAoeSAtIHAueSkgKiAoeSAtIHAueSkpOwp9Cgpkb3VibGUgUG9pbnQ6OlNsb3BlKFBvaW50IHApCnsKCWRvdWJsZSBzbG9wZSA9IDA7Cglkb3VibGUgeGRlbHRhID0geCAtIHAueDsKCWRvdWJsZSB5ZGVsdGEgPSB5IC0gcC55OwoJCglpZih4ZGVsdGEgIT0gMCkKCXsKCQlzbG9wZSA9IHlkZWx0YS94ZGVsdGE7Cgl9CgllbHNlCgl7CgkJcmV0dXJuIFVOREVGSU5FRDsKCX0KCQoJcmV0dXJuIHNsb3BlOwp9Cgo=