library of assembled shared sources |
http://lass.cocamware.com |
#include <vector_2d.h>
Data Structures | |
struct | Rebind |
Public Types | |
enum | { dimension = 2 } |
typedef Vector2D< T > | TSelf |
typedef util::CallTraits< T > ::TValue | TValue |
typedef util::CallTraits< T > ::TParam | TParam |
typedef util::CallTraits< T > ::TReference | TReference |
typedef util::CallTraits< T > ::TConstReference | TConstReference |
typedef num::NumTraits< T > | TNumTraits |
Public Member Functions | |
Vector2D () | |
Vector2D (TParam x, TParam y) | |
template<typename U > | |
Vector2D (const Vector2D< U > &other) | |
template<typename U > | |
Vector2D (const U &x, const U &y) | |
Vector2D::TConstReference | operator[] (size_t index) const |
Vector2D::TReference | operator[] (size_t index) |
Vector2D::TConstReference | at (signed index) const |
Wrap index around range. | |
Vector2D::TReference | at (signed index) |
Wrap index around range. | |
const Vector2D< T > & | operator+ () const |
A weird way to get back the same object. | |
const Vector2D< T > | operator- () const |
Vector2D< T > & | operator+= (const Vector2D< T > &other) |
componentwise addition | |
Vector2D< T > & | operator-= (const Vector2D< T > &other) |
componentwise subtraction | |
Vector2D< T > & | operator*= (const Vector2D< T > &other) |
Componentwise multiplication. | |
Vector2D< T > & | operator/= (const Vector2D< T > &other) |
Componentwise division. | |
Vector2D< T > & | operator+= (TParam other) |
add other to each component of this. | |
Vector2D< T > & | operator-= (TParam other) |
subtract other of each component of this. | |
Vector2D< T > & | operator*= (TParam other) |
multiply each component of this with other. | |
Vector2D< T > & | operator/= (TParam other) |
divide each component of this by other. | |
const bool | isZero () const |
Return true if all the components are (exactly!) zero. | |
const bool | isNaN () const |
Return true if at least one of the components is NaN. | |
const TValue | squaredNorm () const |
Return squared norm of vector. | |
const TValue | norm () const |
Return norm of vector. | |
const Vector2D< T > | normal () const |
return a unit vector with same direction/sense as this vector. | |
const Vector2D< T > | reciprocal () const |
return the reciprocal version of this vector | |
const Vector2D< T > | perp () const |
return the vector perpendicular to this one, 90° to the left. | |
const Vector2D< T > | project (const Vector2D< T > &other) const |
Project vector on this one. | |
const Vector2D< T > | reject (const Vector2D< T > &other) const |
Project vector on this one. | |
const Vector2D< T > | reflect (const Vector2D< T > &other) const |
const Vector2D< T > | transform (T(*iOperator)(T)) const |
apply a function to every component | |
void | normalize () |
Normalize vector. | |
Static Public Member Functions | |
template<class RandomGenerator > | |
static Vector2D< T > | random (RandomGenerator &generator) |
Random unit vector. | |
Data Fields | |
TValue | x |
TValue | y |
Related Functions | |
(Note that these are not member functions.) | |
template<typename T > | |
Vector2D< T >::TValue | dot (const Vector2D< T > &a, const Vector2D< T > &b) |
dot product. | |
template<typename T > | |
Vector2D< T >::TValue | cos (const Vector2D< T > &a, const Vector2D< T > &b) |
returns cosine of angle between both vectors. | |
template<typename T > | |
Vector2D< T >::TValue | perpDot (const Vector2D< T > &a, const Vector2D< T > &b) |
perp dot product (cross product for 2D vectors). | |
template<typename T > | |
bool | operator== (const Vector2D< T > &a, const Vector2D< T > &b) |
template<typename T > | |
bool | operator!= (const Vector2D< T > &a, const Vector2D< T > &b) |
template<typename T > | |
Vector2D< T > | operator+ (const Vector2D< T > &a, const Vector2D< T > &b) |
componentwise addition | |
template<typename T > | |
Vector2D< T > | operator- (const Vector2D< T > &a, const Vector2D< T > &b) |
componentwise subtraction | |
template<typename T > | |
Vector2D< T > | operator* (const Vector2D< T > &a, const Vector2D< T > &b) |
Componentwise multiplication. | |
template<typename T > | |
Vector2D< T > | operator/ (const Vector2D< T > &a, const Vector2D< T > &b) |
Componentwise division. | |
template<typename T > | |
Vector2D< T > | operator+ (const Vector2D< T > &a, typename Vector2D< T >::TParam b) |
add b to all components of a. | |
template<typename T > | |
Vector2D< T > | operator- (const Vector2D< T > &a, typename Vector2D< T >::TParam b) |
subtract b of all components of a. | |
template<typename T > | |
Vector2D< T > | operator* (const Vector2D< T > &a, typename Vector2D< T >::TParam b) |
muliply all components of a by b | |
template<typename T > | |
Vector2D< T > | operator/ (const Vector2D< T > &a, typename Vector2D< T >::TParam b) |
divide all components of a by b | |
template<typename T > | |
Vector2D< T > | operator+ (typename Vector2D< T >::TParam a, const Vector2D< T > &b) |
add a to all components of b | |
template<typename T > | |
Vector2D< T > | operator- (typename Vector2D< T >::TParam a, const Vector2D< T > &b) |
subtract a of all components of b | |
template<typename T > | |
Vector2D< T > | operator* (typename Vector2D< T >::TParam a, const Vector2D< T > &b) |
multiply all components of b with a | |
template<typename T > | |
Vector2D< T > | pointwiseMin (const Vector2D< T > &a, const Vector2D< T > &b) |
return a vector with, for each coordinate, the minimum value of a and b | |
template<typename T > | |
Vector2D< T > | pointwiseMax (const Vector2D< T > &a, const Vector2D< T > &b) |
return a vector with, for each coordinate, the maximum value of a and b | |
template<typename T > | |
Vector2D< T > | lerp (const Vector2D< T > &a, const Vector2D< T > &b, typename Vector2D< T >::TParam t) |
interpolate linearly between two vectors: a + t * (b - a) | |
template<typename T , typename Char , typename Traits > | |
std::basic_ostream< Char, Traits > & | operator<< (std::basic_ostream< Char, Traits > &stream, const Vector2D< T > &b) |
template<typename T , typename Char , typename Traits > | |
std::basic_istream< Char, Traits > & | operator>> (std::basic_istream< Char, Traits > &stream, Vector2D< T > &b) |
template<typename T > | |
io::XmlOStream & | operator<< (io::XmlOStream &stream, const Vector2D< T > &b) |
Definition at line 71 of file vector_2d.h.
typedef Vector2D<T> lass::prim::Vector2D< T >::TSelf |
Definition at line 73 of file vector_2d.h.
typedef util::CallTraits<T>::TValue lass::prim::Vector2D< T >::TValue |
Definition at line 75 of file vector_2d.h.
typedef util::CallTraits<T>::TParam lass::prim::Vector2D< T >::TParam |
Definition at line 76 of file vector_2d.h.
typedef util::CallTraits<T>::TReference lass::prim::Vector2D< T >::TReference |
Definition at line 77 of file vector_2d.h.
typedef util::CallTraits<T>::TConstReference lass::prim::Vector2D< T >::TConstReference |
Definition at line 78 of file vector_2d.h.
typedef num::NumTraits<T> lass::prim::Vector2D< T >::TNumTraits |
Definition at line 79 of file vector_2d.h.
anonymous enum |
lass::prim::Vector2D< T >::Vector2D | ( | ) | [inline] |
lass::prim::Vector2D< T >::Vector2D | ( | TParam | x, | |
TParam | y | |||
) | [inline] |
Definition at line 71 of file vector_2d.inl.
lass::prim::Vector2D< T >::Vector2D | ( | const Vector2D< U > & | other | ) | [inline, explicit] |
Definition at line 81 of file vector_2d.inl.
lass::prim::Vector2D< T >::Vector2D | ( | const U & | x, | |
const U & | y | |||
) | [inline] |
Definition at line 91 of file vector_2d.inl.
Vector2D< T >::TConstReference lass::prim::Vector2D< T >::operator[] | ( | size_t | index | ) | const [inline] |
Definition at line 100 of file vector_2d.inl.
References lass::prim::Vector2D< T >::dimension, LASS_ASSERT, and lass::prim::Vector2D< T >::x.
Vector2D< T >::TReference lass::prim::Vector2D< T >::operator[] | ( | size_t | index | ) | [inline] |
Definition at line 109 of file vector_2d.inl.
References lass::prim::Vector2D< T >::dimension, LASS_ASSERT, and lass::prim::Vector2D< T >::x.
Vector2D< T >::TConstReference lass::prim::Vector2D< T >::at | ( | signed | index | ) | const [inline] |
Wrap index around range.
Definition at line 120 of file vector_2d.inl.
References lass::prim::Vector2D< T >::dimension, lass::num::mod(), and lass::prim::Vector2D< T >::x.
Vector2D< T >::TReference lass::prim::Vector2D< T >::at | ( | signed | index | ) | [inline] |
Wrap index around range.
Definition at line 130 of file vector_2d.inl.
References lass::prim::Vector2D< T >::dimension, lass::num::mod(), and lass::prim::Vector2D< T >::x.
const Vector2D< T > & lass::prim::Vector2D< T >::operator+ | ( | ) | const [inline] |
const Vector2D< T > lass::prim::Vector2D< T >::operator- | ( | ) | const [inline] |
Definition at line 148 of file vector_2d.inl.
References lass::prim::Vector2D< T >::Vector2D(), lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.
Vector2D< T > & lass::prim::Vector2D< T >::operator+= | ( | const Vector2D< T > & | other | ) | [inline] |
componentwise addition
Definition at line 158 of file vector_2d.inl.
References lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.
Vector2D< T > & lass::prim::Vector2D< T >::operator-= | ( | const Vector2D< T > & | other | ) | [inline] |
componentwise subtraction
Definition at line 170 of file vector_2d.inl.
References lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.
Vector2D< T > & lass::prim::Vector2D< T >::operator*= | ( | const Vector2D< T > & | other | ) | [inline] |
Componentwise multiplication.
Definition at line 182 of file vector_2d.inl.
References lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.
Vector2D< T > & lass::prim::Vector2D< T >::operator/= | ( | const Vector2D< T > & | other | ) | [inline] |
Componentwise division.
Definition at line 194 of file vector_2d.inl.
References lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.
Vector2D< T > & lass::prim::Vector2D< T >::operator+= | ( | TParam | other | ) | [inline] |
add other to each component of this.
Definition at line 206 of file vector_2d.inl.
References lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.
Vector2D< T > & lass::prim::Vector2D< T >::operator-= | ( | TParam | other | ) | [inline] |
subtract other of each component of this.
Definition at line 218 of file vector_2d.inl.
References lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.
Vector2D< T > & lass::prim::Vector2D< T >::operator*= | ( | TParam | other | ) | [inline] |
multiply each component of this with other.
Definition at line 230 of file vector_2d.inl.
References lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.
Vector2D< T > & lass::prim::Vector2D< T >::operator/= | ( | TParam | other | ) | [inline] |
divide each component of this by other.
Definition at line 242 of file vector_2d.inl.
References lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.
const bool lass::prim::Vector2D< T >::isZero | ( | ) | const [inline] |
Return true if all the components are (exactly!) zero.
Definition at line 254 of file vector_2d.inl.
References lass::prim::Vector2D< T >::x, lass::prim::Vector2D< T >::y, and lass::num::NumTraits< C >::zero.
Referenced by lass::prim::Ray2D< T, NormalizingPolicy, ParameterPolicy >::isValid(), lass::prim::impl::Line2DParametric< T, NormalizingPolicy >::isValid(), lass::prim::impl::Line2DCombined< T, NormalizingPolicy >::isValid(), lass::prim::impl::Line2DCartesian< T, NormalizingPolicy >::isValid(), and lass::prim::Ray2D< T, NormalizingPolicy, ParameterPolicy >::Ray2D().
const bool lass::prim::Vector2D< T >::isNaN | ( | ) | const [inline] |
Return true if at least one of the components is NaN.
Definition at line 264 of file vector_2d.inl.
References lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.
const Vector2D< T >::TValue lass::prim::Vector2D< T >::squaredNorm | ( | ) | const [inline] |
Return squared norm of vector.
Definition at line 274 of file vector_2d.inl.
References lass::prim::Vector2D< T >::dot().
Referenced by lass::prim::Vector2D< T >::cos(), lass::prim::Point2D< T >::inCircle(), lass::prim::Vector2D< T >::norm(), lass::prim::Vector2D< T >::project(), lass::prim::Triangle2D< T >::squaredDistance(), and lass::prim::Point2D< T >::squaredDistance().
const Vector2D< T >::TValue lass::prim::Vector2D< T >::norm | ( | ) | const [inline] |
Return norm of vector.
Definition at line 284 of file vector_2d.inl.
References sqrt(), and lass::prim::Vector2D< T >::squaredNorm().
Referenced by lass::prim::Point2D< T >::distance(), lass::prim::LineSegment2D< T, ParameterPolicy >::length(), and lass::prim::Vector2D< T >::normalize().
const Vector2D< T > lass::prim::Vector2D< T >::normal | ( | ) | const [inline] |
return a unit vector with same direction/sense as this vector.
The normalized vector of X is a vector in the same direction but with norm (length) 1. It is denoted X^ and given by X^ = X / |X|, http://mathworld.wolfram.com/NormalizedVector.html.
Definition at line 298 of file vector_2d.inl.
References lass::prim::Vector2D< T >::normalize().
const Vector2D< T > lass::prim::Vector2D< T >::reciprocal | ( | ) | const [inline] |
return the reciprocal version of this vector
Definition at line 310 of file vector_2d.inl.
References lass::num::NumTraits< C >::one.
const Vector2D< T > lass::prim::Vector2D< T >::perp | ( | ) | const [inline] |
return the vector perpendicular to this one, 90° to the left.
Definition at line 322 of file vector_2d.inl.
References lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.
Referenced by lass::prim::impl::Line2DCartesian< T, NormalizingPolicy >::direction(), lass::prim::impl::Line2DParametric< T, NormalizingPolicy >::getCartesian(), and lass::prim::impl::Line2DCombined< T, NormalizingPolicy >::Line2DCombined().
const Vector2D< T > lass::prim::Vector2D< T >::project | ( | const Vector2D< T > & | other | ) | const [inline] |
Project vector on this one.
Definition at line 332 of file vector_2d.inl.
References lass::prim::Vector2D< T >::dot(), and lass::prim::Vector2D< T >::squaredNorm().
Referenced by lass::prim::Vector2D< T >::reflect(), and lass::prim::Vector2D< T >::reject().
const Vector2D< T > lass::prim::Vector2D< T >::reject | ( | const Vector2D< T > & | other | ) | const [inline] |
Project vector on this one.
Definition at line 345 of file vector_2d.inl.
References lass::prim::Vector2D< T >::project().
const Vector2D< T > lass::prim::Vector2D< T >::reflect | ( | const Vector2D< T > & | other | ) | const [inline] |
const Vector2D< T > lass::prim::Vector2D< T >::transform | ( | T(*)(T) | iOperator | ) | const [inline] |
apply a function to every component
Definition at line 363 of file vector_2d.inl.
References lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.
void lass::prim::Vector2D< T >::normalize | ( | ) | [inline] |
Normalize vector.
Definition at line 373 of file vector_2d.inl.
References lass::prim::Vector2D< T >::norm().
Referenced by lass::spat::impl::EdgeGatherer::makeRectangular(), and lass::prim::Vector2D< T >::normal().
Vector2D< T > lass::prim::Vector2D< T >::random | ( | RandomGenerator & | generator | ) | [inline, static] |
Random unit vector.
Definition at line 384 of file vector_2d.inl.
References lass::prim::Vector2D< T >::cos(), lass::num::NumTraits< C >::pi, lass::num::sin(), and lass::num::NumTraits< C >::zero.
Vector2D< T >::TValue dot | ( | const Vector2D< T > & | a, | |
const Vector2D< T > & | b | |||
) | [related] |
dot product.
Definition at line 398 of file vector_2d.inl.
References lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.
Referenced by lass::prim::Vector2D< T >::project(), and lass::prim::Vector2D< T >::squaredNorm().
Vector2D< T >::TValue cos | ( | const Vector2D< T > & | a, | |
const Vector2D< T > & | b | |||
) | [related] |
returns cosine of angle between both vectors.
Definition at line 409 of file vector_2d.inl.
References lass::prim::dot(), sqrt(), and lass::prim::Vector2D< T >::squaredNorm().
Referenced by lass::prim::Vector2D< T >::random().
Vector2D< T >::TValue perpDot | ( | const Vector2D< T > & | a, | |
const Vector2D< T > & | b | |||
) | [related] |
perp dot product (cross product for 2D vectors).
The "perp dot product" for a and b vectors in the plane is a modification of the two-dimensional dot product in which a is replaced by the perpendicular vector rotated 90° to the left defined by Hill (1994), http://mathworld.wolfram.com/PerpDotProduct.html.
It reminds a lot to the 3D cross product, as its result is equal to the z-value of the cross product of a and b extended to 3D space by setting their z-value to 0: Vector3D<T> c = cross(Vector3D<T>(a.x, a.y, 0), Vector3D<T>(b.x, b.y, 0)). We know of this that c.x and c.y are both zero, and that c.z equals the perp dot product between a and b.
Definition at line 429 of file vector_2d.inl.
References lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.
bool operator== | ( | const Vector2D< T > & | a, | |
const Vector2D< T > & | b | |||
) | [related] |
Definition at line 439 of file vector_2d.inl.
References lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.
bool operator!= | ( | const Vector2D< T > & | a, | |
const Vector2D< T > & | b | |||
) | [related] |
Definition at line 449 of file vector_2d.inl.
Vector2D< T > pointwiseMin | ( | const Vector2D< T > & | a, | |
const Vector2D< T > & | b | |||
) | [related] |
return a vector with, for each coordinate, the minimum value of a and b
Definition at line 603 of file vector_2d.inl.
References lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.
Vector2D< T > pointwiseMax | ( | const Vector2D< T > & | a, | |
const Vector2D< T > & | b | |||
) | [related] |
return a vector with, for each coordinate, the maximum value of a and b
Definition at line 614 of file vector_2d.inl.
References lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.
Vector2D< T > lerp | ( | const Vector2D< T > & | a, | |
const Vector2D< T > & | b, | |||
typename Vector2D< T >::TParam | t | |||
) | [related] |
interpolate linearly between two vectors: a + t * (b - a)
Definition at line 625 of file vector_2d.inl.
std::basic_ostream< Char, Traits > & operator<< | ( | std::basic_ostream< Char, Traits > & | stream, | |
const Vector2D< T > & | b | |||
) | [related] |
Definition at line 639 of file vector_2d.inl.
References LASS_ENFORCE_STREAM, lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.
std::basic_istream< Char, Traits > & operator>> | ( | std::basic_istream< Char, Traits > & | stream, | |
Vector2D< T > & | b | |||
) | [related] |
Definition at line 652 of file vector_2d.inl.
References lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.
io::XmlOStream & operator<< | ( | io::XmlOStream & | stream, | |
const Vector2D< T > & | b | |||
) | [related] |
TValue lass::prim::Vector2D< T >::x |
Definition at line 91 of file vector_2d.h.
Referenced by lass::prim::Aabb2D< T, MinMaxPolicy >::area(), lass::prim::Vector2D< T >::at(), lass::prim::Aabb2D< T, MinMaxPolicy >::collides(), lass::prim::SimplePolygon2D< T, DegeneratePolicy >::contains(), lass::prim::Vector2D< T >::dot(), lass::spat::impl::fastIntersect(), lass::prim::TriangleMesh3D< T, BoundingVolumeHierarchy, SplitHeuristics >::Triangle::intersect(), lass::prim::Aabb2D< T, MinMaxPolicy >::intersects(), lass::prim::Vector2D< T >::isNaN(), lass::prim::Vector2D< T >::isZero(), lass::prim::Transformation2D< T >::normalTransform(), lass::prim::Vector2D< T >::operator*=(), lass::prim::Vector2D< T >::operator+=(), lass::prim::Point2D< T >::operator+=(), lass::prim::Vector2D< T >::operator-(), lass::prim::Vector2D< T >::operator-=(), lass::prim::Point2D< T >::operator-=(), lass::prim::Vector2D< T >::operator/=(), lass::prim::Vector2D< T >::operator<<(), lass::prim::Vector2D< T >::operator==(), lass::prim::Vector2D< T >::operator>>(), lass::prim::Vector2D< T >::operator[](), lass::prim::Aabb2D< T, MinMaxPolicy >::perimeter(), lass::prim::Vector2D< T >::perp(), lass::prim::Vector2D< T >::perpDot(), lass::prim::Vector2D< T >::pointwiseMax(), lass::prim::Vector2D< T >::pointwiseMin(), lass::prim::Transformation2D< T >::scaler(), lass::prim::Vector2D< T >::transform(), lass::prim::Transformation2D< T >::transform(), and lass::prim::Transformation2D< T >::translation().
TValue lass::prim::Vector2D< T >::y |
Definition at line 92 of file vector_2d.h.
Referenced by lass::prim::Aabb2D< T, MinMaxPolicy >::area(), lass::prim::Aabb2D< T, MinMaxPolicy >::collides(), lass::prim::SimplePolygon2D< T, DegeneratePolicy >::contains(), lass::prim::Vector2D< T >::dot(), lass::spat::impl::fastIntersect(), lass::prim::TriangleMesh3D< T, BoundingVolumeHierarchy, SplitHeuristics >::Triangle::intersect(), lass::prim::Aabb2D< T, MinMaxPolicy >::intersects(), lass::prim::Vector2D< T >::isNaN(), lass::prim::Vector2D< T >::isZero(), lass::prim::Transformation2D< T >::normalTransform(), lass::prim::Vector2D< T >::operator*=(), lass::prim::Vector2D< T >::operator+=(), lass::prim::Point2D< T >::operator+=(), lass::prim::Vector2D< T >::operator-(), lass::prim::Vector2D< T >::operator-=(), lass::prim::Point2D< T >::operator-=(), lass::prim::Vector2D< T >::operator/=(), lass::prim::Vector2D< T >::operator<<(), lass::prim::Vector2D< T >::operator==(), lass::prim::Vector2D< T >::operator>>(), lass::prim::Aabb2D< T, MinMaxPolicy >::perimeter(), lass::prim::Vector2D< T >::perp(), lass::prim::Vector2D< T >::perpDot(), lass::prim::Vector2D< T >::pointwiseMax(), lass::prim::Vector2D< T >::pointwiseMin(), lass::prim::Transformation2D< T >::scaler(), lass::prim::Vector2D< T >::transform(), lass::prim::Transformation2D< T >::transform(), and lass::prim::Transformation2D< T >::translation().
Generated on Mon Nov 10 14:22:14 2008 for Library of Assembled Shared Sources by 1.5.7.1 |