All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions
QGpCoreTools::Point Class Reference

#include <Point.h>

Inheritance diagram for QGpCoreTools::Point:
QGpCoreTools::Point2D QGpCoreTools::NamedPoint TapePoint

List of all members.

Public Member Functions

void average (const Point &p)
short compare (const Point &p) const
double distanceTo (const Point &p) const
double distanceToSegment (const Point &p1, const Point &p2) const
double elevationTo (const Point &p) const
bool fromString (const StringSection &str)
void interpole (double valX, const Point &p1, const Point &p2)
bool isSimilar (const Point &p, double tolerance) const
bool isValid () const
void move (double distance, const Angle &azimuth, const Angle &elevation)
bool operator!= (const Point &obj) const
Point operator* (double mul) const
Point operator* (const Point &p) const
void operator*= (const Point &p)
void operator*= (double mul)
void operator*= (const Matrix3x3 &transformation)
void operator*= (const Matrix4x4 &transformation)
Point operator+ (const Point &p) const
void operator+= (const Point &p)
Point operator- (const Point &p) const
void operator-= (const Point &p)
Point operator/ (double div) const
Point operator/ (const Point &p) const
void operator/= (const Point &p)
void operator/= (double div)
bool operator< (const Point &p) const
bool operator<= (const Point &obj) const
Pointoperator= (const Point &p)
Pointoperator= (const Point2D &p)
bool operator== (const Point &p) const
bool operator> (const Point &obj) const
bool operator>= (const Point &obj) const
 Point ()
 Point (double x, double y, double z=0.0)
 Point (const QPoint &p)
 Point (const QPointF &p)
 Point (const Point2D &p)
 Point (const Point &p)
 Point (const QVector< double > &p)
double scalarProduct (const Point &p) const
void set (double xi, double yi, double zi=0.0)
void setValid (bool)
void setZ (double v)
QString toString (int precision=6, char format='g') const
void translate (const Point &p)
void vectorialProduct (const Point &p1, const Point &p2)
double z () const

Detailed Description

Basic properties of a 3D point (coordinates in double precision)


Constructor & Destructor Documentation

Default constructor

Referenced by operator*(), operator+(), operator-(), and operator/().

  : Point2D()
{
  _z=0.0;
}
QGpCoreTools::Point::Point ( double  x,
double  y,
double  z = 0.0 
) [inline]

Constructor setting x and y, and optionally z

  : Point2D(xi, yi)
{
  _z=zi;
}
QGpCoreTools::Point::Point ( const QPoint &  p) [inline]
  : Point2D(p)
{
  _z=0.0;
}
QGpCoreTools::Point::Point ( const QPointF &  p) [inline]
  : Point2D(p)
{
  _z=0.0;
}
QGpCoreTools::Point::Point ( const Point2D p) [inline]

Copy constructor from Point2D

  : Point2D(p)
{
  _z=0.0;
}
QGpCoreTools::Point::Point ( const Point p) [inline]
  : Point2D(p)
{
  _z=p._z;
}
QGpCoreTools::Point::Point ( const QVector< double > &  p) [inline]

Copy constructor from a vector

   : Point2D(p)
  {
    ASSERT(p.count()>2);
    _z=p.at(2);
  }

Member Function Documentation

void QGpCoreTools::Point::average ( const Point p) [inline]
{
  Point2D::average(p);
  _z=0.5*(_z+p._z);
}
short QGpCoreTools::Point::compare ( const Point p) const [inline]
{
  int c=Point2D::compare(p);
  if(c==0) {
    if(_z < p._z) return -1;
    else if(_z > p._z) return 1;
    else return 0;
  } else {
    return c;
  }
}
double QGpCoreTools::Point::distanceTo ( const Point p) const
double QGpCoreTools::Point::distanceToSegment ( const Point p1,
const Point p2 
) const

Calculates the distance to a segment defined by p1 and p2.

