library of assembled shared sources |
http://lass.cocamware.com |
#include <triangle_2d.h>
Data Structures | |
struct | Rebind |
Public Types | |
enum | { dimension = TPoint::dimension } |
typedef Triangle2D< T > | TSelf |
typedef Point2D< T > | TPoint |
typedef Point2DH< T > | TPointH |
typedef TPoint::TVector | TVector |
typedef LineSegment2D< T > | TLineSegment |
typedef TPoint::TValue | TValue |
typedef TPoint::TParam | TParam |
typedef TPoint::TReference | TReference |
typedef TPoint::TConstReference | TConstReference |
typedef TPoint::TNumTraits | TNumTraits |
Public Member Functions | |
Triangle2D () | |
constructs an empty triangle. | |
Triangle2D (const TPoint &iA, const TPoint &iB, const TPoint &iC) | |
Constructs a triangle through three points in positive sequence. | |
const TPoint & | operator[] (int iIndexOfVertex) const |
TPoint & | operator[] (int iIndexOfVertex) |
const TPoint & | at (int iIndexOfVertex) const |
TPoint & | at (int iIndexOfVertex) |
const TLineSegment | edge (int iIndexOfTailVertex) const |
const TVector | vector (int iIndexOfTailVertex) const |
const bool | isEmpty () const |
const int | size () const |
const TValue | signedArea () const |
const TValue | area () const |
const TValue | perimeter () const |
const TPointH | vertexCentroid () const |
const TPointH | surfaceCentroid () const |
const bool | isSimple () const |
const bool | isConvex () const |
const bool | isConcave () const |
const Orientation | orientation () const |
const bool | isReflex (int iIndexOfVertex) const |
const Side | classify (const TPoint &iP) const |
const bool | contains (const TPoint &iP) const |
return true when a point is inside or on the edge of a triangle. | |
void | flip () |
flip orientation of polygon. | |
Private Types | |
enum | { size_ = 3 } |
Private Member Functions | |
const bool | isInRange (int iIndexOfVertex) const |
return if index of vertex is in range of the std::vector | |
Private Attributes | |
TPoint | vertices_ [size_] |
Related Functions | |
(Note that these are not member functions.) | |
template<typename T > | |
Aabb2D< T > | aabb (const Triangle2D< T > &triangle) |
determine axis aligned bounding box of a 2D triangle | |
template<typename T , class NP , class PP > | |
Result | intersect (const Triangle2D< T > &triangle, const Ray2D< T, NP, PP > &ray, T &t, const T &tMin=T()) |
Find the intersection of a ray and a triangle by their parameter t on the ray. | |
template<typename T > | |
const T | squaredDistance (const Triangle2D< T > &triangle, const Point2D< T > &point) |
template<typename T > | |
const T | distance (const Triangle2D< T > &triangle, const Point2D< T > &point) |
template<typename T > | |
io::XmlOStream & | operator<< (io::XmlOStream &ioOStream, const Triangle2D< T > &iTriangle) |
template<typename T > | |
std::ostream & | operator<< (std::ostream &ioOStream, const Triangle2D< T > &iTriangle) |
template<typename T > | |
lass::io::MatlabOStream & | operator<< (lass::io::MatlabOStream &oOStream, const Triangle2D< T > &iTriangle) |
template<typename T > | |
T | partialVoronoiArea (const Triangle2D< T > iT, int iIndexOfVertex) |
Definition at line 64 of file triangle_2d.h.
typedef Triangle2D<T> lass::prim::Triangle2D< T >::TSelf |
Definition at line 68 of file triangle_2d.h.
typedef Point2D<T> lass::prim::Triangle2D< T >::TPoint |
Definition at line 70 of file triangle_2d.h.
typedef Point2DH<T> lass::prim::Triangle2D< T >::TPointH |
Definition at line 71 of file triangle_2d.h.
typedef TPoint::TVector lass::prim::Triangle2D< T >::TVector |
Definition at line 72 of file triangle_2d.h.
typedef LineSegment2D<T> lass::prim::Triangle2D< T >::TLineSegment |
Definition at line 73 of file triangle_2d.h.
typedef TPoint::TValue lass::prim::Triangle2D< T >::TValue |
Definition at line 75 of file triangle_2d.h.
typedef TPoint::TParam lass::prim::Triangle2D< T >::TParam |
Definition at line 76 of file triangle_2d.h.
typedef TPoint::TReference lass::prim::Triangle2D< T >::TReference |
Definition at line 77 of file triangle_2d.h.
typedef TPoint::TConstReference lass::prim::Triangle2D< T >::TConstReference |
Definition at line 78 of file triangle_2d.h.
typedef TPoint::TNumTraits lass::prim::Triangle2D< T >::TNumTraits |
Definition at line 79 of file triangle_2d.h.
anonymous enum |
anonymous enum [private] |
lass::prim::Triangle2D< T >::Triangle2D | ( | ) | [inline] |
constructs an empty triangle.
all vertices are (0, 0) and thus equal.
Definition at line 61 of file triangle_2d.inl.
lass::prim::Triangle2D< T >::Triangle2D | ( | const TPoint & | iA, | |
const TPoint & | iB, | |||
const TPoint & | iC | |||
) | [inline] |
Constructs a triangle through three points in positive sequence.
Definition at line 70 of file triangle_2d.inl.
References lass::prim::Triangle2D< T >::vertices_.
const Triangle2D< T >::TPoint & lass::prim::Triangle2D< T >::operator[] | ( | int | iIndexOfVertex | ) | const [inline] |
return vertex of polygon by its index, not wrapped, no bounds check.
Definition at line 82 of file triangle_2d.inl.
References lass::prim::Triangle2D< T >::isInRange(), LASS_ASSERT, and lass::prim::Triangle2D< T >::vertices_.
Triangle2D< T >::TPoint & lass::prim::Triangle2D< T >::operator[] | ( | int | iIndexOfVertex | ) | [inline] |
return vertex of polygon by its index, not wrapped, no bounds check.
Definition at line 93 of file triangle_2d.inl.
References lass::prim::Triangle2D< T >::isInRange(), LASS_ASSERT, and lass::prim::Triangle2D< T >::vertices_.
const Triangle2D< T >::TPoint & lass::prim::Triangle2D< T >::at | ( | int | iIndexOfVertex | ) | const [inline] |
return vertex of polygon by its index, but wrap around the bounds.
this->at(-1) will return the same vertex as this->at(this->size() - 1);
an | exception is thrown if polygon is empty |
Definition at line 104 of file triangle_2d.inl.
References lass::prim::Triangle2D< T >::isInRange(), LASS_ASSERT, lass::num::mod(), lass::prim::Triangle2D< T >::size_, and lass::prim::Triangle2D< T >::vertices_.
Referenced by lass::prim::Triangle2D< T >::edge(), lass::prim::Triangle2D< T >::partialVoronoiArea(), and lass::prim::Triangle2D< T >::vector().
Triangle2D< T >::TPoint & lass::prim::Triangle2D< T >::at | ( | int | iIndexOfVertex | ) | [inline] |
return vertex of polygon by its index, but wrap around the bounds.
this->at(-1) will return the same vertex as this->at(this->size() - 1);
an | exception is thrown if polygon is empty |
Definition at line 116 of file triangle_2d.inl.
References lass::prim::Triangle2D< T >::isInRange(), LASS_ASSERT, lass::num::mod(), lass::prim::Triangle2D< T >::size_, and lass::prim::Triangle2D< T >::vertices_.
const Triangle2D< T >::TLineSegment lass::prim::Triangle2D< T >::edge | ( | int | iIndexOfTailVertex | ) | const [inline] |
return the edge of the polygon between vertices at(iIndex) and at(iIndex + 1).
an | exception is thrown if polygon has less than two vertices |
Definition at line 128 of file triangle_2d.inl.
References lass::prim::Triangle2D< T >::at().
const Triangle2D< T >::TVector lass::prim::Triangle2D< T >::vector | ( | int | iIndexOfTailVertex | ) | const [inline] |
return the vector between vertices at(iIndex) and at(iIndex + 1)\
Definition at line 138 of file triangle_2d.inl.
References lass::prim::Triangle2D< T >::at().
const bool lass::prim::Triangle2D< T >::isEmpty | ( | ) | const [inline] |
return true if polygon has no vertices
Definition at line 150 of file triangle_2d.inl.
References lass::prim::Triangle2D< T >::vertices_.
const int lass::prim::Triangle2D< T >::size | ( | ) | const [inline] |
return number of vertices
Definition at line 160 of file triangle_2d.inl.
References lass::prim::Triangle2D< T >::size_.
const Triangle2D< T >::TValue lass::prim::Triangle2D< T >::signedArea | ( | ) | const [inline] |
return signed polygon area.
The area of a convex polygon is defined to be positive if the points are arranged in a counterclockwise order, and negative if they are in clockwise order., Eric W. Weisstein. "Polygon Area." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/PolygonArea.html
Definition at line 170 of file triangle_2d.inl.
References LASS_ASSERT, lass::prim::perpDot(), lass::prim::Triangle2D< T >::size_, lass::stde::T, and lass::prim::Triangle2D< T >::vertices_.
Referenced by lass::prim::Triangle2D< T >::area(), and lass::prim::Triangle2D< T >::orientation().
const Triangle2D< T >::TValue lass::prim::Triangle2D< T >::area | ( | ) | const [inline] |
return area of the polygons surface.
The area of a surface is the amount of material needed to "cover" it completely, Eric W. Weisstein. "Area." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/Area.html
Definition at line 181 of file triangle_2d.inl.
References lass::num::abs(), and lass::prim::Triangle2D< T >::signedArea().
Referenced by lass::prim::Triangle2D< T >::orientation(), and lass::prim::Triangle2D< T >::partialVoronoiArea().
const Triangle2D< T >::TValue lass::prim::Triangle2D< T >::perimeter | ( | ) | const [inline] |
return sum of the lengths of all edges
Definition at line 191 of file triangle_2d.inl.
References lass::prim::Triangle2D< T >::distance(), and lass::prim::Triangle2D< T >::vertices_.
const Triangle2D< T >::TPointH lass::prim::Triangle2D< T >::vertexCentroid | ( | ) | const [inline] |
return the barycenter of all vertices.
The vertex centroid is the homogenous sum of all vertices.
Definition at line 204 of file triangle_2d.inl.
References lass::prim::Triangle2D< T >::vertices_.
Referenced by lass::prim::Triangle2D< T >::surfaceCentroid().
const Triangle2D< T >::TPointH lass::prim::Triangle2D< T >::surfaceCentroid | ( | ) | const [inline] |
return the barycenter of all vertices.
The vertex centroid is the homogenous sum of all vertices.
Definition at line 216 of file triangle_2d.inl.
References lass::prim::Triangle2D< T >::vertexCentroid().
const bool lass::prim::Triangle2D< T >::isSimple | ( | ) | const [inline] |
return true if polygon is simple, false if not.
A polygon P is said to be simple (or Jordan) if the only points of the plane belonging to two polygon edges of P are the polygon vertices of P. Such a polygon has a well defined interior and exterior. Simple polygons are topologically equivalent to a disk., Eric W. Weisstein. "Simple Polygon." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/SimplePolygon.html
A polygon with less than four vertices is always simple.
Definition at line 228 of file triangle_2d.inl.
const bool lass::prim::Triangle2D< T >::isConvex | ( | ) | const [inline] |
return true if polygon is convex, false if not.
A planar polygon is convex if it contains all the line segments connecting any pair of its points. Thus, for example, a regular pentagon is convex, while an indented pentagon is not. A planar polygon that is not convex is said to be a concave polygon, Eric W. Weisstein. "Convex Polygon." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/ConvexPolygon.html
A simple polygon is convex if all the cross products of adjacent edges will be the same sign (we ignore zero cross products of colinear edges, only + or - are taken in account), a concave polygon will have a mixture of cross product signs.
A polygon with less than three vertices is always convex. A polygon with all coincident. vertices is considered convex if DegeneratePolicy allows this.
Definition at line 240 of file triangle_2d.inl.
const bool lass::prim::Triangle2D< T >::isConcave | ( | ) | const |
const Orientation lass::prim::Triangle2D< T >::orientation | ( | ) | const [inline] |
return orientation of polygon.
Definition at line 250 of file triangle_2d.inl.
References lass::prim::Triangle2D< T >::area(), lass::prim::oClockWise, lass::prim::oCounterClockWise, lass::prim::oInvalid, lass::prim::Triangle2D< T >::signedArea(), and lass::num::NumTraits< C >::zero.
const bool lass::prim::Triangle2D< T >::isReflex | ( | int | iIndexOfVertex | ) | const [inline] |
return true if inner angle of vertex is reflex (is > 180 degrees).
Reflect Angle: An angle more than 180°, Eric W. Weisstein. "Reflex Angle." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/ReflexAngle.html
test if signedArea() and perdDot(...) have different sign. if one of them is zero, it will return false by default.
Definition at line 274 of file triangle_2d.inl.
const Side lass::prim::Triangle2D< T >::classify | ( | const TPoint & | iP | ) | const [inline] |
Definition at line 295 of file triangle_2d.inl.
References lass::prim::Triangle2D< T >::contains(), lass::prim::sInside, and lass::prim::sOutside.
const bool lass::prim::Triangle2D< T >::contains | ( | const TPoint & | iP | ) | const [inline] |
return true when a point is inside or on the edge of a triangle.
Definition at line 284 of file triangle_2d.inl.
References lass::prim::perpDot(), lass::prim::Triangle2D< T >::vertices_, and lass::num::NumTraits< C >::zero.
Referenced by lass::prim::Triangle2D< T >::classify().
void lass::prim::Triangle2D< T >::flip | ( | ) | [inline] |
flip orientation of polygon.
Definition at line 305 of file triangle_2d.inl.
References std::swap(), and lass::prim::Triangle2D< T >::vertices_.
const bool lass::prim::Triangle2D< T >::isInRange | ( | int | iIndexOfVertex | ) | const [inline, private] |
return if index of vertex is in range of the std::vector
Definition at line 317 of file triangle_2d.inl.
References lass::prim::Triangle2D< T >::size_.
Referenced by lass::prim::Triangle2D< T >::at(), and lass::prim::Triangle2D< T >::operator[]().
Aabb2D< T > aabb | ( | const Triangle2D< T > & | triangle | ) | [related] |
determine axis aligned bounding box of a 2D triangle
Definition at line 60 of file aabb_2d_triangle_2d.h.
Result intersect | ( | const Triangle2D< T > & | triangle, | |
const Ray2D< T, NP, PP > & | ray, | |||
T & | t, | |||
const T & | tMin = T() | |||
) | [related] |
Find the intersection of a ray and a triangle by their parameter t on the ray.
A maximum of two possible intersections with t > 0.
triangle | [in] the triangle | |
ray | [in] the ray | |
t | [out] the parameter of the intersection point > tMin. | |
tMin | [in] the minimum t that may be returned as valid intersection. |
Definition at line 72 of file ray_2d_triangle_2d.h.
References lass::prim::Ray2D< T, NormalizingPolicy, ParameterPolicy >::direction(), lass::prim::impl::intersectEdge2D(), LASS_ASSERT, lass::prim::rNone, lass::prim::rOne, and lass::prim::Ray2D< T, NormalizingPolicy, ParameterPolicy >::support().
const T squaredDistance | ( | const Triangle2D< T > & | triangle, | |
const Point2D< T > & | point | |||
) | [related] |
Definition at line 329 of file triangle_2d.inl.
References lass::prim::dot(), and lass::prim::Vector2D< T >::squaredNorm().
const T distance | ( | const Triangle2D< T > & | triangle, | |
const Point2D< T > & | point | |||
) | [related] |
Definition at line 361 of file triangle_2d.inl.
References sqrt(), and lass::prim::squaredDistance().
Referenced by lass::prim::Triangle2D< T >::perimeter().
io::XmlOStream & operator<< | ( | io::XmlOStream & | ioOStream, | |
const Triangle2D< T > & | iTriangle | |||
) | [related] |
std::ostream & operator<< | ( | std::ostream & | ioOStream, | |
const Triangle2D< T > & | iTriangle | |||
) | [related] |
lass::io::MatlabOStream & operator<< | ( | lass::io::MatlabOStream & | oOStream, | |
const Triangle2D< T > & | iTriangle | |||
) | [related] |
Definition at line 397 of file triangle_2d.inl.
References lass::io::MatlabOStream::color(), and LASS_ENFORCE_STREAM.
T partialVoronoiArea | ( | const Triangle2D< T > | iT, | |
int | iIndexOfVertex | |||
) | [related] |
Returns the surface of the partial Voronoi cell constructed around vertex iIndexOfVertex (say vertex a in triangle abc). Then the surface is determined by the quad built by a, the two midpoints on ab and ac and the intersection of the two perpendicular bisectors.
Definition at line 415 of file triangle_2d.inl.
References lass::prim::Point2DH< T >::affine(), lass::prim::Triangle2D< T >::area(), lass::prim::Triangle2D< T >::at(), lass::prim::intersect(), LASS_ENFORCE, and lass::prim::rOne.
TPoint lass::prim::Triangle2D< T >::vertices_[size_] [private] |
Definition at line 125 of file triangle_2d.h.
Referenced by lass::prim::Triangle2D< T >::at(), lass::prim::Triangle2D< T >::contains(), lass::prim::Triangle2D< T >::flip(), lass::prim::Triangle2D< T >::isEmpty(), lass::prim::Triangle2D< T >::operator[](), lass::prim::Triangle2D< T >::perimeter(), lass::prim::Triangle2D< T >::signedArea(), lass::prim::Triangle2D< T >::Triangle2D(), and lass::prim::Triangle2D< T >::vertexCentroid().
Generated on Mon Nov 10 14:22:14 2008 for Library of Assembled Shared Sources by 1.5.7.1 |