library of assembled shared sources

http://lass.cocamware.com

lass::prim::Parallelogram3D< T > Class Template Reference

A very simple 3D polygon :). More...

#include <parallelogram_3d.h>

Collaboration diagram for lass::prim::Parallelogram3D< T >:

Collaboration graph
[legend]

Data Structures

struct  Rebind

Public Types

enum  { dimension = TPoint::dimension }
typedef Parallelogram3D< T > TSelf
typedef Point3D< T > TPoint
typedef Point3DH< T > TPointH
typedef TPoint::TVector TVector
typedef Point2D< T > TUV
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

 Parallelogram3D ()
 constructs an empty parallelogram.
 Parallelogram3D (const TPoint &iSupport, const TVector &iSizeX, const TVector &iSizeY)
 Constructs a parallelogram with a support and two sizes.
const TPointsupport () const
TPointsupport ()
const TVectorsizeU () const
TVectorsizeU ()
const TVectorsizeV () const
TVectorsizeV ()
const TPlane plane () const
const TValue squaredArea () const
 returns squared area of parallelogram to avoid the square root.
const TValue area () const
const TValue perimeter () const
const TPoint point (TParam iU, TParam iV) const
const TPoint point (const TUV &iUV) const
const TUV uv (const TPoint &iPoint) const
const bool isSimple () const
const bool isConvex () const
const bool isReflex (int iIndexOfVertex) const

Private Attributes

TPoint support_
TVector sizeU_
TVector sizeV_

Related Functions

(Note that these are not member functions.)

template<typename T >
io::XmlOStreamoperator<< (io::XmlOStream &ioOStream, const Parallelogram3D< T > &iParallelogram)
template<typename T >
std::ostream & operator<< (std::ostream &ioOStream, const Parallelogram3D< T > &iParallelogram)
template<typename T , class NP , class PP >
Result intersect (const Parallelogram3D< T > &parallelogram, const Ray3D< T, NP, PP > &ray, T &u, T &v, T &t, const T &tMin=T())
 Find the intersection of a ray and a parallelogram by their parameter t on the ray and it's coordinates (u,v) on the parallelogram.
template<typename T , class NP , class PP >
Result intersect (const Parallelogram3D< T > &parallelogram, const Ray3D< T, NP, PP > &ray, T &t, const T &tMin=T())
 Find the intersection of a ray and a parallelogram by their parameter t on the ray.

Detailed Description

template<typename T>
class lass::prim::Parallelogram3D< T >

A very simple 3D polygon :).

Author:
Bram de Greve [BdG]

Definition at line 63 of file parallelogram_3d.h.


Member Typedef Documentation

template<typename T >
typedef Parallelogram3D<T> lass::prim::Parallelogram3D< T >::TSelf

Definition at line 67 of file parallelogram_3d.h.

template<typename T >
typedef Point3D<T> lass::prim::Parallelogram3D< T >::TPoint

Definition at line 69 of file parallelogram_3d.h.

template<typename T >
typedef Point3DH<T> lass::prim::Parallelogram3D< T >::TPointH

Definition at line 70 of file parallelogram_3d.h.

template<typename T >
typedef TPoint::TVector lass::prim::Parallelogram3D< T >::TVector

Definition at line 71 of file parallelogram_3d.h.

template<typename T >
typedef Point2D<T> lass::prim::Parallelogram3D< T >::TUV

Definition at line 72 of file parallelogram_3d.h.

template<typename T >
typedef Plane3D<T, Cartesian, Normalized> lass::prim::Parallelogram3D< T >::TPlane

Definition at line 73 of file parallelogram_3d.h.

template<typename T >
typedef TPoint::TValue lass::prim::Parallelogram3D< T >::TValue

Definition at line 75 of file parallelogram_3d.h.

template<typename T >
typedef TPoint::TParam lass::prim::Parallelogram3D< T >::TParam

Definition at line 76 of file parallelogram_3d.h.

template<typename T >
typedef TPoint::TReference lass::prim::Parallelogram3D< T >::TReference

Definition at line 77 of file parallelogram_3d.h.

Definition at line 78 of file parallelogram_3d.h.

template<typename T >
typedef TPoint::TNumTraits lass::prim::Parallelogram3D< T >::TNumTraits

Definition at line 79 of file parallelogram_3d.h.


Member Enumeration Documentation

template<typename T >
anonymous enum

Enumerator:
dimension 

Definition at line 81 of file parallelogram_3d.h.


Constructor & Destructor Documentation

template<typename T >
lass::prim::Parallelogram3D< T >::Parallelogram3D (  )  [inline]

constructs an empty parallelogram.

support is origin and sizes are zero.

Definition at line 61 of file parallelogram_3d.inl.

template<typename T >
lass::prim::Parallelogram3D< T >::Parallelogram3D ( const TPoint iSupport,
const TVector iSizeX,
const TVector iSizeY 
) [inline]

Constructs a parallelogram with a support and two sizes.

Definition at line 70 of file parallelogram_3d.inl.


Member Function Documentation

template<typename T >
const Parallelogram3D< T >::TPoint & lass::prim::Parallelogram3D< T >::support (  )  const [inline]

template<typename T >
Parallelogram3D< T >::TPoint & lass::prim::Parallelogram3D< T >::support (  )  [inline]

Definition at line 91 of file parallelogram_3d.inl.

References lass::prim::Parallelogram3D< T >::support_.

template<typename T >
const Parallelogram3D< T >::TVector & lass::prim::Parallelogram3D< T >::sizeU (  )  const [inline]

template<typename T >
Parallelogram3D< T >::TVector & lass::prim::Parallelogram3D< T >::sizeU (  )  [inline]

Definition at line 109 of file parallelogram_3d.inl.

References lass::prim::Parallelogram3D< T >::sizeU_.

template<typename T >
const Parallelogram3D< T >::TVector & lass::prim::Parallelogram3D< T >::sizeV (  )  const [inline]

template<typename T >
Parallelogram3D< T >::TVector & lass::prim::Parallelogram3D< T >::sizeV (  )  [inline]

Definition at line 127 of file parallelogram_3d.inl.

References lass::prim::Parallelogram3D< T >::sizeV_.

template<typename T >
const Parallelogram3D< T >::TPlane lass::prim::Parallelogram3D< T >::plane (  )  const [inline]

template<typename T >
const Parallelogram3D< T >::TValue lass::prim::Parallelogram3D< T >::squaredArea (  )  const [inline]

returns squared area of parallelogram to avoid the square root.

Returns:
num::sqr(area()) but faster :)

Definition at line 148 of file parallelogram_3d.inl.

References lass::prim::cross(), lass::prim::Parallelogram3D< T >::sizeU_, and lass::prim::Parallelogram3D< T >::sizeV_.

Referenced by lass::prim::Parallelogram3D< T >::area().

template<typename T >
const Parallelogram3D< T >::TValue lass::prim::Parallelogram3D< 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 159 of file parallelogram_3d.inl.

References sqrt(), and lass::prim::Parallelogram3D< T >::squaredArea().

template<typename T >
const Parallelogram3D< T >::TValue lass::prim::Parallelogram3D< T >::perimeter (  )  const [inline]

return sum of the lengths of all edges

Definition at line 170 of file parallelogram_3d.inl.

References lass::prim::Vector3D< T >::norm(), lass::prim::Parallelogram3D< T >::sizeU_, and lass::prim::Parallelogram3D< T >::sizeV_.

template<typename T >
const Parallelogram3D< T >::TPoint lass::prim::Parallelogram3D< T >::point ( TParam  iU,
TParam  iV 
) const [inline]

template<typename T >
const Parallelogram3D< T >::TPoint lass::prim::Parallelogram3D< T >::point ( const TUV iUV  )  const [inline]

template<typename T >
const Parallelogram3D< T >::TUV lass::prim::Parallelogram3D< T >::uv ( const TPoint iPoint  )  const [inline]

