All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions | Protected Attributes
QGpCoreTools::Line2D Class Reference

#include <Line2D.h>

List of all members.

Public Member Functions

Point2D intersect (const Line2D &o, bool &ok) const
 Line2D (double c=0.0)
 Line2D (double b, double c)
 Line2D (double x1, double y1, double az)
 Line2D (const Line2D &o)
 ~Line2D ()

Protected Attributes

double _a
double _b
double _c

Constructor & Destructor Documentation

QGpCoreTools::Line2D::Line2D ( double  c = 0.0)

Construct a vertical line (parallel to y axis) crossing at (c, 0)

line equation is a * y + b * x=c (with a=0 and b=1).

References _a, _b, _c, and TRACE.

{
  TRACE;
  _a=0;
  _b=1;
  _c=c;
}
QGpCoreTools::Line2D::Line2D ( double  b,
double  c 
)

Construct any line except vertical ones.

line equation is a * y + b * x=c (with a=1)

References _a, _b, _c, and TRACE.

{
  TRACE;
  _a=1;
  _b=b;
  _c=c;
}
QGpCoreTools::Line2D::Line2D ( double  x1,
double  y1,
double  az 
)

Construct any line passing by point ( x1, y1) and with azimuth az (counted clockwize from North).

line equation is a * y + b * x=c

References _a, _b, _c, QGpCoreTools::tan(), and TRACE.

{
  TRACE;
  if(az==0) {
    _a=0;
    _b=1;
    _c=x1;
  } else {
    _a=1;
    _b=-::tan(0.5 * M_PI - az);
    _c=y1 + _b * x1;
  }
}

Copy constructor

References _a, _b, and _c.

{
  _a=o._a;
  _b=o._b;
  _c=o._c;
}
{}

Member Function Documentation

Point2D QGpCoreTools::Line2D::intersect ( const Line2D o,
bool &  ok 
) const

Returns interstection between this line and line o. If no intersection is found, ok is set to false.

References _a, _b, _c, QGpCoreTools::Point2D::setX(), QGpCoreTools::Point2D::setY(), TRACE, and QGpCoreTools::Point2D::x().

Referenced by QGpCoreTools::PointLocate::position().

{
  TRACE;
  Point2D inter(0, 0);
  if(_a==o._a && _b==o._b) {
    // Either no intersection or infinity of intersections
    ok=false;
  } else if(_a==0) { // this is vertical
    inter.setX(_c); // _b is 1
    inter.setY(o._c - o._b * inter.x()); // o._a is 1
    ok=true;
  } else if(o._a==0) { // o is vertical
    inter.setX(o._c); // o._b is 1
    inter.setY(_c - _b * inter.x()); // _a is 1
    ok=true;
  } else { // _a and o._a are 1
    inter.setX((_c - o._c)/(_b - o._b));
    inter.setY(_c - _b * inter.x());
    ok=true;
  }
  return inter;
}

Member Data Documentation

double QGpCoreTools::Line2D::_a [protected]

Referenced by intersect(), and Line2D().

double QGpCoreTools::Line2D::_b [protected]

Referenced by intersect(), and Line2D().

double QGpCoreTools::Line2D::_c [protected]

Referenced by intersect(), and Line2D().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines