psimpl 7
psimpl::math Namespace Reference

Contains functions for calculating statistics and distances between various geometric entities. More...

Classes

struct  Statistics
 POD structure for storing several statistical values. More...

Functions

template<unsigned DIM, class InputIterator >
bool equal (InputIterator p1, InputIterator p2)
 Determines if two points have the exact same coordinates.
template<unsigned DIM, class InputIterator , class OutputIterator >
OutputIterator make_vector (InputIterator p1, InputIterator p2, OutputIterator result)
 Creates a vector from two points.
template<unsigned DIM, class InputIterator >
std::iterator_traits
< InputIterator >::value_type 
dot (InputIterator v1, InputIterator v2)
 Computes the dot product of two vectors.
template<unsigned DIM, class InputIterator , class OutputIterator >
OutputIterator interpolate (InputIterator p1, InputIterator p2, float fraction, OutputIterator result)
 Peforms linear interpolation between two points.
template<unsigned DIM, class InputIterator1 , class InputIterator2 >
std::iterator_traits
< InputIterator1 >::value_type 
point_distance2 (InputIterator1 p1, InputIterator2 p2)
 Computes the squared distance of two points.
template<unsigned DIM, class InputIterator >
std::iterator_traits
< InputIterator >::value_type 
line_distance2 (InputIterator l1, InputIterator l2, InputIterator p)
 Computes the squared distance between an infinite line (l1, l2) and a point p.
template<unsigned DIM, class InputIterator >
std::iterator_traits
< InputIterator >::value_type 
segment_distance2 (InputIterator s1, InputIterator s2, InputIterator p)
 Computes the squared distance between a line segment (s1, s2) and a point p.
template<unsigned DIM, class InputIterator >
std::iterator_traits
< InputIterator >::value_type 
ray_distance2 (InputIterator r1, InputIterator r2, InputIterator p)
 Computes the squared distance between a ray (r1, r2) and a point p.
template<class InputIterator >
Statistics compute_statistics (InputIterator first, InputIterator last)
 Computes various statistics for the range [first, last)

Detailed Description

Contains functions for calculating statistics and distances between various geometric entities.


Function Documentation

template<class InputIterator >
Statistics psimpl::math::compute_statistics ( InputIterator  first,
InputIterator  last 
) [inline]

Computes various statistics for the range [first, last)

Parameters:
[in]firstthe first value
[in]lastone beyond the last value
Returns:
the calculated statistics
template<unsigned DIM, class InputIterator >
std::iterator_traits<InputIterator>::value_type psimpl::math::dot ( InputIterator  v1,
InputIterator  v2 
) [inline]

Computes the dot product of two vectors.

Parameters:
[in]v1the first coordinate of the first vector
[in]v2the first coordinate of the second vector
Returns:
the dot product (v1 * v2)
template<unsigned DIM, class InputIterator >
bool psimpl::math::equal ( InputIterator  p1,
InputIterator  p2 
) [inline]

Determines if two points have the exact same coordinates.

Parameters:
[in]p1the first coordinate of the first point
[in]p2the first coordinate of the second point
Returns:
true when the points are equal; false otherwise
template<unsigned DIM, class InputIterator , class OutputIterator >
OutputIterator psimpl::math::interpolate ( InputIterator  p1,
InputIterator  p2,
float  fraction,
OutputIterator  result 
) [inline]

Peforms linear interpolation between two points.

Parameters:
[in]p1the first coordinate of the first point
[in]p2the first coordinate of the second point
[in]fractionthe fraction used during interpolation
[in]resultthe interpolation result (p1 + fraction * (p2 - p1))
Returns:
one beyond the last coordinate of the interpolated point
template<unsigned DIM, class InputIterator >
std::iterator_traits<InputIterator>::value_type psimpl::math::line_distance2 ( InputIterator  l1,
InputIterator  l2,
InputIterator  p 
) [inline]

Computes the squared distance between an infinite line (l1, l2) and a point p.

Parameters:
[in]l1the first coordinate of the first point on the line
[in]l2the first coordinate of the second point on the line
[in]pthe first coordinate of the test point
Returns:
the squared distance
template<unsigned DIM, class InputIterator , class OutputIterator >
OutputIterator psimpl::math::make_vector ( InputIterator  p1,
InputIterator  p2,
OutputIterator  result 
) [inline]

Creates a vector from two points.

Parameters:
[in]p1the first coordinate of the first point
[in]p2the first coordinate of the second point
[in]resultthe resulting vector (p2-p1)
Returns:
one beyond the last coordinate of the resulting vector
template<unsigned DIM, class InputIterator1 , class InputIterator2 >
std::iterator_traits<InputIterator1>::value_type psimpl::math::point_distance2 ( InputIterator1  p1,
InputIterator2  p2 
) [inline]

Computes the squared distance of two points.

Parameters:
[in]p1the first coordinate of the first point
[in]p2the first coordinate of the second point
Returns:
the squared distance
template<unsigned DIM, class InputIterator >
std::iterator_traits<InputIterator>::value_type psimpl::math::ray_distance2 ( InputIterator  r1,
InputIterator  r2,
InputIterator  p 
) [inline]

Computes the squared distance between a ray (r1, r2) and a point p.

Parameters:
[in]r1the first coordinate of the start point of the ray
[in]r2the first coordinate of a point on the ray
[in]pthe first coordinate of the test point
Returns:
the squared distance
template<unsigned DIM, class InputIterator >
std::iterator_traits<InputIterator>::value_type psimpl::math::segment_distance2 ( InputIterator  s1,
InputIterator  s2,
InputIterator  p 
) [inline]

Computes the squared distance between a line segment (s1, s2) and a point p.

Parameters:
[in]s1the first coordinate of the start point of the segment
[in]s2the first coordinate of the end point of the segment
[in]pthe first coordinate of the test point
Returns:
the squared distance