Reference documentation for deal.II version 8.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Static Public Member Functions | Related Functions | List of all members
Point< dim, Number > Class Template Reference

#include <point.h>

Inheritance diagram for Point< dim, Number >:
[legend]

Public Member Functions

 Point ()
 
 Point (const bool initialize)
 
 Point (const Tensor< 1, dim, Number > &)
 
 Point (const Number x)
 
 Point (const Number x, const Number y)
 
 Point (const Number x, const Number y, const Number z)
 
Number operator() (const unsigned int index) const
 
Number & operator() (const unsigned int index)
 
Point< dim, Number > operator+ (const Tensor< 1, dim, Number > &) const
 
Point< dim, Number > operator- (const Tensor< 1, dim, Number > &) const
 
Point< dim, Number > operator- () const
 
Point< dim, Number > operator* (const Number) const
 
Number operator* (const Tensor< 1, dim, Number > &) const
 
Point< dim, Number > operator/ (const Number) const
 
Number square () const
 
Number distance (const Point< dim, Number > &p) const
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 
- Public Member Functions inherited from Tensor< 1, dim, Number >
 Tensor (const bool initialize=true)
 
 Tensor (const array_type &initializer)
 
 Tensor (const Tensor< 1, dim, Number > &)
 
Number operator[] (const unsigned int index) const
 
Number & operator[] (const unsigned int index)
 
Number operator[] (const TableIndices< 1 > &indices) const
 
Number & operator[] (const TableIndices< 1 > &indices)
 
Tensor< 1, dim, Number > & operator= (const Tensor< 1, dim, Number > &)
 
Tensor< 1, dim, Number > & operator= (const Number d)
 
bool operator== (const Tensor< 1, dim, Number > &) const
 
bool operator!= (const Tensor< 1, dim, Number > &) const
 
Tensor< 1, dim, Number > & operator+= (const Tensor< 1, dim, Number > &)
 
Tensor< 1, dim, Number > & operator-= (const Tensor< 1, dim, Number > &)
 
Tensor< 1, dim, Number > & operator*= (const Number factor)
 
Tensor< 1, dim, Number > & operator/= (const Number factor)
 
Number operator* (const Tensor< 1, dim, Number > &) const
 
Tensor< 1, dim, Number > operator+ (const Tensor< 1, dim, Number > &) const
 
Tensor< 1, dim, Number > operator- (const Tensor< 1, dim, Number > &) const
 
Tensor< 1, dim, Number > operator- () const
 
real_type norm () const
 
real_type norm_square () const
 
void clear ()
 
template<typename Number2 >
void unroll (Vector< Number2 > &result) const
 
 DeclException1 (ExcDimTooSmall, int,<< "dim must be positive, but was "<< arg1)
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Static Public Member Functions

static Point< dim, Number > unit_vector (const unsigned int i)
 
- Static Public Member Functions inherited from Tensor< 1, dim, Number >
static unsigned int component_to_unrolled_index (const TableIndices< 1 > &indices)
 
static TableIndices< 1 > unrolled_to_component_indices (const unsigned int i)
 
static std::size_t memory_consumption ()
 

Related Functions

(Note that these are not member functions.)

template<int dim, typename Number >
Point< dim, Number > operator* (const Number factor, const Point< dim, Number > &p)
 
template<int dim>
Point< dim, doubleoperator* (const double factor, const Point< dim, double > &p)
 
template<int dim, typename Number >
std::ostream & operator<< (std::ostream &out, const Point< dim, Number > &p)
 
template<int dim, typename Number >
std::istream & operator>> (std::istream &in, Point< dim, Number > &p)
 

Additional Inherited Members

- Public Types inherited from Tensor< 1, dim, Number >
typedef Number value_type
 
typedef numbers::NumberTraits
< Number >::real_type 
real_type
 
typedef Number array_type [(dim!=0)?dim:100000000]
 
- Static Public Attributes inherited from Tensor< 1, dim, Number >
static const unsigned int dimension = dim
 
static const unsigned int rank = 1
 
static const unsigned int n_independent_components = dim
 

Detailed Description

template<int dim, typename Number = double>
class Point< dim, Number >

The Point class provides for a point or vector in a space with arbitrary dimension dim.

It is the preferred object to be passed to functions which operate on points in spaces of a priori unknown dimension: rather than using functions like double f(double x) and double f(double x, double y), you use double f(Point<dim> &p).

Point also serves as a starting point for the implementation of the geometrical primitives like cells, edges, or faces.

Within deal.II, we use the Point class mainly to denote the points that make up geometric objects. As such, they have a small number of additional operations over general tensors of rank 1 for which we use the Tensor<1,dim> class. In particular, there is a distance() function to compute the Euclidian distance between two points in space.

The Point class is really only used where the coordinates of an object can be thought to possess the dimension of a length. For all other uses, such as the gradient of a scalar function (which is a tensor of rank 1, or vector, with as many elements as a point object, but with different physical units), we use the Tensor<1,dim> class.

