Public Member Functions | Static Public Member Functions | List of all members
i2d::CLine2d Class Reference

Definition of a line in 2D-space. More...

#include <CLine2d.h>

Inheritance diagram for i2d::CLine2d:
i2d::CObject2dBase i2d::IObject2d iser::IObject i2d::ICalibrationProvider iser::ISerializable istd::IChangeable istd::IChangeable istd::IPolymorphic istd::IPolymorphic i2d::TObject2dCompWrap< CLine2d > i2d::CLine2dComp

Public Member Functions

 CLine2d ()
 
 CLine2d (const CVector2d &p1, const CVector2d &p2)
 
 CLine2d (double x1, double y1, double x2, double y2)
 
bool operator== (const CLine2d &line) const
 
bool operator!= (const CLine2d &line) const
 
bool IsNull () const
 Returns true, if the line has a length equal 0. More...
 
const CVector2dGetPoint1 () const
 Get value of first line point. More...
 
CVector2dGetPoint1Ref ()
 Get reference to first line point. More...
 
void SetPoint1 (const CVector2d &point)
 Set value of first line point. More...
 
const CVector2dGetPoint2 () const
 Get value of second line point. More...
 
CVector2dGetPoint2Ref ()
 Get reference to second line point. More...
 
void SetPoint2 (const CVector2d &point)
 Set value of second line point. More...
 
double GetSlope () const
 Get slope of this line. More...
 
double GetIntercept () const
 Get intercept of this line. More...
 
bool IsParallel (const CLine2d &line) const
 Check if this line is parallel to another one. More...
 
bool IsIntersectedBy (const CLine2d &line) const
 Check if two lines intersect. More...
 
bool GetIntersection (const CLine2d &line, CVector2d &result) const
 Get intersection position of two lines. More...
 
bool GetExtendedIntersection (const CLine2d &line, CVector2d &result) const
 Get intersection position of extended lines. More...
 
double GetDistance (const CVector2d &position) const
 Get distance from nearest point of this line to specified position. More...
 
double GetMaxDistance (const CVector2d &position) const
 Get maximal distance from points of this line to specified position. More...
 
double GetExtendedDistance (const CVector2d &position) const
 Get distance from nearest point of extended line to specified position. More...
 
CVector2d GetPositionFromAlpha (double alpha) const
 Get position of point using normed 'alpha' value. More...
 
CVector2d GetDiffVector () const
 Get difference vector from point 1 to point 2. More...
 
double GetLength () const
 Get distance between line points. More...
 
double GetLength2 () const
 Get quadratic distance between line points. More...
 
double GetDirectionAngle () const
 Get direction angle of this line. More...
 
CLine2d GetClipped (const CRectangle &rect) const
 Get part of line intersecting specified rectangle. More...
 
CLine2d GetSwapped () const
 Get the line with replaced points (p1 = p2 and p2 = p1) More...
 
double GetCutXPos (double linePosY) const
 Get Y position of cutting this line by specified horizontal line. More...
 
double GetCutYPos (double linePosX) const
 Get X position of cutting this line by specified vertical line. More...
 
void PushBeginPoint (const i2d::CVector2d &newBeginPoint)
 Copy begin point to end point and set new begin point. More...
 
void PushEndPoint (const i2d::CVector2d &newEndPoint)
 Copy end point to begin point and set new end point. More...
 
void PushBeginPointQuiet (const i2d::CVector2d &newBeginPoint)
 Quiet methods do not trigger any notification changes (to be used inside of algorithms) More...
 
void PushEndPointQuiet (const i2d::CVector2d &newEndPoint)
 
void SetPoint1Quiet (const CVector2d &point)
 
void SetPoint2Quiet (const CVector2d &point)
 
double GetCutAlpha (const CLine2d &line) const
 Get a proportion of lines cut point to line length (called also 'alpha value'). More...
 
double GetCastAlpha (const i2d::CVector2d &point) const
 
QPair< double, double > GetAlphaAndCastDistance (const i2d::CVector2d &point) const
 Get projection position 'alpha value' and orthogonal distance to line. More...
 
bool GetCutPoint (const CLine2d &otherLine, i2d::CVector2d &cutPoint) const
 Get position where this line intersects the second one. More...
 
i2d::CVector2d GetNearestPoint (const i2d::CVector2d &point) const
 Return a line point, which is the nearest to the specified point. More...
 
