Vault  4.1
Public Member Functions | Static Public Member Functions | Friends
VLineT< T > Class Template Reference

VLineT defines a line segment with two points. More...

#include <vgeometry.h>

List of all members.

Public Member Functions

 VLineT (VPointT< T > start, VPointT< T > end)
 VLineT (VPointT< T > start, VSizeT< T > vec)
 VLineT (T x1, T y1, T x2, T y2)
 VLineT (T x1, T y1, VSizeT< T > vec)
 VLineT (VBinaryIOStream &stream)
void readFromStream (VBinaryIOStream &stream)
void writeToStream (VBinaryIOStream &stream) const
VPointT< T > getP1 () const
VPointT< T > getP2 () const
void setP1 (VPointT< T > p)
void setP2 (VPointT< T > p)
void setPoints (VPointT< T > p1, VPointT< T > p2)
VPointT< T > & rP1 ()
VPointT< T > & rP2 ()
VSizeT< T > getSize () const
getDX () const
getDY () const
VDouble getLength () const
void translate (const VPointT< T > &delta)
void translate (T deltaX, T deltaY)
VLineT< T > translated (const VPointT< T > &delta) const
VLineT< T > translated (T deltaX, T deltaY) const
VLineT< T > normalized () const
 Normalizes the line in the following sense: The resulting line's P1 and P2 will point left-to-right (+x), and if the x values are the same, it will point top-to-bottom (+y).
VLineT< T > reversed () const
VLineT< VDoublegetUnitVector () const
 Returns a VLine starting at P1, towards P2 but with length 1.0.
VPoint getNearestPoint (const VPoint &C, bool restrictToSegment) const
 Returns the point on this line (AB) that is the nearest to the supplied point C.
VDouble getDistanceToPoint (const VPoint &p, bool restrictToSegment) const

Static Public Member Functions

static bool equal (const VLineT< T > &line1, const VLineT< T > &line2)
static bool notEqual (const VLineT< T > &line1, const VLineT< T > &line2)
static bool same (const VLineT< T > &line1, const VLineT< T > &line2)
 Returns true if the two lines have the same endpoints (within 0.000001), regardless of their order.

Friends

bool operator== (const VLineT< T > &line1, const VLineT< T > &line2)
bool operator!= (const VLineT< T > &line1, const VLineT< T > &line2)

Detailed Description

template<typename T>
class VLineT< T >

VLineT defines a line segment with two points.

The order matters for equality and math. Use the same() function to test equality without respect to the order of the two points. VLine uses VDouble coordinates; VILine uses int coordinates.

Definition at line 331 of file vgeometry.h.


Member Function Documentation

template<typename T>
VLineT<T> VLineT< T >::normalized ( ) const [inline]

Normalizes the line in the following sense: The resulting line's P1 and P2 will point left-to-right (+x), and if the x values are the same, it will point top-to-bottom (+y).

This can be useful when comparing or using two lines when you don't want the "directionality" of the line to matter.

Returns:
a normalized copy of this line

Definition at line 374 of file vgeometry.h.

template<typename T>
VLineT<VDouble> VLineT< T >::getUnitVector ( ) const [inline]

Returns a VLine starting at P1, towards P2 but with length 1.0.

Returns:
a unit vector of this line

Definition at line 392 of file vgeometry.h.

template<typename T>
static bool VLineT< T >::same ( const VLineT< T > &  line1,
const VLineT< T > &  line2 
) [inline, static]

Returns true if the two lines have the same endpoints (within 0.000001), regardless of their order.

Parameters:
line1a line
line2a line
Returns:
true if line1 and line2 have the same endpoints

Definition at line 415 of file vgeometry.h.

template<typename T>
VPoint VLineT< T >::getNearestPoint ( const VPoint C,
bool  restrictToSegment 
) const [inline]

Returns the point on this line (AB) that is the nearest to the supplied point C.

You can specify whether this line is treated as a line segment (result within the segment) or not (result may be outside the segment). Note the input and result points are VPoint, not VPointT<T>, because even if this line is integer-based, the result may not be.

Parameters:
Ca point to test
restrictToSegmenttrue if the result must lie between endpoints
Returns:
the point along this line (or within segment) that is nearest to C

Definition at line 439 of file vgeometry.h.


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

Copyright ©1997-2014 Trygve Isaacson. All rights reserved. This documentation was generated with Doxygen.