Author
Wolfgang Bangerth, 1997

Definition at line 44 of file tensor_base.h.

Constructor & Destructor Documentation

template<int dim, typename Number = double>
Point< dim, Number >::Point ( )

Standard constructor. Creates an object that corresponds to the origin, i.e., all coordinates are set to zero.

template<int dim, typename Number = double>
Point< dim, Number >::Point ( const bool  initialize)
explicit

Constructor. Initialize all entries to zero if initialize==true (in which case it is equivalent to the default constructor) or leaves the elements uninitialized if initialize==false.

template<int dim, typename Number = double>
Point< dim, Number >::Point ( const Tensor< 1, dim, Number > &  )

Convert a tensor to a point.

template<int dim, typename Number = double>
Point< dim, Number >::Point ( const Number  x)
explicit

Constructor for one dimensional points. This function is only implemented for dim==1 since the usage is considered unsafe for points with dim!=1 as it would leave some components of the point coordinates uninitialized.

template<int dim, typename Number = double>
Point< dim, Number >::Point ( const Number  x,
const Number  y 
)

Constructor for two dimensional points. This function is only implemented for dim==2 since the usage is considered unsafe for points with dim!=2 as it would leave some components of the point coordinates uninitialized (if dim>2) or would not use some arguments (if dim<2).

template<int dim, typename Number = double>
Point< dim, Number >::Point ( const Number  x,
const Number  y,
const Number  z 
)

Constructor for three dimensional points. This function is only implemented for dim==3 since the usage is considered unsafe for points with dim!=3 as it would leave some components of the point coordinates uninitialized (if dim>3) or would not use some arguments (if dim<3).

Member Function Documentation

template<int dim, typename Number = double>
static Point<dim,Number> Point< dim, Number >::unit_vector ( const unsigned int  i)
static

Return a unit vector in coordinate direction i.

template<int dim, typename Number = double>
Number Point< dim, Number >::operator() ( const unsigned int  index) const

Read access to the indexth coordinate.

template<int dim, typename Number = double>
Number& Point< dim, Number >::operator() ( const unsigned int  index)

Read and write access to the indexth coordinate.

template<int dim, typename Number = double>
Point<dim,Number> Point< dim, Number >::operator+ ( const Tensor< 1, dim, Number > &  ) const

Add two point vectors. If possible, use operator += instead since this does not need to copy a point at least once.

template<int dim, typename Number = double>
Point<dim,Number> Point< dim, Number >::operator- ( const Tensor< 1, dim, Number > &  ) const

Subtract two point vectors. If possible, use operator += instead since this does not need to copy a point at least once.

template<int dim, typename Number = double>
Point<dim,Number> Point< dim, Number >::operator- ( ) const

The opposite vector.

template<int dim, typename Number = double>
Point<dim,Number> Point< dim, Number >::operator* ( const Number  ) const

Multiply by a factor. If possible, use operator *= instead since this does not need to copy a point at least once.

There is a commutative complement to this function also

template<int dim, typename Number = double>
Number Point< dim, Number >::operator* ( const Tensor< 1, dim, Number > &  ) const

Returns the scalar product of two vectors.

template<int dim, typename Number = double>
Point<dim,Number> Point< dim, Number >::operator/ ( const Number  ) const

Divide by a factor. If possible, use operator /= instead since this does not need to copy a point at least once.

template<int dim, typename Number = double>
Number Point< dim, Number >::square ( ) const

Returns the scalar product of this point vector with itself, i.e. the square, or the square of the norm.

template<int dim, typename Number = double>
Number Point< dim, Number >::distance ( const Point< dim, Number > &  p) const

Returns the Euclidian distance of this point to the point p, i.e. the l_2 norm of the difference between the vectors representing the two points.

template<int dim, typename Number = double>
template<class Archive >
void Point< dim, Number >::serialize ( Archive &  ar,
const unsigned int  version 
)

Read or write the data of this object to or from a stream for the purpose of serialization

Friends And Related Function Documentation

template<int dim, typename Number >
Point< dim, Number > operator* ( const Number  factor,
const Point< dim, Number > &  p 
)
related

Global operator scaling a point vector by a scalar.

Definition at line 432 of file point.h.

template<int dim>
Point< dim, double > operator* ( const double  factor,
const Point< dim, double > &  p 
)
related

Global operator scaling a point vector by a scalar.

Definition at line 446 of file point.h.

template<int dim, typename Number >
std::ostream & operator<< ( std::ostream &  out,
const Point< dim, Number > &  p 
)
related

Output operator for points. Print the elements consecutively, with a space in between.

Definition at line 461 of file point.h.

template<int dim, typename Number >
std::istream & operator>> ( std::istream &  in,
Point< dim, Number > &  p 
)
related

Output operator for points. Print the elements consecutively, with a space in between.

Definition at line 480 of file point.h.


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