i2d::CVector2d GetExtendedNearestPoint (const i2d::CVector2d &point) const
 Return a point on the straight line in a mathematical sense, which is the nearest to the specified point. More...
 
CLine2d GetShortestEndConnection (const CLine2d &line) const
 Return a line, which connects the nearest end points of two lines. More...
 
CLine2d GetShortestConnectionToNext (const CLine2d &line) const
 Return a line, which connects the nearest points of two lines. More...
 
CLine2d GetShortestConnection (const i2d::CVector2d &point) const
 Return a line, which connects the nearest point of line and specified point. More...
 
CLine2d GetShortestConnection (const CLine2d &line) const
 Return a line, which connects the nearest points of two lines. More...
 
bool ApproxFromPoints (const QSet< i2d::CVector2d > &points)
 Calculate this line as approximation of set of points. More...
 
virtual CVector2d GetCenter () const
 Returns center of this 2D-object. More...
 
virtual void MoveCenterTo (const CVector2d &position)
 Move object to position position. More...
 
virtual CRectangle GetBoundingBox () const
 Get bounding box of this shape. More...
 
virtual bool Transform (const ITransformation2d &transformation, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=NULL)
 Transform this object using some transformation. More...
 
virtual bool InvTransform (const ITransformation2d &transformation, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=NULL)
 Do inverse transformation of this object. More...
 
virtual bool GetTransformed (const ITransformation2d &transformation, IObject2d &result, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=NULL) const
 Calulate transformation of the object into second one. More...
 
virtual bool GetInvTransformed (const ITransformation2d &transformation, IObject2d &result, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=NULL) const
 Calulate inverse transformation of the object into second one. More...
 
virtual QByteArray GetFactoryId () const
 
virtual bool Serialize (iser::IArchive &archive)
 Load or store state of this object as a archive stream. More...
 
virtual int GetSupportedOperations () const
 Get set of flags for supported operations. More...
 
virtual bool CopyFrom (const IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS)
 
virtual istd::IChangeableCloneMe (CompatibilityMode mode=CM_WITHOUT_REFS) const
 Make a copy of this object. More...
 
- Public Member Functions inherited from i2d::CObject2dBase
 CObject2dBase ()
 
 CObject2dBase (const CObject2dBase &object2d)
 
virtual const ICalibration2dGetCalibration () const
 Get access to transformation object, which transforms a local logical coordinate system to global one. More...
 
virtual void SetCalibration (const ICalibration2d *calibrationPtr, bool releaseFlag=false)
 Set calibration of this object. More...
 
virtual bool CopyFrom (const istd::IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS)
 Copy this object from another one. More...
 
virtual bool ResetData (CompatibilityMode mode=CM_WITHOUT_REFS)
 Reset data to its default state. More...
 
- Public Member Functions inherited from iser::ISerializable
virtual quint32 GetMinimalVersion (int versionId) const
 Get minimal needed version to correct storing of this data. More...
 
- Public Member Functions inherited from istd::IChangeable
virtual bool IsEqual (const IChangeable &object) const
 Compare this object with another object. More...
 
virtual void BeginChanges (const ChangeSet &changeSet)
 Starts the change transaction. More...
 
virtual void EndChanges (const ChangeSet &changeSet)
 Ends the change transaction. More...
 
virtual void BeginChangeGroup (const ChangeSet &changeSet)
 Starts group of changes. More...
 
virtual void EndChangeGroup (const ChangeSet &changeSet)
 Ends group of changes. More...
 
- Public Member Functions inherited from istd::IPolymorphic
virtual ~IPolymorphic ()
 

Static Public Member Functions

static QByteArray GetTypeName ()
 
- Static Public Member Functions inherited from istd::IChangeable
static const ChangeSetGetNoChanges ()
 Get empty set of changes. More...
 
static const ChangeSetGetAnyChange ()
 Get anonymous change set. More...
 
static const ChangeSetGetAllChanges ()
 Get anonymous change set. More...
 
static const ChangeSetGetDelegatedChanges ()
 Get delegated change set. More...
 

Additional Inherited Members

- Public Types inherited from i2d::IObject2d
enum  ChangeFlags { CF_OBJECT_POSITION = 0x6ba340 }
 
- Public Types inherited from istd::IChangeable
enum  ChangeFlags {
  CF_ACF_INTERNAL = 0, CF_ALL_DATA, CF_ANY, CF_DESTROYING,
  CF_DELEGATED, CF_NO_UNDO
}
 Data model change notification flags. More...
 
