45#ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_SIMPLE_TRIANGLE_3D_INL
46#define LASS_GUARDIAN_OF_INCLUSION_PRIM_SIMPLE_TRIANGLE_3D_INL
81const typename Triangle3D<T>::TPoint&
84 LASS_ASSERT(isInRange(iIndexOfVertex));
85 return vertices_[iIndexOfVertex];
93typename Triangle3D<T>::TPoint&
96 LASS_ASSERT(isInRange(iIndexOfVertex));
97 return vertices_[iIndexOfVertex];
105const typename Triangle3D<T>::TPoint&
108 const int i = num::mod(iIndexOfVertex,
static_cast<unsigned>(size_));
109 LASS_ASSERT(isInRange(i));
118typename Triangle3D<T>::TPoint&
121 const int i = num::mod(iIndexOfVertex,
static_cast<unsigned>(size_));
122 LASS_ASSERT(isInRange(i));
131const typename Triangle3D<T>::TLineSegment
134 return TLineSegment(
at(iIndexOfTailVertex),
at(iIndexOfTailVertex + 1));
142const typename Triangle3D<T>::TVector
145 return at(iIndexOfTailVertex + 1) -
at(iIndexOfTailVertex);
153const typename Triangle3D<T>::TPlane
156 return TPlane(vertices_[0], vertices_[1], vertices_[2]);
168 return vertices_[0] == vertices_[1] && vertices_[0] == vertices_[2];
187const typename Triangle3D<T>::TValue
190 LASS_ASSERT(size_ == 3);
191 return cross(vertices_[1] - vertices_[0], vertices_[2] - vertices_[0]).squaredNorm() / 4;
199const typename Triangle3D<T>::TValue
210const typename Triangle3D<T>::TValue
213 return distance(vertices_[0], vertices_[1]) +
214 distance(vertices_[1], vertices_[2]) +
215 distance(vertices_[2], vertices_[0]);
223const typename Triangle3D<T>::TPointH
226 TPointH result = vertices_[0] + vertices_[1] + vertices_[2];
234template <
typename T>
inline
235const typename Triangle3D<T>::TPointH
284bool Triangle3D<T>::isInRange(
size_t iIndexOfVertex)
const
286 return iIndexOfVertex < size_;
298 LASS_ENFORCE_STREAM(ioOStream) <<
"<Triangle3D>\n";
299 for (
unsigned i = 0; i < 3; ++i)
301 ioOStream <<
"<vertex id='" << i <<
"'>" << iTriangle[i] <<
"</vertex>\n";
303 ioOStream <<
"</Triangle3D>\n";
312std::ostream& operator<<(std::ostream& ioOStream,
const Triangle3D<T>& iTriangle)
314 LASS_ENFORCE_STREAM(ioOStream)
315 <<
"{" << iTriangle[0] <<
", " << iTriangle[1] <<
", " << iTriangle[2] <<
"}";
Output stream for writing a selection of geometric primitives to XML files.
A very simple 3D polygon :)
const TValue squaredArea() const
returns squared area of triangle to avoid the square root.
const TPoint & operator[](size_t iIndexOfVertex) const
return vertex of polygon by its index, not wrapped, no bounds check.
bool isEmpty() const
return true if polygon has no vertices
size_t size() const
return number of vertices
const TValue area() const
return area of the polygons surface.
bool isSimple() const
return true if polygon is simple, false if not.
const TPoint & at(int iIndexOfVertex) const
return vertex of polygon by its index, but wrap around the bounds.
const TLineSegment edge(int iIndexOfTailVertex) const
return the edge of the polygon between vertices at(iIndex) and at(iIndex + 1).
bool isReflex(int iIndexOfVertex) const
return true if inner angle of vertex is reflex (is > 180 degrees).
const TPointH vertexCentroid() const
return the barycenter of all vertices.
const TPlane plane() const
return support plane of polygon.
bool isConvex() const
return true if polygon is convex, false if not.
const TVector vector(int iIndexOfTailVertex) const
return the vector between vertices at(iIndex) and at(iIndex + 1)\
const TPointH surfaceCentroid() const
return the centroid of the filled polygon.
const TValue perimeter() const
return sum of the lengths of all edges
Triangle3D()
constructs an empty triangle.
set of geometrical primitives
Library for Assembled Shared Sources.