DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Private Attributes
DGtal::StraightLineFrom2Points< TPoint > Class Template Reference

#include <StraightLineFrom2Points.h>

Collaboration diagram for DGtal::StraightLineFrom2Points< TPoint >:
Collaboration graph
[legend]

Public Types

typedef TPoint::Coordinate Coordinate
typedef Coordinate Distance
typedef TPoint Point
typedef TPoint Vector

Public Member Functions

 StraightLineFrom2Points ()
 StraightLineFrom2Points (const Point &aFirstPoint, const Point &aSecondPoint)
void init (const Point &aFirstPoint, const Point &aSecondPoint)
 StraightLineFrom2Points (const StraightLineFrom2Points &other)
StraightLineFrom2Pointsoperator= (const StraightLineFrom2Points &other)
 ~StraightLineFrom2Points ()
void selfDisplay (std::ostream &out) const
bool isValid () const
Distance signedDistance (const Point &aP) const
const Pointp () const
const Pointq () const
std::string className () const

Private Attributes

Point myP
Point myQ

Detailed Description

template<typename TPoint>
class DGtal::StraightLineFrom2Points< TPoint >

Aim: Represents a straight line uniquely defined by two 2D points and that is able to return for any given 2D point its signed distance to itself.

Template Parameters:
TPointa type of points.

Definition at line 68 of file StraightLineFrom2Points.h.


Member Typedef Documentation

template<typename TPoint>
typedef TPoint::Coordinate DGtal::StraightLineFrom2Points< TPoint >::Coordinate

Definition at line 74 of file StraightLineFrom2Points.h.

template<typename TPoint>
typedef Coordinate DGtal::StraightLineFrom2Points< TPoint >::Distance

Definition at line 75 of file StraightLineFrom2Points.h.

template<typename TPoint>
typedef TPoint DGtal::StraightLineFrom2Points< TPoint >::Point

Definition at line 76 of file StraightLineFrom2Points.h.

template<typename TPoint>
typedef TPoint DGtal::StraightLineFrom2Points< TPoint >::Vector

Definition at line 77 of file StraightLineFrom2Points.h.


Constructor & Destructor Documentation

template<typename TPoint >
DGtal::StraightLineFrom2Points< TPoint >::StraightLineFrom2Points ( )
inline

Default constructor.

Definition at line 49 of file StraightLineFrom2Points.ih.

{
}
template<typename TPoint >
DGtal::StraightLineFrom2Points< TPoint >::StraightLineFrom2Points ( const Point aFirstPoint,
const Point aSecondPoint 
)
inline

Constructor.

Parameters:
firstPointa point
secondPointanother point

Definition at line 67 of file StraightLineFrom2Points.ih.

:
myP(aFirstPoint),
myQ(aSecondPoint)
{
}
template<typename TPoint >
DGtal::StraightLineFrom2Points< TPoint >::StraightLineFrom2Points ( const StraightLineFrom2Points< TPoint > &  other)
inline

Copy constructor.

Parameters:
otherthe object to clone.

Definition at line 78 of file StraightLineFrom2Points.ih.

:
myP(other.myP),
myQ(other.myQ)
{
}
template<typename TPoint >
DGtal::StraightLineFrom2Points< TPoint >::~StraightLineFrom2Points ( )
inline

Destructor. Does nothing

Definition at line 43 of file StraightLineFrom2Points.ih.

{
}

Member Function Documentation

template<typename TPoint >
std::string DGtal::StraightLineFrom2Points< TPoint >::className ( ) const
inline

Default drawing style object.

Returns:
the dyn. alloc. default style for this object.
the style name used for drawing this object.

Definition at line 118 of file StraightLineFrom2Points.ih.

{
return "StraightLineFrom2Points";
}
template<typename TPoint >
void DGtal::StraightLineFrom2Points< TPoint >::init ( const Point aFirstPoint,
const Point aSecondPoint 
)
inline

Init.

Parameters:
firstPointa point
secondPointanother point

Definition at line 56 of file StraightLineFrom2Points.ih.

{
myP = aFirstPoint;
myQ = aSecondPoint;
}
template<typename TPoint >
bool DGtal::StraightLineFrom2Points< TPoint >::isValid ( ) const
inline

Checks the validity/consistency of the object.

Returns:
'true' if the object is valid, 'false' otherwise.

Definition at line 135 of file StraightLineFrom2Points.ih.

{
return true;
}
template<typename TPoint >
DGtal::StraightLineFrom2Points< TPoint > & DGtal::StraightLineFrom2Points< TPoint >::operator= ( const StraightLineFrom2Points< TPoint > &  other)
inline

Assignment.

Parameters:
otherthe object to copy.
Returns:
a reference on 'this'.

Definition at line 89 of file StraightLineFrom2Points.ih.

References DGtal::StraightLineFrom2Points< TPoint >::myP, and DGtal::StraightLineFrom2Points< TPoint >::myQ.

{
myP = other.myP;
myQ = other.myQ;
return *this;
}
template<typename TPoint>
const Point& DGtal::StraightLineFrom2Points< TPoint >::p ( ) const
inline
Returns:
the first point through which the straight line passes.

Definition at line 146 of file StraightLineFrom2Points.h.

References DGtal::StraightLineFrom2Points< TPoint >::myP.

Referenced by DGtal::Display2DFactory::draw().

{
return myP;
};
template<typename TPoint>
const Point& DGtal::StraightLineFrom2Points< TPoint >::q ( ) const
inline
Returns:
the second point through which the straight line passes.

Definition at line 154 of file StraightLineFrom2Points.h.

References DGtal::StraightLineFrom2Points< TPoint >::myQ.

Referenced by DGtal::Display2DFactory::draw().

{
return myQ;
};
template<typename TPoint >
void DGtal::StraightLineFrom2Points< TPoint >::selfDisplay ( std::ostream &  out) const
inline

Writes/Displays the object on an output stream.

Parameters:
outthe output stream where the object is written.

Definition at line 126 of file StraightLineFrom2Points.ih.

{
out << "[StraightLineFrom2Points] passing through:\n";
out << myP << myQ;
}
template<typename TPoint >
DGtal::StraightLineFrom2Points< TPoint >::Distance DGtal::StraightLineFrom2Points< TPoint >::signedDistance ( const Point aP) const
inline

Computes the signed distance of to the straight line

Parameters:
aPthe point to be tested.
Returns:
the signed distance.

Definition at line 102 of file StraightLineFrom2Points.ih.

{
Vector pq = myQ - myP;
Vector pr = aP - myP;
//computation of det(pq, pr)
//(= twice the parallelogram area)
return ((pq.at(0) * pr.at(1)) - (pq.at(1) * pr.at(0)));
}

Field Documentation

template<typename TPoint>
Point DGtal::StraightLineFrom2Points< TPoint >::myP
private

First point through which the straight line passes

Definition at line 179 of file StraightLineFrom2Points.h.

Referenced by DGtal::StraightLineFrom2Points< TPoint >::operator=(), and DGtal::StraightLineFrom2Points< TPoint >::p().

template<typename TPoint>
Point DGtal::StraightLineFrom2Points< TPoint >::myQ
private

Second point through which the straight line passes

Definition at line 183 of file StraightLineFrom2Points.h.

Referenced by DGtal::StraightLineFrom2Points< TPoint >::operator=(), and DGtal::StraightLineFrom2Points< TPoint >::q().


The documentation for this class was generated from the following files: