Public Member Functions | Private Attributes | Related Functions | List of all members
vgl_homg_point_3d< Type > Class Template Reference

Represents a homogeneous 3D point. More...

#include <vgl_fwd.h>

Public Member Functions

 vgl_homg_point_3d ()
 Default constructor with (0,0,0,1). More...
 
 vgl_homg_point_3d (Type px, Type py, Type pz, Type pw=(Type) 1)
 Construct from three (nonhomogeneous) or four (homogeneous) Types. More...
 
 vgl_homg_point_3d (const Type v[4])
 Construct from homogeneous 4-array. More...
 
 vgl_homg_point_3d (vgl_vector_3d< Type >const &v)
 Construct point at infinity from direction vector. More...
 
 vgl_homg_point_3d (vgl_point_3d< Type > const &p)
 Construct from (non-homogeneous) vgl_point_3d<Type>. More...
 
 vgl_homg_point_3d (vgl_homg_plane_3d< Type > const &l1, vgl_homg_plane_3d< Type > const &l2, vgl_homg_plane_3d< Type > const &l3)
 Construct from 3 planes (intersection). More...
 
bool operator== (vgl_homg_point_3d< Type > const &other) const
 the comparison operator. More...
 
bool operator!= (vgl_homg_point_3d< Type >const &other) const
 
Type x () const
 
Type y () const
 
Type z () const
 
Type w () const
 
void set (Type px, Type py, Type pz, Type pw=(Type) 1)
 Set x,y,z,w. More...
 
void set (Type const p[4])
 
bool ideal (Type tol=(Type) 0) const
 Return true iff the point is at infinity (an ideal point). More...
 
bool get_nonhomogeneous (double &vx, double &vy, double &vz) const
 
bool rescale_w (Type new_w=Type(1))
 

Private Attributes

Type x_
 
Type y_
 
Type z_
 
Type w_
 

Related Functions

(Note that these are not member functions.)

template<class T >
vgl_homg_point_3d< T > vgl_closest_point_origin (vgl_homg_plane_3d< T > const &pl)
 Return the point on the given plane closest to the origin. More...
 
template<class T >
vgl_homg_point_3d< T > vgl_closest_point_origin (vgl_homg_line_3d_2_points< T > const &l)
 Return the point on the given line closest to the origin. More...
 
template<class T >
vgl_homg_point_3d< T > vgl_closest_point (vgl_homg_line_3d_2_points< T > const &l, vgl_homg_point_3d< T > const &p)
 Return the point on the given line which is closest to the given point. More...
 
template<class T >
double vgl_distance (vgl_homg_point_3d< T >const &p1, vgl_homg_point_3d< T >const &p2)
 return the distance between two points. More...
 
template<class Type >
bool collinear (l const &l1, vgl_homg_point_3d< Type > const &p)
 Does a line pass through a point, i.e., are the point and the line collinear?. More...
 
template<class Type >
bool coplanar (l const &l1, vgl_homg_point_3d< Type > const &p1, vgl_homg_point_3d< Type > const &p2)
 Are two points coplanar with a line?. More...
 
template<class Type >
std::ostream & operator<< (std::ostream &s, vgl_homg_point_3d< Type > const &p)
 Write "<vgl_homg_point_3d (x,y,z,w) >" to stream. More...
 
template<class Type >
std::istream & operator>> (std::istream &s, vgl_homg_point_3d< Type > &p)
 Read x y z w from stream. More...
 
template<class Type >
bool is_ideal (vgl_homg_point_3d< Type > const &p, Type tol=(Type) 0)
 Return true iff the point is at infinity (an ideal point). More...
 
template<class Type >
bool coplanar (vgl_homg_point_3d< Type > const &p1, vgl_homg_point_3d< Type > const &p2, vgl_homg_point_3d< Type > const &p3, vgl_homg_point_3d< Type > const &p4)
 Return true iff the 4 points are coplanar, i.e., they belong to a common plane. More...
 
template<class Type >
vgl_vector_3d< Type > operator- (vgl_homg_point_3d< Type > const &p1, vgl_homg_point_3d< Type > const &p2)
 The difference of two points is the vector from second to first point. More...
 
template<class Type >
vgl_homg_point_3d< Type > operator+ (vgl_homg_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. More...
 
template<class Type >
vgl_homg_point_3d< Type > & operator+= (vgl_homg_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. More...
 
template<class Type >
vgl_homg_point_3d< Type > operator- (vgl_homg_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. More...
 
template<class Type >
vgl_homg_point_3d< Type > & operator-= (vgl_homg_point_3d< Type > &p, vgl_vector_3d< Type > const &v)
 Subtracting a vector from a point is the same as adding the inverse vector. More...
 
template<class T >
double cross_ratio (vgl_homg_point_3d< T >const &p1, vgl_homg_point_3d< T >const &p2, vgl_homg_point_3d< T >const &p3, vgl_homg_point_3d< T >const &p4)
 cross ratio of four collinear points. More...
 
template<class Type >
bool collinear (vgl_homg_point_3d< Type > const &p1, vgl_homg_point_3d< Type > const &p2, vgl_homg_point_3d< Type > const &p3)
 Are three points collinear, i.e., do they lie on a common line?. More...
 
template<class Type >
double ratio (vgl_homg_point_3d< Type > const &p1, vgl_homg_point_3d< Type > const &p2, vgl_homg_point_3d< Type > const &p3)
 Return the relative distance to p1 wrt p1-p2 of p3. More...
 
template<class Type >
vgl_homg_point_3d< Type > midpoint (vgl_homg_point_3d< Type > const &p1, vgl_homg_point_3d< Type > const &p2, Type f=(Type) 0.5)
 Return the point at a given ratio wrt two other points. More...
 
template<class Type >
vgl_homg_point_3d< Type > centre (vgl_homg_point_3d< Type > const &p1, vgl_homg_point_3d< Type > const &p2)
 Return the point at the centre of gravity of two given points. More...
 
template<class Type >
vgl_homg_point_3d< Type > centre (std::vector< vgl_homg_point_3d< Type > > const &v)
 Return the point at the centre of gravity of a set of given points. More...
 

Detailed Description

template<class Type>
class vgl_homg_point_3d< Type >

Represents a homogeneous 3D point.

Definition at line 9 of file vgl_fwd.h.

Constructor & Destructor Documentation

◆ vgl_homg_point_3d() [1/6]

template<class Type>
vgl_homg_point_3d< Type >::vgl_homg_point_3d ( )
inline

Default constructor with (0,0,0,1).

Definition at line 42 of file vgl_homg_point_3d.h.

◆ vgl_homg_point_3d() [2/6]

template<class Type>
vgl_homg_point_3d< Type >::vgl_homg_point_3d ( Type  px,
Type  py,
Type  pz,
Type  pw = (Type)1 
)
inline

Construct from three (nonhomogeneous) or four (homogeneous) Types.

Definition at line 45 of file vgl_homg_point_3d.h.

◆ vgl_homg_point_3d() [3/6]

template<class Type>
vgl_homg_point_3d< Type >::vgl_homg_point_3d ( const Type  v[4])
inline

Construct from homogeneous 4-array.

Definition at line 49 of file vgl_homg_point_3d.h.

◆ vgl_homg_point_3d() [4/6]

template<class Type>
vgl_homg_point_3d< Type >::vgl_homg_point_3d ( vgl_vector_3d< Type >const &  v)
inline

Construct point at infinity from direction vector.

Definition at line 52 of file vgl_homg_point_3d.h.

◆ vgl_homg_point_3d() [5/6]

template<class Type>
vgl_homg_point_3d< Type >::vgl_homg_point_3d ( vgl_point_3d< Type > const &  p)
inlineexplicit

Construct from (non-homogeneous) vgl_point_3d<Type>.

Definition at line 55 of file vgl_homg_point_3d.h.

◆ vgl_homg_point_3d() [6/6]

template<class Type >
vgl_homg_point_3d< Type >::vgl_homg_point_3d ( vgl_homg_plane_3d< Type > const &  l1,
vgl_homg_plane_3d< Type > const &  l2,
vgl_homg_plane_3d< Type > const &  l3 
)

Construct from 3 planes (intersection).

Definition at line 14 of file vgl_homg_point_3d.hxx.

Member Function Documentation

◆ get_nonhomogeneous()

template<class Type>
bool vgl_homg_point_3d< Type >::get_nonhomogeneous ( double &  vx,
double &  vy,
double &  vz 
) const
inline

Definition at line 108 of file vgl_homg_point_3d.h.

◆ ideal()

template<class Type>
bool vgl_homg_point_3d< Type >::ideal ( Type  tol = (Type)0) const
inline

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

The method checks whether |w| <= tol * max(|x|,|y|,|z|)

Definition at line 99 of file vgl_homg_point_3d.h.

◆ operator!=()

template<class Type>
bool vgl_homg_point_3d< Type >::operator!= ( vgl_homg_point_3d< Type >const &  other) const
inline

Definition at line 81 of file vgl_homg_point_3d.h.

◆ operator==()

template<class Type >
bool vgl_homg_point_3d< Type >::operator== ( vgl_homg_point_3d< Type > const &  other) const

the comparison operator.

Definition at line 29 of file vgl_homg_point_3d.hxx.

◆ rescale_w()

template<class Type>
bool vgl_homg_point_3d< Type >::rescale_w ( Type  new_w = Type(1))
inline

Definition at line 127 of file vgl_homg_point_3d.h.

◆ set() [1/2]

template<class Type>
void vgl_homg_point_3d< Type >::set ( Type  px,
Type  py,
Type  pz,
Type  pw = (Type)1 
)
inline

Set x,y,z,w.

Note that it does not make sense to set x, y, z or w individually.

Definition at line 92 of file vgl_homg_point_3d.h.

◆ set() [2/2]

template<class Type>
void vgl_homg_point_3d< Type >::set ( Type const  p[4])
inline

Definition at line 95 of file vgl_homg_point_3d.h.

◆ w()

template<class Type>
Type vgl_homg_point_3d< Type >::w ( ) const
inline

Definition at line 88 of file vgl_homg_point_3d.h.

◆ x()

template<class Type>
Type vgl_homg_point_3d< Type >::x ( ) const
inline

Definition at line 85 of file vgl_homg_point_3d.h.

◆ y()

template<class Type>
Type vgl_homg_point_3d< Type >::y ( ) const
inline

Definition at line 86 of file vgl_homg_point_3d.h.

◆ z()

template<class Type>
Type vgl_homg_point_3d< Type >::z ( ) const
inline

Definition at line 87 of file vgl_homg_point_3d.h.

Friends And Related Function Documentation

◆ centre() [1/2]

template<class Type >
vgl_homg_point_3d< Type > centre ( vgl_homg_point_3d< Type > const &  p1,
vgl_homg_point_3d< Type > const &  p2 
)
related

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

Identical to midpoint(p1,p2). Invalid when both points are at infinity. If only one point is at infinity, that point is returned. inline

Definition at line 297 of file vgl_homg_point_3d.h.

◆ centre() [2/2]

template<class Type >
vgl_homg_point_3d< Type > centre ( std::vector< vgl_homg_point_3d< Type > > const &  v)
related

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

There are no rounding errors when Type is e.g. int, if all w() are 1.

Definition at line 310 of file vgl_homg_point_3d.h.

◆ collinear() [1/2]

template<class Type >
bool collinear ( l const &  l1,
vgl_homg_point_3d< Type > const &  p 
)
related

Does a line pass through a point, i.e., are the point and the line collinear?.

Definition at line 100 of file vgl_homg_line_3d_2_points.h.

◆ collinear() [2/2]

template<class Type >
bool collinear ( vgl_homg_point_3d< Type > const &  p1,
vgl_homg_point_3d< Type > const &  p2,
vgl_homg_point_3d< Type > const &  p3 
)
related

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

◆ coplanar() [1/2]

template<class Type >
bool coplanar ( l const &  l1,
vgl_homg_point_3d< Type > const &  p1,
vgl_homg_point_3d< Type > const &  p2 
)
related

Are two points coplanar with a line?.

Definition at line 118 of file vgl_homg_line_3d_2_points.h.

◆ coplanar() [2/2]

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

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

Definition at line 164 of file vgl_homg_point_3d.h.

◆ cross_ratio()

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

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.

◆ is_ideal()

template<class Type >
bool is_ideal ( vgl_homg_point_3d< Type > const &  p,
Type  tol = (Type)0 
)
related

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

The method checks whether |w| <= tol * max(|x|,|y|,|z|)

Definition at line 159 of file vgl_homg_point_3d.h.

◆ midpoint()

template<class Type >
vgl_homg_point_3d< Type > midpoint ( vgl_homg_point_3d< Type > const &  p1,
vgl_homg_point_3d< Type > const &  p2,
Type  f = (Type)0.5 
)
related

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_homg_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 285 of file vgl_homg_point_3d.h.

◆ operator+()

template<class Type >
vgl_homg_point_3d< Type > operator+ ( vgl_homg_point_3d< Type > const &  p,
vgl_vector_3d< Type > const &  v 
)
related

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

If the point is at infinity, nothing happens. Note that vector + point is not defined! It's always point + vector.

Definition at line 201 of file vgl_homg_point_3d.h.

◆ operator+=()

template<class Type >
vgl_homg_point_3d< Type > & operator+= ( vgl_homg_point_3d< Type > &  p,
vgl_vector_3d< Type > const &  v 
)
related

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

If the point is at infinity, nothing happens.

Definition at line 213 of file vgl_homg_point_3d.h.

◆ operator-() [1/2]

template<class Type >
vgl_vector_3d< Type > operator- ( vgl_homg_point_3d< Type > const &  p1,
vgl_homg_point_3d< Type > const &  p2 
)
related

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

This function is only valid if the points are not at infinity.

Definition at line 187 of file vgl_homg_point_3d.h.

◆ operator-() [2/2]

template<class Type >
vgl_homg_point_3d< Type > operator- ( vgl_homg_point_3d< Type > const &  p,
vgl_vector_3d< Type > const &  v 
)
related

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

Definition at line 222 of file vgl_homg_point_3d.h.

◆ operator-=()

template<class Type >
vgl_homg_point_3d< Type > & operator-= ( vgl_homg_point_3d< Type > &  p,
vgl_vector_3d< Type > const &  v 
)
related

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

Definition at line 229 of file vgl_homg_point_3d.h.

◆ operator<<()

template<class Type >
std::ostream & operator<< ( std::ostream &  s,
vgl_homg_point_3d< Type > const &  p 
)
related

Write "<vgl_homg_point_3d (x,y,z,w) >" to stream.

◆ operator>>()

template<class Type >
std::istream & operator>> ( std::istream &  s,
vgl_homg_point_3d< Type > &  p 
)
related

Read x y z w from stream.

◆ ratio()

template<class Type >
double ratio ( vgl_homg_point_3d< Type > const &  p1,
vgl_homg_point_3d< Type > const &  p2,
vgl_homg_point_3d< Type > const &  p3 
)
related

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 273 of file vgl_homg_point_3d.h.

◆ vgl_closest_point()

template<class T >
vgl_homg_point_3d< T > vgl_closest_point ( vgl_homg_line_3d_2_points< T > const &  l,
vgl_homg_point_3d< T > const &  p 
)
related

Return the point on the given line which is closest to the given point.

If the given point is at infinity, the point at infinity of the line is returned.

◆ vgl_closest_point_origin() [1/2]

template<class T >
vgl_homg_point_3d< T > vgl_closest_point_origin ( vgl_homg_plane_3d< T > const &  pl)
related

Return the point on the given plane closest to the origin.

◆ vgl_closest_point_origin() [2/2]

template<class T >
vgl_homg_point_3d< T > vgl_closest_point_origin ( vgl_homg_line_3d_2_points< T > const &  l)
related

Return the point on the given line closest to the origin.

◆ vgl_distance()

template<class T >
double vgl_distance ( vgl_homg_point_3d< T >const &  p1,
vgl_homg_point_3d< T >const &  p2 
)
related

return the distance between two points.

Definition at line 128 of file vgl_distance.h.

Member Data Documentation

◆ w_

template<class Type>
Type vgl_homg_point_3d< Type >::w_
private

Definition at line 35 of file vgl_homg_point_3d.h.

◆ x_

template<class Type>
Type vgl_homg_point_3d< Type >::x_
private

Definition at line 32 of file vgl_homg_point_3d.h.

◆ y_

template<class Type>
Type vgl_homg_point_3d< Type >::y_
private

Definition at line 33 of file vgl_homg_point_3d.h.

◆ z_

template<class Type>
Type vgl_homg_point_3d< Type >::z_
private

Definition at line 34 of file vgl_homg_point_3d.h.


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