Classes | Defines | Functions
core/vgl/vgl_point_3d.h File Reference

a point in 3D nonhomogeneous space More...

#include <vcl_iosfwd.h>
#include <vgl/vgl_fwd.h>
#include <vgl/vgl_vector_3d.h>
#include <vcl_cassert.h>
#include <vcl_vector.h>

Go to the source code of this file.

Classes

class  vgl_point_3d< Type >
 Represents a cartesian 3D point. More...

Defines

#define VGL_POINT_3D_INSTANTIATE(T)   extern "please include vgl/vgl_point_3d.txx first"

Functions

template<class Type >
vcl_ostream & operator<< (vcl_ostream &s, vgl_point_3d< Type > const &p)
 Write "<vgl_point_3d x,y,z> " to stream.
template<class Type >
vcl_istream & operator>> (vcl_istream &s, vgl_point_3d< Type > &p)
 Read from stream, possibly with formatting.
template<class Type >
bool is_ideal (vgl_point_3d< Type > const &, Type=0)
 Return true iff the point is at infinity (an ideal point).
template<class Type >
vgl_vector_3d< Type > operator- (vgl_point_3d< Type > const &p1, vgl_point_3d< Type > const &p2)
 The difference of two points is the vector from second to first point.
template<class Type >
vgl_point_3d< Type > operator+ (vgl_point_3d< Type > const &p, vgl_vector_3d< Type > const &v)
 Adding a vector to a point gives a new point at the end of that vector.
template<class Type >
vgl_point_3d< Type > & operator+= (vgl_point_3d< Type > &p, vgl_vector_3d< Type > const &v)
 Adding a vector to a point gives the point at the end of that vector.
template<class Type >
vgl_point_3d< Type > operator- (vgl_point_3d< Type > const &p, vgl_vector_3d< Type > const &v)
 Subtracting a vector from a point is the same as adding the inverse vector.
template<class Type >
vgl_point_3d< Type > & operator-= (vgl_point_3d< Type > &p, vgl_vector_3d< Type > const &v)
 Subtracting a vector from a point is the same as adding the inverse vector.
template<class T >
double cross_ratio (vgl_point_3d< T >const &p1, vgl_point_3d< T >const &p2, vgl_point_3d< T >const &p3, vgl_point_3d< T >const &p4)
 cross ratio of four collinear points.
template<class Type >
bool collinear (vgl_point_3d< Type > const &p1, vgl_point_3d< Type > const &p2, vgl_point_3d< Type > const &p3)
 Are three points collinear, i.e., do they lie on a common line?.
template<class Type >
double ratio (vgl_point_3d< Type > const &p1, vgl_point_3d< Type > const &p2, vgl_point_3d< Type > const &p3)
 Return the relative distance to p1 wrt p1-p2 of p3.
template<class Type >
vgl_point_3d< Type > midpoint (vgl_point_3d< Type > const &p1, vgl_point_3d< Type > const &p2, Type f=(Type) 0.5)
 Return the point at a given ratio wrt two other points.
template<class Type >
vgl_point_3d< Type > centre (vgl_point_3d< Type > const &p1, vgl_point_3d< Type > const &p2)
 Return the point at the centre of gravity of two given points.
template<class Type >
vgl_point_3d< Type > centre (vgl_point_3d< Type > const &p1, vgl_point_3d< Type > const &p2, vgl_point_3d< Type > const &p3)
 Return the point at the centre of gravity of three given points.
template<class Type >
vgl_point_3d< Type > centre (vgl_point_3d< Type > const &p1, vgl_point_3d< Type > const &p2, vgl_point_3d< Type > const &p3, vgl_point_3d< Type > const &p4)
 Return the point at the centre of gravity of four given points.
template<class Type >
vgl_point_3d< Type > centre (vcl_vector< vgl_point_3d< Type > > const &v)
 Return the point at the centre of gravity of a set of given points.
template<class Type >
double stddev (vcl_vector< vgl_point_3d< Type > > const &v)
 Return the "average deviation" of a set of given points from its centre of gravity.
template<class Type >
bool coplanar (vgl_point_3d< Type > const &p1, vgl_point_3d< Type > const &p2, vgl_point_3d< Type > const &p3, vgl_point_3d< Type > const &p4)
 Return true iff the 4 points are coplanar, i.e., they belong to a common plane.

Detailed Description

a point in 3D nonhomogeneous space

Author:
Don Hamilton, Peter Tu
    Modifications
     Peter Vanroose -  2 July 2001 - Added constructor from 3 planes
     Peter Vanroose - 24 Oct. 2002 - Added coplanar()
     Peter Vanroose - 21 May  2009 - istream operator>> re-implemented
   

Definition in file vgl_point_3d.h.


Define Documentation

#define VGL_POINT_3D_INSTANTIATE (   T)    extern "please include vgl/vgl_point_3d.txx first"

Definition at line 285 of file vgl_point_3d.h.


Function Documentation

template<class Type >
vgl_point_3d< Type > centre ( vgl_point_3d< Type > const &  p1,
vgl_point_3d< Type > const &  p2 
) [inline]

Return the point at the centre of gravity of two given points.

Identical to midpoint(p1,p2).

Definition at line 224 of file vgl_point_3d.h.

template<class Type >
vgl_point_3d< Type > centre ( vgl_point_3d< Type > const &  p1,
vgl_point_3d< Type > const &  p2,
vgl_point_3d< Type > const &  p3 
) [inline]

Return the point at the centre of gravity of three given points.

Definition at line 235 of file vgl_point_3d.h.

template<class Type >
vgl_point_3d< Type > centre ( vgl_point_3d< Type > const &  p1,
vgl_point_3d< Type > const &  p2,
vgl_point_3d< Type > const &  p3,
vgl_point_3d< Type > const &  p4 
) [inline]

Return the point at the centre of gravity of four given points.

Definition at line 247 of file vgl_point_3d.h.

template<class Type >
vgl_point_3d< Type > centre ( vcl_vector< vgl_point_3d< Type > > const &  v) [inline]

Return the point at the centre of gravity of a set of given points.

Beware of possible rounding errors when Type is e.g. int.

Definition at line 261 of file vgl_point_3d.h.

template<class Type >
bool collinear ( vgl_point_3d< Type > const &  p1,
vgl_point_3d< Type > const &  p2,
vgl_point_3d< Type > const &  p3 
) [inline]

Are three points collinear, i.e., do they lie on a common line?.

Definition at line 184 of file vgl_point_3d.h.

template<class Type >
bool coplanar ( vgl_point_3d< Type > const &  p1,
vgl_point_3d< Type > const &  p2,
vgl_point_3d< Type > const &  p3,
vgl_point_3d< Type > const &  p4 
)

Return true iff the 4 points are coplanar, i.e., they belong to a common plane.

Definition at line 46 of file vgl_point_3d.txx.

template<class T >
double cross_ratio ( vgl_point_3d< T >const &  p1,
vgl_point_3d< T >const &  p2,
vgl_point_3d< T >const &  p3,
vgl_point_3d< T >const &  p4 
)

cross ratio of four collinear points.

This number is projectively invariant, and it is the coordinate of p4 in the reference frame where p2 is the origin (coordinate 0), p3 is the unity (coordinate 1) and p1 is the point at infinity. This cross ratio is often denoted as ((p1, p2; p3, p4)) (which also equals ((p3, p4; p1, p2)) or ((p2, p1; p4, p3)) or ((p4, p3; p2, p1)) ) and is calculated as

                        p1 - p3   p2 - p3      (p1-p3)(p2-p4)
                        ------- : --------  =  --------------
                        p1 - p4   p2 - p4      (p1-p4)(p2-p3)
   

If three of the given points coincide, the cross ratio is not defined.

In this implementation, a least-squares result is calculated when the points are not exactly collinear.