enum  SupportedOperations {
  SO_NONE = 0, SO_OBSERVE = 1 << 0, SO_COPY = 1 << 1, SO_CLONE = 1 << 2,
  SO_COMPARE = 1 << 3, SO_RESET = 1 << 4
}
 Flags for supported operations. More...
 
enum  CompatibilityMode { CM_STRICT, CM_WITHOUT_REFS, CM_WITH_REFS, CM_CONVERT }
 Control how relationship betweeen objects are interpreted. More...
 
- Protected Member Functions inherited from istd::IChangeable
virtual void OnBeginChanges ()
 Callback function for begin change event. More...
 
virtual void OnEndChanges (const ChangeSet &changeSet)
 Callback function for end change event. More...
 
- Static Protected Attributes inherited from i2d::CObject2dBase
static const ChangeSet s_objectMovedChange
 
static const ChangeSet s_objectModifiedChange
 

Detailed Description

Definition of a line in 2D-space.

Line is stored as the ordered set of two points.

Definition at line 24 of file CLine2d.h.

Constructor & Destructor Documentation

i2d::CLine2d::CLine2d ( )
i2d::CLine2d::CLine2d ( const CVector2d p1,
const CVector2d p2 
)
i2d::CLine2d::CLine2d ( double  x1,
double  y1,
double  x2,
double  y2 
)

Member Function Documentation

bool i2d::CLine2d::ApproxFromPoints ( const QSet< i2d::CVector2d > &  points)

Calculate this line as approximation of set of points.

virtual istd::IChangeable* i2d::CLine2d::CloneMe ( CompatibilityMode  mode = CM_WITHOUT_REFS) const
virtual

Make a copy of this object.

Returns
new instance or NULL, if this operation is not supported.

Reimplemented from istd::IChangeable.

virtual bool i2d::CLine2d::CopyFrom ( const IChangeable &  object,
CompatibilityMode  mode = CM_WITHOUT_REFS 
)
virtual
QPair< double, double > i2d::CLine2d::GetAlphaAndCastDistance ( const i2d::CVector2d point) const
inline

Get projection position 'alpha value' and orthogonal distance to line.

Returns
first value equals result of GetCastAlpha, the second is GetExtendedDistance, but it can be negative for positions on the left size.

Definition at line 383 of file CLine2d.h.

References i2d::CVector2d::GetCrossProductZ(), i2d::CVector2d::GetDotProduct(), and imath::TVector< Size, Element >::GetLength2().

virtual CRectangle i2d::CLine2d::GetBoundingBox ( ) const
virtual

Get bounding box of this shape.

Please note, this bounding box is in logical units, the calibration will not be considered.

Implements i2d::IObject2d.

double i2d::CLine2d::GetCastAlpha ( const i2d::CVector2d point) const
inline
virtual CVector2d i2d::CLine2d::GetCenter ( ) const
virtual

Returns center of this 2D-object.

Implements i2d::IObject2d.

CLine2d i2d::CLine2d::GetClipped ( const CRectangle rect) const

Get part of line intersecting specified rectangle.

double i2d::CLine2d::GetCutAlpha ( const CLine2d line) const
inline

Get a proportion of lines cut point to line length (called also 'alpha value').

Definition at line 360 of file CLine2d.h.

References i2d::CVector2d::GetCrossProductZ(), GetDiffVector(), and GetPoint1().

bool i2d::CLine2d::GetCutPoint ( const CLine2d otherLine,
i2d::CVector2d cutPoint 
) const

Get position where this line intersects the second one.

Returns
true, if this lines intersect and intersection position can be calculated.
double i2d::CLine2d::GetCutXPos ( double  linePosY) const
inline

Get Y position of cutting this line by specified horizontal line.

Definition at line 344 of file CLine2d.h.

References GetDiffVector(), i2d::CVector2d::GetX(), and i2d::CVector2d::GetY().

double i2d::CLine2d::GetCutYPos ( double  linePosX) const
inline

Get X position of cutting this line by specified vertical line.

Definition at line 352 of file CLine2d.h.

References GetDiffVector(), i2d::CVector2d::GetX(), and i2d::CVector2d::GetY().

CVector2d i2d::CLine2d::GetDiffVector ( ) const
inline

Get difference vector from point 1 to point 2.

Definition at line 314 of file CLine2d.h.

Referenced by GetCastAlpha(), GetCutAlpha(), GetCutXPos(), and GetCutYPos().

double i2d::CLine2d::GetDirectionAngle ( ) const

