Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
Public Member Functions | Static Public Member Functions | Related Functions | List of all members
Point< dim, Number > Class Template Reference

#include <deal.II/base/point.h>

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

Public Member Functions

 Point ()
 
 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)
 
template<std::size_t dummy_dim, typename std::enable_if<(dim==dummy_dim) &&(dummy_dim !=0), int >::type = 0>
 Point (const boost::geometry::model::point< Number, dummy_dim, boost::geometry::cs::cartesian > &boost_pt)
 
Number operator() (const unsigned int index) const
 
Number & operator() (const unsigned int index)
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 
Addition and subtraction of points.
Point< dim, Number > operator+ (const Tensor< 1, dim, Number > &) const
 
Tensor< 1, dim, Number > operator- (const Point< dim, Number > &) const
 
Point< dim, Number > operator- (const Tensor< 1, dim, Number > &) const
 
Point< dim, Number > operator- () const
 
- Public Member Functions inherited from Tensor< 1, dim, Number >
constexpr Tensor ()=default
 
 Tensor (const array_type &initializer)
 
 Tensor (const Tensor< rank_, dim, OtherNumber > &initializer)
 
 Tensor (const Tensor< 1, dim, Tensor< rank_ - 1, dim, OtherNumber >> &initializer)
 
constexpr operator Tensor< 1, dim, Tensor< rank_ - 1, dim, OtherNumber >> () const
 
value_typeoperator[] (const unsigned int i)
 
constexpr const value_typeoperator[] (const unsigned int i) const
 
const Number & operator[] (const TableIndices< rank_ > &indices) const
 
Number & operator[] (const TableIndices< rank_ > &indices)
 
Number * begin_raw ()
 
constexpr const Number * begin_raw () const
 
Number * end_raw ()
 
constexpr const Number * end_raw () const
 
Tensoroperator= (const Tensor< rank_, dim, OtherNumber > &rhs)
 
Tensoroperator= (const Number &d)
 
bool operator== (const Tensor< rank_, dim, OtherNumber > &) const
 
constexpr bool operator!= (const Tensor< rank_, dim, OtherNumber > &) const
 
Tensoroperator+= (const Tensor< rank_, dim, OtherNumber > &)
 
Tensoroperator-= (const Tensor< rank_, dim, OtherNumber > &)
 
Tensoroperator*= (const OtherNumber &factor)
 
Tensoroperator/= (const OtherNumber &factor)
 
Tensor operator- () const
 
void clear ()
 
numbers::NumberTraits< Number >::real_type norm () const
 
numbers::NumberTraits< Number >::real_type norm_square () const
 
void unroll (Vector< OtherNumber > &result) const
 
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< rank_ > &indices)
 
static TableIndices< rank_ > unrolled_to_component_indices (const unsigned int i)
 
static constexpr std::size_t memory_consumption ()
 

Related Functions

(Note that these are not member functions.)

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)
 

Multiplication and scaling of points. Dot products. Norms.

template<typename OtherNumber >
Point< dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator/ (const OtherNumber) const
 
Number operator* (const Tensor< 1, dim, Number > &p) const
 
numbers::NumberTraits< Number >::real_type square () const
 
numbers::NumberTraits< Number >::real_type distance (const Point< dim, Number > &p) const
 
numbers::NumberTraits< Number >::real_type distance_square (const Point< dim, Number > &p) const
 
template<typename OtherNumber >
Point< dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator* (const OtherNumber) const
 

Additional Inherited Members

- Public Types inherited from Tensor< 1, dim, Number >
using value_type = typename Tensor< rank_ - 1, dim, Number >::tensor_type
 
using array_type = typename Tensor< rank_ - 1, dim, Number >::array_type[(dim !=0) ? dim :1]
 
using tensor_type = Tensor< rank_, dim, Number >
 
- Static Public Attributes inherited from Tensor< 1, dim, Number >
static constexpr unsigned int dimension
 
static constexpr unsigned int rank
 
static constexpr unsigned int n_independent_components
 

Detailed Description

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

A class that represents a point in a Cartesian space of dimension dim .

Objects of this class are used to represent points (i.e., vectors anchored at the origin) of a vector space equipped with a Cartesian coordinate system. They are, among other uses, passed to functions that operate on points in spaces of a priori fixed dimension: rather than using functions like double f(const double x) and double f(const double x, const double y), you can use double f(const Point<dim> &p) instead as it allows writing dimension independent code.

deal.II specifically uses Point objects as indicating points that are represented by Cartesian coordinates, i.e., where a point in dim space dimensions is characterized by signed distances along the axes of a coordinate system spanned by dim mutually orthogonal unit vectors (called the "coordinate axes"). This choice of representing a vector makes addition and scaling of vectors particularly simple: one only has to add or multiply each coordinate value. On the other hand, adding or scaling vectors is not nearly as simple when a vector is represented in other kinds of coordinate systems (e.g., spherical coordinate systems).

