本文整理汇总了C++中line::getPoint2方法的典型用法代码示例。如果您正苦于以下问题:C++ line::getPoint2方法的具体用法?C++ line::getPoint2怎么用?C++ line::getPoint2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类line
的用法示例。
在下文中一共展示了line::getPoint2方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkIntersection
point line::checkIntersection( const line & line2 ) const
{
// now the real work begins
// lets try this using determinants
// converting to form Ax + By = C
float A1 = _y2 - _y1;
float B1 = _x1 - _x2;
float C1 = ( A1 * _x1 ) + ( B1 * _y1 );
float A2 = line2.getPoint2().y - line2.getPoint1().y;
float B2 = line2.getPoint1().x - line2.getPoint2().x;
float C2 = ( A2 * line2.getPoint1().x ) + ( B2 * line2.getPoint1().y );
float det = ( A1 * B2 ) - ( A2 * B1 );
// parallel test
if ( det == 0 ) point( 0, 0 );
float x_intersect = ( ( B2 * C1 ) - ( B1 * C2 ) ) / det;
float y_intersect = ( ( A1 * C2 ) - ( A2 * C1 ) ) / det;
return point( x_intersect, y_intersect );
}