Definition at line 67 of file vgl_point_3d.txx.

template<class Type >
bool is_ideal ( vgl_point_3d< Type > const &  ,
Type  = 0 
) [inline]

Return true iff the point is at infinity (an ideal point).

Always returns false.

Definition at line 119 of file vgl_point_3d.h.

template<class Type >
vgl_point_3d< Type > midpoint ( vgl_point_3d< Type > const &  p1,
vgl_point_3d< Type > const &  p2,
Type  f = (Type)0.5 
) [inline]

Return the point at a given ratio wrt two other points.

By default, the mid point (ratio=0.5) is returned. Note that the third argument is Type, not double, so the midpoint of e.g. two vgl_point_3d<int> is not a valid concept. But the reflection point of p2 wrt p1 is: in that case f=-1.

Definition at line 210 of file vgl_point_3d.h.

template<class Type >
vgl_point_3d< Type > operator+ ( vgl_point_3d< Type > const &  p,
vgl_vector_3d< Type > const &  v 
) [inline]

Adding a vector to a point gives a new point at the end of that vector.

Note that vector + point is not defined! It's always point + vector.

Definition at line 132 of file vgl_point_3d.h.

template<class Type >
vgl_point_3d< Type > & operator+= ( vgl_point_3d< Type > &  p,
vgl_vector_3d< Type > const &  v 
) [inline]

Adding a vector to a point gives the point at the end of that vector.

Definition at line 139 of file vgl_point_3d.h.

template<class Type >
vgl_vector_3d< Type > operator- ( vgl_point_3d< Type > const &  p1,
vgl_point_3d< Type > const &  p2 
) [inline]

The difference of two points is the vector from second to first point.

Definition at line 124 of file vgl_point_3d.h.

template<class Type >
vgl_point_3d< Type > operator- ( vgl_point_3d< Type > const &  p,
vgl_vector_3d< Type > const &  v 
) [inline]

Subtracting a vector from a point is the same as adding the inverse vector.

Definition at line 146 of file vgl_point_3d.h.

template<class Type >
vgl_point_3d< Type > & operator-= ( vgl_point_3d< Type > &  p,
vgl_vector_3d< Type > const &  v 
) [inline]

Subtracting a vector from a point is the same as adding the inverse vector.

Definition at line 153 of file vgl_point_3d.h.

template<class Type >
vcl_ostream & operator<< ( vcl_ostream &  s,
vgl_point_3d< Type > const &  p 
)

Write "<vgl_point_3d x,y,z> " to stream.

Definition at line 83 of file vgl_point_3d.txx.

template<class Type >
vcl_istream & operator>> ( vcl_istream &  is,
vgl_point_3d< Type > &  p 
)

Read from stream, possibly with formatting.

Either just reads three blank-separated numbers, or reads three comma-separated numbers, or reads three numbers in parenthesized form "(123, 321, 567)"

Definition at line 124 of file vgl_point_3d.txx.

template<class Type >
double ratio ( vgl_point_3d< Type > const &  p1,
vgl_point_3d< Type > const &  p2,
vgl_point_3d< Type > const &  p3 
) [inline]

Return the relative distance to p1 wrt p1-p2 of p3.

The three points should be collinear and p2 should not equal p1. This is the coordinate of p3 in the affine 1D reference frame (p1,p2). If p3=p1, the ratio is 0; if p1=p3, the ratio is 1. The mid point of p1 and p2 has ratio 0.5. Note that the return type is double, not Type, since the ratio of e.g. two vgl_vector_3d<int> need not be an int.

Definition at line 198 of file vgl_point_3d.h.

template<class Type >
double stddev ( vcl_vector< vgl_point_3d< Type > > const &  v)

Return the "average deviation" of a set of given points from its centre of gravity.

"Average" in the sense of the standard deviation (2-norm, i.e., square root of sum of squares) of the distances from that centre of gravity.

Definition at line 134 of file vgl_point_3d.txx.