本文整理汇总了C++中Line2::getEnd方法的典型用法代码示例。如果您正苦于以下问题:C++ Line2::getEnd方法的具体用法?C++ Line2::getEnd怎么用?C++ Line2::getEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Line2
的用法示例。
在下文中一共展示了Line2::getEnd方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: segmentsIntersect
// The main function that returns true if line segment 'p1q1'
// and 'p2q2' intersect.
bool segmentsIntersect(Line2 l1, Line2 l2)
{
// Find the four orientations needed for general and
// special cases
int o1 = orientation(l1.getStart(), l1.getEnd(), l2.getStart());
int o2 = orientation(l1.getStart(), l1.getEnd(), l2.getEnd());
int o3 = orientation(l2.getStart(), l2.getEnd(), l1.getStart());
int o4 = orientation(l2.getStart(), l2.getEnd(), l1.getEnd());
// General case
if (o1 != o2 && o3 != o4)
return true;
// Special Cases
// p1, q1 and p2 are colinear and p2 lies on segment p1q1
if (o1 == 0 && onSegment(l1.getStart(), l2.getStart(), l1.getEnd())) return true;
// p1, q1 and p2 are colinear and q2 lies on segment p1q1
if (o2 == 0 && onSegment(l1.getStart(), l2.getEnd(), l1.getEnd())) return true;
// p2, q2 and p1 are colinear and p1 lies on segment p2q2
if (o3 == 0 && onSegment(l2.getStart(), l1.getStart(), l2.getEnd())) return true;
// p2, q2 and q1 are colinear and q1 lies on segment p2q2
if (o4 == 0 && onSegment(l2.getStart(), l1.getEnd(), l2.getEnd())) return true;
return false; // Doesn't fall in any of the above cases
}
示例2: oppositeSide
bool oppositeSide(Point2 p1, Point2 p2, Line2 ab)//returns whether or not p1 and p2 are on the same side of AB
{
double & ax = p1.x;
double & ay = p1.y;
double & bx = p2.x;
double & by = p2.y;
double & x1 = ab.x;
double & y1 = ab.y;
double x2 = ab.getEnd().x;
double y2 = ab.getEnd().y;
return ((y1 - y2)*(ax - x1)+(x2 - x1)*(ay - y1))*((y1 - y2)*(bx - x1)+(x2 - x1)*(by - y1))<0;
}
示例3:
bool operator==(Line2 const & lhs, Line2 const & rhs)
{
return (lhs.getStart() == rhs.getStart() && lhs.getEnd() == rhs.getEnd()) || (lhs.getStart() == rhs.getEnd() && lhs.getEnd() == rhs.getStart());
}
示例4: intersect
bool intersect(Line2 ab, Line2 cd)
{
return oppositeSide(ab, ab.getEnd(), cd) && oppositeSide(cd, cd.getEnd(), ab);
}