Get direction angle of this line.

It will be returned in radians conform to i2d::CVector2d::GetAngle().

double i2d::CLine2d::GetDistance ( const CVector2d position) const

Get distance from nearest point of this line to specified position.

double i2d::CLine2d::GetExtendedDistance ( const CVector2d position) const

Get distance from nearest point of extended line to specified position.

As extended line are mean mathematical lines going over specified line points.

bool i2d::CLine2d::GetExtendedIntersection ( const CLine2d line,
CVector2d result 
) const

Get intersection position of extended lines.

As extended line are mean mathematical lines going over specified line points.

Parameters
linesecond line.
resultobject will be set to intersection point.
Returns
true if extended intersection could be calculated.
i2d::CVector2d i2d::CLine2d::GetExtendedNearestPoint ( const i2d::CVector2d point) const

Return a point on the straight line in a mathematical sense, which is the nearest to the specified point.

virtual QByteArray i2d::CLine2d::GetFactoryId ( ) const
virtual

Reimplemented from iser::IObject.

double i2d::CLine2d::GetIntercept ( ) const

Get intercept of this line.

Intercept is derivative value along Y axis (dy/dx) of line function.

bool i2d::CLine2d::GetIntersection ( const CLine2d line,
CVector2d result 
) const

Get intersection position of two lines.

Parameters
linesecond line.
resultobject will be set to intersection point.
Returns
true if lines intersects and intersection could be calculated.
virtual bool i2d::CLine2d::GetInvTransformed ( const ITransformation2d transformation,
IObject2d result,
ITransformation2d::ExactnessMode  mode = ITransformation2d::EM_NONE,
double *  errorFactorPtr = NULL 
) const
virtual

Calulate inverse transformation of the object into second one.

Please note, that this operation transforms logical coordinates, it means that the calibration will be ignored.

Parameters
modecontrols needed transformation exactness.
errorFactorPtroptional output where approximated length of transformation error vector will be stored. Value 0 means that transformation is exactly done.
resultresult object.
Returns
true, if transformation was done correctly.

Reimplemented from i2d::CObject2dBase.

double i2d::CLine2d::GetLength ( ) const

Get distance between line points.

double i2d::CLine2d::GetLength2 ( ) const

Get quadratic distance between line points.

double i2d::CLine2d::GetMaxDistance ( const CVector2d position) const

Get maximal distance from points of this line to specified position.

i2d::CVector2d i2d::CLine2d::GetNearestPoint ( const i2d::CVector2d point) const

Return a line point, which is the nearest to the specified point.

const CVector2d & i2d::CLine2d::GetPoint1 ( ) const
inline

Get value of first line point.

Definition at line 320 of file CLine2d.h.

Referenced by GetCutAlpha(), and i2d::qHash().

CVector2d & i2d::CLine2d::GetPoint1Ref ( )
inline

Get reference to first line point.

Please avoid to use this function because of possible update problems.

Definition at line 326 of file CLine2d.h.

const CVector2d & i2d::CLine2d::GetPoint2 ( ) const
inline

Get value of second line point.

Definition at line 332 of file CLine2d.h.

Referenced by i2d::qHash().

CVector2d & i2d::CLine2d::GetPoint2Ref ( )
inline

Get reference to second line point.

Please avoid to use this function because of possible update problems.

Definition at line 338 of file CLine2d.h.

CVector2d i2d::CLine2d::GetPositionFromAlpha ( double  alpha) const

Get position of point using normed 'alpha' value.

Value 0 will be mapped to point 1 and value 1 will be mapped to point 2.

CLine2d i2d::CLine2d::GetShortestConnection ( const i2d::CVector2d point) const

Return a line, which connects the nearest point of line and specified point.

CLine2d i2d::CLine2d::GetShortestConnection ( const CLine2d line) const

Return a line, which connects the nearest points of two lines.

CLine2d i2d::CLine2d::GetShortestConnectionToNext ( const CLine2d line) const

Return a line, which connects the nearest points of two lines.

Only connection between end point of first line and second line or connection between first line and begin point of second line will be checked.

CLine2d i2d::CLine2d::GetShortestEndConnection ( const CLine2d line) const

Return a line, which connects the nearest end points of two lines.

double i2d::CLine2d::GetSlope ( ) const

Get slope of this line.

Slope is derivative value along X axis (dx/dy) of line function.

virtual int i2d::CLine2d::GetSupportedOperations ( ) const
virtual

Get set of flags for supported operations.

