library of assembled shared sources |
http://lass.cocamware.com |
#include <triangle_3d.h>
Data Structures | |
struct | Rebind |
Public Types | |
enum | { dimension = TPoint::dimension } |
typedef Triangle3D< T > | TSelf |
typedef Point3D< T > | TPoint |
typedef Point3DH< T > | TPointH |
typedef TPoint::TVector | TVector |
typedef LineSegment3D< T > | TLineSegment |
typedef Plane3D< T, Cartesian, Normalized > | TPlane |
typedef TPoint::TValue | TValue |
typedef TPoint::TParam | TParam |
typedef TPoint::TReference | TReference |
typedef TPoint::TConstReference | TConstReference |
typedef TPoint::TNumTraits | TNumTraits |
Public Member Functions | |
Triangle3D () | |
constructs an empty triangle. | |
Triangle3D (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 TPlane | plane () const |
const bool | isEmpty () const |
const int | size () const |
const TValue | squaredArea () const |
returns squared area of triangle to avoid the square root. | |
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 | isReflex (int iIndexOfVertex) const |
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 , class NP , class PP > | |
Result | intersect (const Triangle3D< T > &triangle, const Ray3D< 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 , class NP , class PP > | |
Result | intersect (const Triangle3D< T > &triangle, const Ray3D< T, NP, PP > &ray, T &u, T &v, T &t, const T &tMin=T()) |
Find the intersection of a ray and a triangle by their parameter t on the ray and it's coordinates (u,v) on the triangle. | |
template<typename T > | |
io::XmlOStream & | operator<< (io::XmlOStream &ioOStream, const Triangle3D< T > &iTriangle) |
template<typename T > | |
std::ostream & | operator<< (std::ostream &ioOStream, const Triangle3D< T > &iTriangle) |
Definition at line 63 of file triangle_3d.h.
typedef Triangle3D<T> lass::prim::Triangle3D< T >::TSelf |
Definition at line 67 of file triangle_3d.h.
typedef Point3D<T> lass::prim::Triangle3D< T >::TPoint |
Definition at line 69 of file triangle_3d.h.
typedef Point3DH<T> lass::prim::Triangle3D< T >::TPointH |
Definition at line 70 of file triangle_3d.h.
typedef TPoint::TVector lass::prim::Triangle3D< T >::TVector |
Definition at line 71 of file triangle_3d.h.
typedef LineSegment3D<T> lass::prim::Triangle3D< T >::TLineSegment |
Definition at line 72 of file triangle_3d.h.
typedef Plane3D<T, Cartesian, Normalized> lass::prim::Triangle3D< T >::TPlane |
Definition at line 73 of file triangle_3d.h.
typedef TPoint::TValue lass::prim::Triangle3D< T >::TValue |
Definition at line 75 of file triangle_3d.h.
typedef TPoint::TParam lass::prim::Triangle3D< T >::TParam |
Definition at line 76 of file triangle_3d.h.
typedef TPoint::TReference lass::prim::Triangle3D< T >::TReference |
Definition at line 77 of file triangle_3d.h.
typedef TPoint::TConstReference lass::prim::Triangle3D< T >::TConstReference |
Definition at line 78 of file triangle_3d.h.
typedef TPoint::TNumTraits lass::prim::Triangle3D< T >::TNumTraits |
Definition at line 79 of file triangle_3d.h.
anonymous enum |
anonymous enum [private] |
lass::prim::Triangle3D< T >::Triangle3D | ( | ) | [inline] |
constructs an empty triangle.
all vertices are (0, 0) and thus equal.
Definition at line 60 of file triangle_3d.inl.
lass::prim::Triangle3D< T >::Triangle3D | ( | const TPoint & | iA, | |
const TPoint & | iB, | |||
const TPoint & | iC | |||
) | [inline] |
Constructs a triangle through three points in positive sequence.
Definition at line 69 of file triangle_3d.inl.
References lass::prim::Triangle3D< T >::vertices_.
const Triangle3D< T >::TPoint & lass::prim::Triangle3D< 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_3d.inl.
References lass::prim::Triangle3D< T >::isInRange(), LASS_ASSERT, and lass::prim::Triangle3D< T >::vertices_.
Triangle3D< T >::TPoint & lass::prim::Triangle3D< T >::operator[] | ( | int | iIndexOfVertex | ) | [inline] |
return vertex of polygon by its index, not wrapped, no bounds check.
Definition at line 94 of file triangle_3d.inl.
References lass::prim::Triangle3D< T >::isInRange(), LASS_ASSERT, and lass::prim::Triangle3D< T >::vertices_.
const Triangle3D< T >::TPoint & lass::prim::Triangle3D< 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);
Definition at line 106 of file triangle_3d.inl.
References lass::prim::Triangle3D< T >::isInRange(), LASS_ASSERT, lass::num::mod(), lass::prim::Triangle3D< T >::size_, and lass::prim::Triangle3D< T >::vertices_.
Referenced by lass::prim::Triangle3D< T >::edge(), and lass::prim::Triangle3D< T >::vector().
Triangle3D< T >::TPoint & lass::prim::Triangle3D< 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);
Definition at line 119 of file triangle_3d.inl.
References lass::prim::Triangle3D< T >::isInRange(), LASS_ASSERT, lass::num::mod(), lass::prim::Triangle3D< T >::size_, and lass::prim::Triangle3D< T >::vertices_.
const Triangle3D< T >::TLineSegment lass::prim::Triangle3D< T >::edge | ( | int | iIndexOfTailVertex | ) | const [inline] |
return the edge of the polygon between vertices at(iIndex) and at(iIndex + 1).
Definition at line 132 of file triangle_3d.inl.
References lass::prim::Triangle3D< T >::at().
const Triangle3D< T >::TVector lass::prim::Triangle3D< T >::vector | ( | int | iIndexOfTailVertex | ) | const [inline] |
return the vector between vertices at(iIndex) and at(iIndex + 1)\
Definition at line 143 of file triangle_3d.inl.
References lass::prim::Triangle3D< T >::at().
const Triangle3D< T >::TPlane lass::prim::Triangle3D< T >::plane | ( | ) | const [inline] |
return support plane of polygon.
Definition at line 154 of file triangle_3d.inl.
References lass::prim::Triangle3D< T >::vertices_.
const bool lass::prim::Triangle3D< T >::isEmpty | ( | ) | const [inline] |
return true if polygon has no vertices
Definition at line 166 of file triangle_3d.inl.
References lass::prim::Triangle3D< T >::vertices_.
const int lass::prim::Triangle3D< T >::size | ( | ) | const [inline] |
return number of vertices
Definition at line 176 of file triangle_3d.inl.
References lass::prim::Triangle3D< T >::size_.
const Triangle3D< T >::TValue lass::prim::Triangle3D< T >::squaredArea | ( | ) | const [inline] |
returns squared area of triangle to avoid the square root.
Definition at line 188 of file triangle_3d.inl.
References lass::prim::cross(), LASS_ASSERT, lass::prim::Triangle3D< T >::size_, and lass::prim::Triangle3D< T >::vertices_.
Referenced by lass::prim::Triangle3D< T >::area().
const Triangle3D< T >::TValue lass::prim::Triangle3D< 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 200 of file triangle_3d.inl.
References sqrt(), and lass::prim::Triangle3D< T >::squaredArea().
const Triangle3D< T >::TValue lass::prim::Triangle3D< T >::perimeter | ( | ) | const [inline] |
return sum of the lengths of all edges
Definition at line 211 of file triangle_3d.inl.
References lass::prim::distance(), and lass::prim::Triangle3D< T >::vertices_.
const Triangle3D< T >::TPointH lass::prim::Triangle3D< T >::vertexCentroid | ( | ) | const [inline] |
return the barycenter of all vertices.
The barycenter is the homogenous sum of all vertices.
Definition at line 224 of file triangle_3d.inl.
References lass::prim::Triangle3D< T >::vertices_.
Referenced by lass::prim::Triangle3D< T >::surfaceCentroid().
const Triangle3D< T >::TPointH lass::prim::Triangle3D< T >::surfaceCentroid | ( | ) | const [inline] |
return the centroid of the filled polygon.
Eric W. Weisstein. "Geometric Centroid." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/GeometricCentroid.html
Definition at line 236 of file triangle_3d.inl.
References lass::prim::Triangle3D< T >::vertexCentroid().
const bool lass::prim::Triangle3D< 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
In 3D, we test if the 2D mapping on the major axis is simple.
Definition at line 248 of file triangle_3d.inl.
const bool lass::prim::Triangle3D< T >::isConvex | ( | ) | const [inline] |
return true if polygon is convex, false if not.
A simple polygon is convex if all the cross products of adjacent edges will be the same sign (we ignore zero signs, 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 colinear vertices is considered convex (not very usefull maybe, but convex).
Definition at line 260 of file triangle_3d.inl.
const bool lass::prim::Triangle3D< T >::isReflex | ( | int | iIndexOfVertex | ) | const [inline] |
return true if inner angle of vertex is reflex (is > 180 degrees).
Definition at line 272 of file triangle_3d.inl.
const bool lass::prim::Triangle3D< T >::isInRange | ( | int | iIndexOfVertex | ) | const [inline, private] |
return if index of vertex is in range of the std::vector
Definition at line 284 of file triangle_3d.inl.
References lass::prim::Triangle3D< T >::size_.
Referenced by lass::prim::Triangle3D< T >::at(), and lass::prim::Triangle3D< T >::operator[]().
Result intersect | ( | const Triangle3D< T > & | triangle, | |
const Ray3D< 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 76 of file ray_3d_triangle_3d.h.
References lass::prim::Ray3D< T, NormalizingPolicy, ParameterPolicy >::direction(), lass::prim::impl::intersectTriangle3D(), lass::prim::Ray3D< T, NormalizingPolicy, ParameterPolicy >::support(), and lass::stde::T.
Result intersect | ( | const Triangle3D< T > & | triangle, | |
const Ray3D< T, NP, PP > & | ray, | |||
T & | u, | |||
T & | v, | |||
T & | t, | |||
const T & | tMin = T() | |||
) | [related] |
Find the intersection of a ray and a triangle by their parameter t on the ray and it's coordinates (u,v) on the triangle.
A maximum of two possible intersections with t > 0.
triangle | [in] the triangle | |
ray | [in] the ray | |
u | [out] the parameter of the intersection point on the triangle. | |
v | [out] the parameter of the intersection point on the triangle. | |
t | [out] the parameter of the intersection point > tMin. | |
tMin | [in] the minimum t that may be returned as valid intersection. |
Definition at line 113 of file ray_3d_triangle_3d.h.
References lass::prim::Ray3D< T, NormalizingPolicy, ParameterPolicy >::direction(), lass::prim::impl::intersectTriangle3D(), and lass::prim::Ray3D< T, NormalizingPolicy, ParameterPolicy >::support().
io::XmlOStream & operator<< | ( | io::XmlOStream & | ioOStream, | |
const Triangle3D< T > & | iTriangle | |||
) | [related] |
std::ostream & operator<< | ( | std::ostream & | ioOStream, | |
const Triangle3D< T > & | iTriangle | |||
) | [related] |
TPoint lass::prim::Triangle3D< T >::vertices_[size_] [private] |
Definition at line 119 of file triangle_3d.h.
Referenced by lass::prim::Triangle3D< T >::at(), lass::prim::Triangle3D< T >::isEmpty(), lass::prim::Triangle3D< T >::operator[](), lass::prim::Triangle3D< T >::perimeter(), lass::prim::Triangle3D< T >::plane(), lass::prim::Triangle3D< T >::squaredArea(), lass::prim::Triangle3D< T >::Triangle3D(), and lass::prim::Triangle3D< T >::vertexCentroid().
Generated on Mon Nov 10 14:22:14 2008 for Library of Assembled Shared Sources by 1.5.7.1 |