What's a Point<dim> and what is a Tensor<1,dim>?

The Point class is derived from Tensor<1,dim> and consequently shares the latter's member functions and other attributes. In fact, it has relatively few additional functions itself (the most notable exception being the distance() function to compute the Euclidean distance between two points in space), and these two classes can therefore often be used interchangeably.

Nonetheless, there are semantic differences that make us use these classes in different and well-defined contexts. Within deal.II, we use the Point class to denote points in space, i.e., for vectors (rank-1 tensors) that are anchored at the origin. On the other hand, vectors that are anchored elsewhere (and consequently do not represent points in the common usage of the word) are represented by objects of type Tensor<1,dim>. In particular, this is the case for direction vectors, normal vectors, gradients, and the differences between two points (i.e., what you get when you subtract one point from another): all of these are represented by Tensor<1,dim> objects rather than Point<dim>.

Furthermore, the Point class is only used where the coordinates of an object can be thought to possess the dimension of a length. An object that represents the weight, height, and cost of an object is neither a point nor a tensor (because it lacks the transformation properties under rotation of the coordinate system) and should consequently not be represented by either of these classes. Use an array of size 3 in this case, or the std::array class. Alternatively, as in the case of vector-valued functions, you can use objects of type Vector or std::vector.

Template Parameters
dimAn integer that denotes the dimension of the space in which a point lies. This of course equals the number of coordinates that identify a point.
NumberThe data type in which the coordinates values are to be stored. This will, in almost all cases, simply be the default double, but there are cases where one may want to store coordinates in a different (and always scalar) type. An example would be an interval type that can store the value of a coordinate as well as its uncertainty. Another example would be a type that allows for Automatic Differentiation (see, for example, the Sacado type used in step-33) and thereby can generate analytic (spatial) derivatives of a function when passed a Point object whose coordinates are stored in such a type.
Author
Wolfgang Bangerth, 1997

Definition at line 110 of file point.h.

Constructor & Destructor Documentation

◆ Point() [1/6]

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.

◆ Point() [2/6]

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

Convert a tensor to a point.

◆ Point() [3/6]

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.

◆ Point() [4/6]

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).

◆ Point() [5/6]

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).

◆ Point() [6/6]

template<int dim, typename Number = double>
template<std::size_t dummy_dim, typename std::enable_if<(dim==dummy_dim) &&(dummy_dim !=0), int >::type = 0>
Point< dim, Number >::Point ( const boost::geometry::model::point< Number, dummy_dim, boost::geometry::cs::cartesian > &  boost_pt)

Convert a boost::geometry::point to a Point.

Member Function Documentation

◆ unit_vector()

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, i.e., a vector that is zero in all coordinates except for a single 1 in the ith coordinate.

◆ operator()() [1/2]

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

Read access to the indexth coordinate.

◆ operator()() [2/2]

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

Read and write access to the indexth coordinate.

◆ operator+()

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

Add an offset given as Tensor<1,dim,Number> to a point.

◆ operator-() [1/3]

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

Subtract two points, i.e., obtain the vector that connects the two. As discussed in the documentation of this class, subtracting two points results in a vector anchored at one of the two points (rather than at the origin) and, consequently, the result is returned as a Tensor<1,dim> rather than as a Point<dim>.

◆ operator-() [2/3]

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

Subtract a difference vector (represented by a Tensor<1,dim>) from the current point. This results in another point and, as discussed in the documentation of this class, the result is then naturally returned as a Point<dim> object rather than as a Tensor<1,dim>.

◆ operator-() [3/3]

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

The opposite vector.

◆ operator/()

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

Divide the current point by a factor.

◆ operator*()

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

Return the scalar product of the vectors representing two points.

◆ square()

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

Return the scalar product of this point vector with itself, i.e. the square, or the square of the norm. In case of a complex number type it is equivalent to the contraction of this point vector with a complex conjugate of itself.

Note
This function is equivalent to Tensor<rank,dim,Number>::norm_square() which returns the square of the Frobenius norm.

◆ distance()

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

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

◆ distance_square()

template<int dim, typename Number = double>
numbers::NumberTraits<Number>::real_type Point< dim, Number >::distance_square ( const Point< dim, Number > &  p) const

Return the squared Euclidean distance of this point to the point p.

◆ serialize()

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

◆ operator*()

template<int dim, typename Number = double>
template<typename OtherNumber >
Point<dim, typename ProductType<Number, typename EnableIfScalar<OtherNumber>::type>::type> operator* ( const OtherNumber  ) const
related

Multiply the current point by a factor.

◆ operator<<()

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 588 of file point.h.

◆ operator>>()

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

Input operator for points. Inputs the elements consecutively.

Definition at line 605 of file point.h.


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