References distanceTo(), QGpCoreTools::sqrt(), TRACE, QGpCoreTools::Point2D::x(), QGpCoreTools::Point2D::y(), and z().

  {
    TRACE;
    double d1=distanceTo(p1);
    double d2=distanceTo(p2);
    double d12=p1.distanceTo(p2);
    Point dir1((x()-p1.x())/d1, (y()-p1.y())/d1, (z()-p1.z())/d1);
    Point dir2((x()-p2.x())/d2, (y()-p2.y())/d2, (z()-p2.z())/d2);
    Point dir12((p2.x()-p1.x())/d12, (p2.y()-p1.y())/d12, (p2.z()-p1.z())/d12);
    double costheta1=dir1.x()*dir12.x()+dir1.y()*dir12.y()+dir1.z()*dir12.z();
    double costheta2=-dir2.x()*dir12.x()-dir2.y()*dir12.y()-dir2.z()*dir12.z();
    if((costheta1 < 0.) || (costheta2 < 0.))
      return -1.;
    double d=d1*::sqrt(1.-costheta1*costheta1);
    return d;
  }
double QGpCoreTools::Point::elevationTo ( const Point p) const

Calculates the angle from horizontal plane (Z axis). This is the third spherical coordinate.

See also:
distanceTo(), azimuthTo()

References QGpCoreTools::sqrt(), QGpCoreTools::Point2D::x(), QGpCoreTools::Point2D::y(), and z().

  {
    double tmp=x()-p.x();
    double dist=tmp*tmp;
    tmp=y()-p.y();
    dist+=tmp*tmp;
    return atan2(p.z()-_z, ::sqrt(dist));
  }

Extracts coordinates from string str.

Reimplemented from QGpCoreTools::Point2D.

References QGpCoreTools::StringSection::isValid(), QGpCoreTools::StringSection::nextField(), QGpCoreTools::Point2D::setX(), QGpCoreTools::Point2D::setY(), QGpCoreTools::StringSection::toDouble(), and TRACE.

Referenced by createCurve(), main(), QGpCoreTools::operator>>(), CoordReader::parse(), ProfileReader::setOptions(), TargetAdd::setOptions(), DinverDCCore::ParamGroundModel::xml_setProperty(), DinverDCCore::TargetList::xml_setProperty(), and GeopsyCore::Signal::xml_setProperty().

  {
    TRACE;
    const QChar * ptr=0;
    StringSection f;
    f=str.nextField(ptr);
    if(f.isValid()) setX(f.toDouble()); else return false;
    f=str.nextField(ptr);
    if(f.isValid()) setY(f.toDouble()); else return false;
    f=str.nextField(ptr);
    if(f.isValid()) _z=f.toDouble(); else _z=0.0;
    return true;
  }
void QGpCoreTools::Point::interpole ( double  valX,
const Point p1,
const Point p2 
) [inline]

Interpole between two points

References QGpCoreTools::Point2D::setX(), QGpCoreTools::Point2D::setY(), setZ(), QGpCoreTools::Point2D::x(), QGpCoreTools::Point2D::y(), and z().

{
  double factor=(valX-p1.x())/(p2.x()-p1.x());
  setX(valX);
  setY(p1.y()+(p2.y()-p1.y())*factor);
  setZ(p1.z()+(p2.z()-p1.z())*factor);
}
bool QGpCoreTools::Point::isSimilar ( const Point p,
double  tolerance 
) const [inline]

References z().

Referenced by QGpCoreTools::Segment::distanceTo(), QGpCoreTools::Segment::isSimilar(), and QGpCoreTools::Segment::parallelTo().

{
  return Point2D::isSimilar(p, tolerance) &&
         fabs(p.z()-z())<tolerance;
}
bool QGpCoreTools::Point::isValid ( ) const [inline]

Return always true. Used by Curve.

Reimplemented from QGpCoreTools::Point2D.

{return true;}
void QGpCoreTools::Point::move ( double  distance,
const Angle azimuth,
const Angle elevation 
)