template<typename T >
const bool lass::prim::Parallelogram3D< 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.

Warning:
this is a brute force test. we simple test for all edges if they are not intersecting Hence, this is O(n^2).
Parallelogram specific:
A parallelogram is always simple

Definition at line 213 of file parallelogram_3d.inl.

template<typename T >
const bool lass::prim::Parallelogram3D< T >::isConvex (  )  const [inline]

return true if polygon is convex, false if not.

Warning:
assumes polygon is simple
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 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).

Parallelogram specific:
A parallelogram is always convex

Definition at line 225 of file parallelogram_3d.inl.

template<typename T >
const bool lass::prim::Parallelogram3D< T >::isReflex ( int  iIndexOfVertex  )  const [inline]

return true if inner angle of vertex is reflex (is > 180 degrees).

Warning:
assumes polygon is simple
Parallelogram specific:
A parallelogram never has reflex vertices

Definition at line 237 of file parallelogram_3d.inl.


Friends And Related Function Documentation

template<typename T >
io::XmlOStream & operator<< ( io::XmlOStream ioOStream,
const Parallelogram3D< T > &  iParallelogram 
) [related]

Definition at line 253 of file parallelogram_3d.inl.

References LASS_ENFORCE_STREAM.

template<typename T >
std::ostream & operator<< ( std::ostream &  ioOStream,
const Parallelogram3D< T > &  iParallelogram 
) [related]

Definition at line 268 of file parallelogram_3d.inl.

References LASS_ENFORCE_STREAM.

template<typename T , class NP , class PP >
Result intersect ( const Parallelogram3D< T > &  parallelogram,
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 parallelogram by their parameter t on the ray and it's coordinates (u,v) on the parallelogram.

A maximum of two possible intersections with t > 0.

Parameters:
parallelogram [in] the parallelogram
ray [in] the ray
oU [out] the parameter of the intersection point on the parallelogram.
oV [out] the parameter of the intersection point on the parallelogram.
t [out] the parameter of the intersection point > tMin.
tMin [in] the minimum t that may be returned as valid intersection.
Returns:
  • rNone: no intersections with t > tMin found. t is not assigned.
  • rOne: a intersection with t > tMin is found. t is assigned.
Algorithm, based on ray/triangle intersection from:

Definition at line 79 of file parallelogram_3d_ray_3d.h.

References lass::prim::cross(), lass::prim::Ray3D< T, NormalizingPolicy, ParameterPolicy >::direction(), lass::prim::dot(), lass::num::inv(), lass::prim::rNone, lass::prim::rOne, lass::prim::Parallelogram3D< T >::sizeU(), lass::prim::Parallelogram3D< T >::sizeV(), lass::prim::Parallelogram3D< T >::support(), and lass::prim::Ray3D< T, NormalizingPolicy, ParameterPolicy >::support().

template<typename T , class NP , class PP >
Result intersect ( const Parallelogram3D< T > &  parallelogram,
const Ray3D< T, NP, PP > &  ray,
T &  t,
const T &  tMin = T() 
) [related]

Find the intersection of a ray and a parallelogram by their parameter t on the ray.

A maximum of two possible intersections with t > 0.

Parameters:
parallelogram [in] the parallelogram
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.
Returns:
  • rNone no intersections with t > tMin found t is not assigned.
  • rOne a intersection with t > tMin is found t is assigned.

Definition at line 141 of file parallelogram_3d_ray_3d.h.

References lass::prim::intersect(), and lass::stde::T.


Field Documentation

template<typename T >
TPoint lass::prim::Parallelogram3D< T >::support_ [private]

template<typename T >
TVector lass::prim::Parallelogram3D< T >::sizeU_ [private]

template<typename T >
TVector lass::prim::Parallelogram3D< T >::sizeV_ [private]


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

Generated on Mon Nov 10 14:22:13 2008 for Library of Assembled Shared Sources by doxygen 1.5.7.1
SourceForge.net Logo