See Also
SupportedOperations

Reimplemented from istd::IChangeable.

CLine2d i2d::CLine2d::GetSwapped ( ) const

Get the line with replaced points (p1 = p2 and p2 = p1)

virtual bool i2d::CLine2d::GetTransformed ( const ITransformation2d transformation,
IObject2d result,
ITransformation2d::ExactnessMode  mode = ITransformation2d::EM_NONE,
double *  errorFactorPtr = NULL 
) const
virtual

Calulate transformation of the object into second one.

Please note, that this operation transforms logical coordinates, it means that the calibration will be ignored.

Parameters
modecontrols needed transformation exactness.
errorFactorPtroptional output where approximated length of transformation error vector will be stored. Value 0 means that transformation is exactly done.
resultresult object.
Returns
true, if transformation was done correctly.

Reimplemented from i2d::CObject2dBase.

static QByteArray i2d::CLine2d::GetTypeName ( )
static
virtual bool i2d::CLine2d::InvTransform ( const ITransformation2d transformation,
ITransformation2d::ExactnessMode  mode = ITransformation2d::EM_NONE,
double *  errorFactorPtr = NULL 
)
virtual

Do inverse transformation of this object.

Please note, that this operation transforms logical coordinates, it means that the calibration will be ignored.

Parameters
modecontrols needed transformation exactness.
errorFactorPtroptional output where approximated length of transformation error vector will be stored. Value 0 means that transformation is exactly done.
Returns
true, if transformation was done correctly.

Reimplemented from i2d::CObject2dBase.

bool i2d::CLine2d::IsIntersectedBy ( const CLine2d line) const

Check if two lines intersect.

Parameters
linesecond line.
Returns
true, if this line has common point.
bool i2d::CLine2d::IsNull ( ) const
inline

Returns true, if the line has a length equal 0.

Definition at line 308 of file CLine2d.h.

bool i2d::CLine2d::IsParallel ( const CLine2d line) const

Check if this line is parallel to another one.

virtual void i2d::CLine2d::MoveCenterTo ( const CVector2d position)
virtual

Move object to position position.

Implements i2d::IObject2d.

bool i2d::CLine2d::operator!= ( const CLine2d line) const
inline

Definition at line 302 of file CLine2d.h.

References operator==().

bool i2d::CLine2d::operator== ( const CLine2d line) const
inline

Definition at line 296 of file CLine2d.h.

Referenced by operator!=().

void i2d::CLine2d::PushBeginPoint ( const i2d::CVector2d newBeginPoint)

Copy begin point to end point and set new begin point.

void i2d::CLine2d::PushBeginPointQuiet ( const i2d::CVector2d newBeginPoint)
inline

Quiet methods do not trigger any notification changes (to be used inside of algorithms)

Definition at line 396 of file CLine2d.h.

void i2d::CLine2d::PushEndPoint ( const i2d::CVector2d newEndPoint)

Copy end point to begin point and set new end point.

void i2d::CLine2d::PushEndPointQuiet ( const i2d::CVector2d newEndPoint)
inline

Definition at line 403 of file CLine2d.h.

virtual bool i2d::CLine2d::Serialize ( iser::IArchive archive)
virtual

Load or store state of this object as a archive stream.

Type of operation is depending on archive type.

See Also
iser::IArchive

Implements iser::ISerializable.

void i2d::CLine2d::SetPoint1 ( const CVector2d point)

Set value of first line point.

void i2d::CLine2d::SetPoint1Quiet ( const CVector2d point)
inline

Definition at line 410 of file CLine2d.h.

void i2d::CLine2d::SetPoint2 ( const CVector2d point)

Set value of second line point.

void i2d::CLine2d::SetPoint2Quiet ( const CVector2d point)
inline

Definition at line 416 of file CLine2d.h.

virtual bool i2d::CLine2d::Transform ( const ITransformation2d transformation,
ITransformation2d::ExactnessMode  mode = ITransformation2d::EM_NONE,
double *  errorFactorPtr = NULL 
)
virtual

Transform this object using some transformation.

Please note, that this operation transforms logical coordinates, it means that the calibration will be ignored.

Parameters
modecontrols needed transformation exactness.
errorFactorPtroptional output where approximated length of transformation error vector will be stored. Value 0 means that transformation is exactly done.
Returns
true, if transformation was done correctly.

Reimplemented from i2d::CObject2dBase.


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

© 2007-2017 Witold Gantzke and Kirill Lepskiy