Moves this point by distance in direction azimuth (radians, mathematical sense, 0 is east) and elevation (radians, mathematical sense from horizontal plane).

References QGpCoreTools::Angle::cos(), and QGpCoreTools::Angle::sin().

  {
    Point2D::move(distance*elevation.cos(), azimuth);
    _z+=distance*elevation.sin();
  }
bool QGpCoreTools::Point::operator!= ( const Point obj) const [inline]
    {return ! (*this==obj);}
Point QGpCoreTools::Point::operator* ( double  mul) const [inline]

Reimplemented from QGpCoreTools::Point2D.

Reimplemented in QGpCoreTools::NamedPoint.

References Point(), QGpCoreTools::Point2D::x(), and QGpCoreTools::Point2D::y().

{
  return Point(x()*mul, y()*mul, _z*mul);
}
Point QGpCoreTools::Point::operator* ( const Point p) const [inline]

Reimplemented in QGpCoreTools::NamedPoint.

References Point(), QGpCoreTools::Point2D::x(), and QGpCoreTools::Point2D::y().

{
  return Point (x()*p.x(), y()*p.y(), _z*p._z);
}
void QGpCoreTools::Point::operator*= ( const Point p) [inline]

Referenced by operator*=(), and operator/=().

{
  Point2D::operator*=(p);
  _z*=p._z;
}
void QGpCoreTools::Point::operator*= ( double  mul) [inline]

Reimplemented from QGpCoreTools::Point2D.

References operator*=().

{
  Point2D::operator*=(mul);
  _z*=mul;
}
void QGpCoreTools::Point::operator*= ( const Matrix3x3 transformation)
  {
    *this=transformation*(*this);
  }
void QGpCoreTools::Point::operator*= ( const Matrix4x4 transformation)
  {
    *this=transformation*(*this);
  }
Point QGpCoreTools::Point::operator+ ( const Point p) const [inline]

Reimplemented in QGpCoreTools::NamedPoint.

References Point(), QGpCoreTools::Point2D::x(), and QGpCoreTools::Point2D::y().

{
  return Point(x()+p.x(), y()+p.y(), _z+p._z);
}
void QGpCoreTools::Point::operator+= ( const Point p) [inline]
{
  Point2D::operator+=(p);
  _z+=p._z;
}
Point QGpCoreTools::Point::operator- ( const Point p) const [inline]

Reimplemented in QGpCoreTools::NamedPoint.

References Point(), QGpCoreTools::Point2D::x(), and QGpCoreTools::Point2D::y().

{
  return Point(x()-p.x(), y()-p.y(), _z-p._z);
}
void QGpCoreTools::Point::operator-= ( const Point p) [inline]
{
  Point2D::operator-=(p);
  _z-=p._z;
}
Point QGpCoreTools::Point::operator/ ( double  div) const [inline]

Reimplemented from QGpCoreTools::Point2D.

Reimplemented in QGpCoreTools::NamedPoint.

References Point(), QGpCoreTools::Point2D::x(), and QGpCoreTools::Point2D::y().

{
  double f=1.0/div;
  return Point (x()*f, y()*f, _z*f);
}
Point QGpCoreTools::Point::operator/ ( const Point p) const [inline]

Reimplemented in QGpCoreTools::NamedPoint.

References Point(), QGpCoreTools::Point2D::x(), and QGpCoreTools::Point2D::y().

{
  return Point (x()/p.x(), y()/p.y(), _z/p._z);
}
void QGpCoreTools::Point::operator/= ( const Point p) [inline]
{
  Point2D::operator/=(p);
  _z/=p._z;
}
void QGpCoreTools::Point::operator/= ( double  div) [inline]

Reimplemented from QGpCoreTools::Point2D.

References operator*=().

{
  double f=1.0/div;
  Point2D::operator*=(f);
  _z*=f;
}
bool QGpCoreTools::Point::operator< ( const Point p) const [inline]

References QGpCoreTools::Point2D::x(), and QGpCoreTools::Point2D::y().

{
  if(x()<p.x()) return true;
  else if(x()==p.x()) {
    if(y()< p.y()) return true;
    else if(y()==p.y() && _z < p._z) return true;
  }
  return false;
}
bool QGpCoreTools::Point::operator<= ( const Point obj) const [inline]
    {return *this==obj || *this<obj;}
Point & QGpCoreTools::Point::operator= ( const Point p) [inline]

Reimplemented in QGpCoreTools::NamedPoint.

Referenced by operator=().

{
  Point2D::operator=(p);
  _z=p._z;
  return *this;
}
Point & QGpCoreTools::Point::operator= ( const Point2D p) [inline]

Reimplemented from QGpCoreTools::Point2D.

Reimplemented in QGpCoreTools::NamedPoint, and TapePoint.

References operator=().

{
  Point2D::operator=(p);
  _z=0.0;
  return *this;
}
bool QGpCoreTools::Point::operator== ( const Point p) const [inline]
{
  return Point2D::operator==(p) && _z==p._z;
}
bool QGpCoreTools::Point::operator> ( const Point obj) const [inline]
    {return ! (*this<=obj);}
bool QGpCoreTools::Point::operator>= ( const Point obj) const [inline]
    {return ! (*this<obj);}
double QGpCoreTools::Point::scalarProduct ( const Point p) const [inline]

References QGpCoreTools::Point2D::x(), and QGpCoreTools::Point2D::y().

Referenced by QGpCoreTools::Segment::distanceTo().

{
  return x()*p.x()+y()*p.y()+_z*p._z;
}
void QGpCoreTools::Point::set ( double  xi,
double  yi,
double  zi = 0.0 
) [inline]

Referenced by GeopsyCore::SubSignalPool::rotateComponents().

{
  Point2D::set(xi, yi);
  _z=zi;
}
void QGpCoreTools::Point::setValid ( bool  v) [inline]

Does nothing. Used by Curve.

Reimplemented from QGpCoreTools::Point2D.

{}
void QGpCoreTools::Point::setZ ( double  v) [inline]
QString QGpCoreTools::Point::toString ( int  precision = 6,
char  format = 'g' 
) const

Returns the point as a string with space separation between coordinates. precision is the number of significant digits. format is 'g' or 'f'.

Reimplemented from QGpCoreTools::Point2D.

Reimplemented in QGpCoreTools::NamedPoint.

References TRACE, QGpCoreTools::Point2D::x(), and QGpCoreTools::Point2D::y().

Referenced by TargetExtract::execute(), DinverDCCore::TargetList2D::humanInfo(), SpectrumStation::save(), HVStation::save(), ToolSPAC::setArrayMap(), ProfileReader::terminate(), CoordReader::terminate(), DinverDCCore::ParamGroundModel::xml_writeProperties(), and DinverDCCore::TargetList::xml_writeProperties().

  {
    TRACE;
    QString tmp;
    tmp+=QString::number(x(), format, precision);
    tmp+=" ";
    tmp+=QString::number(y(), format, precision);
    tmp+=" ";
    tmp+=QString::number(_z, format, precision);
    return tmp;
  }
void QGpCoreTools::Point::translate ( const Point p) [inline]

Referenced by CoordReader::parse().

{operator+=(p);}
void QGpCoreTools::Point::vectorialProduct ( const Point p1,
const Point p2 
) [inline]

References QGpCoreTools::Point2D::setX(), QGpCoreTools::Point2D::setY(), setZ(), QGpCoreTools::Point2D::x(), QGpCoreTools::Point2D::y(), and z().

{
  setX(p1.y()*p2.z()-p2.y()*p1.z());
  setY(-p1.x()*p2.z()+p2.x()*p1.z());
  setZ(p1.x()*p2.y()-p2.x()*p1.y());
}
double QGpCoreTools::Point::z ( ) const [inline]

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