本文整理汇总了C++中Point::Abs方法的典型用法代码示例。如果您正苦于以下问题:C++ Point::Abs方法的具体用法?C++ Point::Abs怎么用?C++ Point::Abs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point
的用法示例。
在下文中一共展示了Point::Abs方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calc
/* called by Area(const Polygon&) */
double calc(const Point &rhs1, const Point &rhs2){
vector<Point> p;
bool in1 = (cmp(rhs1.Abs()-R) < 0);
bool in2 = (cmp(rhs2.Abs()-R) < 0);
if(in1){
if(in2)
return fabs(rhs1.Cross(rhs2)) / 2.0;
else{
p = Intersection(Line(rhs1, rhs2));
return SectorArea(rhs2, p[0]) + fabs(rhs1.Cross(p[0])) / 2.0;
}
}else{
if(in2){
p = Intersection(Line(rhs1, rhs2));
return SectorArea(p[0], rhs1) + fabs(rhs2.Cross(p[0])) / 2.0;
}else{
p = Intersection(Line(rhs1, rhs2));
if((int)p.size() == 2){
return SectorArea(rhs1, p[0]) + SectorArea(p[1], rhs2) + fabs(p[0].Cross(p[1])) / 2.0;
}else{
return SectorArea(rhs1, rhs2);
}
}
}
}
示例2: invalid_argument
Angle::Angle(Point const& point)
{
if (!point.X && !point.Y)
throw std::invalid_argument("Point must be not (0, 0)");
double distance = point.Abs();
Value = Point(point.X / distance, point.Y / distance);
}
示例3: Get
double Angle::Get(Angle& result, Point const& left, Point const& right, double minDistance)
{
if (minDistance < 0)
throw std::invalid_argument("Min distance must be >= 0");
Point vect = right - left;
if (!vect.X && !vect.Y)
return 0;
double distance = vect.Abs();
if (distance > minDistance)
result = Angle(vect, distance);
return distance;
}
示例4: Move
/*
* move d units along the direction of line
* example: {(0, 0) -> (1, 1)} move _/2 becomes {(1, 1) -> (2, 2)}
*/
Line Move(const double &d){
Point tmp = b - a;
tmp = tmp / tmp.Abs();
return Line(a + tmp * d, b + tmp * d);
}
示例5: move
Line move(const double &d){
Point tmp = b - a;
tmp = tmp / tmp.Abs();
tmp = tmp.Rotate(PI/2);
return Line(a+tmp*d, b+tmp*d);
}