World Builder  1.1.0-pre
A geodynamic initial conditions generator
WorldBuilder::Point< dim > Class Template Reference

#include <interface.h>

Public Member Functions

 Point (CoordinateSystem coordinate_system_)
 
 Point (const std::array< double, dim > &location, CoordinateSystem coordinate_system_)
 
 Point (const Point< dim > &location, CoordinateSystem coordinate_system_)
 
 Point (const Point< dim > &location)
 
 Point (const double x, const double y, CoordinateSystem coordinate_system)
 
 Point (const double x, const double y, const double z, CoordinateSystem coordinate_system)
 
 ~Point ()=default
 
Point< dim > & operator= (const Point< dim > &point_right)
 
double operator* (const Point< dim > &point_right) const
 
Point< dim > operator* (const double scalar) const
 
Point< dim > operator/ (const double scalar) const
 
Point< dim > operator+ (const Point< dim > &point_right) const
 
Point< dim > operator- (const Point< dim > &point_right) const
 
Point< dim > & operator*= (const double scalar)
 
Point< dim > & operator/= (const double scalar)
 
Point< dim > & operator+= (const Point< dim > &point_right)
 
bool operator== (const Point< dim > &point_) const
 
Point< dim > & operator-= (const Point< dim > &point_right)
 
const double & operator[] (const size_t index) const
 
double & operator[] (const size_t index)
 
double distance (const Point< 2 > &two) const
 
double cheap_relative_distance_spherical (const Point< 2 > &two) const
 
double cheap_relative_distance_cartesian (const Point< 2 > &two) const
 
const std::array< double, dim > & get_array () const
 
CoordinateSystem get_coordinate_system () const
 
double norm () const
 
double norm_square () const
 
template<>
 Point (const double x, const double y, const CoordinateSystem coordinate_system_)
 
template<>
 Point (const double, const double, CoordinateSystem coordinate_system_)
 
template<>
 Point (const double, const double, const double, CoordinateSystem coordinate_system_)
 
template<>
 Point (const double x, const double y, const double z, CoordinateSystem coordinate_system_)
 
template<>
double norm_square () const
 
template<>
double norm_square () const
 

Private Attributes

std::array< double, dim > point
 
CoordinateSystem coordinate_system
 

Friends

std::ostream & operator<< (std::ostream &output, const Point< dim > &stream_point)
 

Detailed Description

template<unsigned int dim>
class WorldBuilder::Point< dim >

A class which stores 2d and 3d arrays of doubles (depending on the dimension), and the coordinate system which the coordinates can be used for. It also implements several operations such as the computation of the l2 norm and the dot product.

Definition at line 33 of file interface.h.

Constructor & Destructor Documentation

◆ Point() [1/10]

template<unsigned int dim>
WorldBuilder::Point< dim >::Point ( CoordinateSystem  coordinate_system_)
inline

Constructor. Constructs a Point at (0,0) in 2d or (0,0,0) in 3d with a Cartesian coordinate system.

Definition at line 119 of file point.h.

◆ Point() [2/10]

template<unsigned int dim>
WorldBuilder::Point< dim >::Point ( const std::array< double, dim > &  location,
CoordinateSystem  coordinate_system_ 
)
inline

Constructor. Constructs a Point from a std::array<double,dim> and a coordinate system.

Definition at line 130 of file point.h.

◆ Point() [3/10]

template<unsigned int dim>
WorldBuilder::Point< dim >::Point ( const Point< dim > &  location,
CoordinateSystem  coordinate_system_ 
)
inline

Constructor. Constructs a Point from an other Point and a coordinate system.

Definition at line 141 of file point.h.

◆ Point() [4/10]

template<unsigned int dim>
WorldBuilder::Point< dim >::Point ( const Point< dim > &  location)
inline

Constructor. Constructs a Point from an other Point.

Definition at line 151 of file point.h.

◆ Point() [5/10]

template<unsigned int dim>
WorldBuilder::Point< dim >::Point ( const double  x,
const double  y,
CoordinateSystem  coordinate_system 
)

Constructor. Constructs a 2d Point from two doubles and a coordinate system.

◆ Point() [6/10]

template<unsigned int dim>
WorldBuilder::Point< dim >::Point ( const double  x,
const double  y,
const double  z,
CoordinateSystem  coordinate_system 
)

Constructor. Constructs a 3d Point from three doubles and a coordinate system.

◆ ~Point()

template<unsigned int dim>
WorldBuilder::Point< dim >::~Point ( )
inlinedefault

Destructor

◆ Point() [7/10]

template<>
WorldBuilder::Point< 2 >::Point ( const double  x,
const double  y,
const CoordinateSystem  coordinate_system_ 
)

Definition at line 28 of file point.cc.

◆ Point() [8/10]

template<>
WorldBuilder::Point< 3 >::Point ( const double  ,
const double  ,
CoordinateSystem  coordinate_system_ 
)

Definition at line 35 of file point.cc.

◆ Point() [9/10]

template<>
WorldBuilder::Point< 2 >::Point ( const double  ,
const double  ,
const double  ,
CoordinateSystem  coordinate_system_ 
)

Definition at line 45 of file point.cc.

◆ Point() [10/10]

template<>
WorldBuilder::Point< 3 >::Point ( const double  x,
const double  y,
const double  z,
CoordinateSystem  coordinate_system_ 
)

Definition at line 55 of file point.cc.

Member Function Documentation

◆ cheap_relative_distance_cartesian()

template<unsigned int dim>
double WorldBuilder::Point< dim >::cheap_relative_distance_cartesian ( const Point< 2 > &  two) const
inline

Computes the cheapest relative distance between this and a given point in cartesian coordinates. The return value itself is only guartenteed to have the property that a larger value is further away. In the current implementation that means for the cartasian case the squared value is returned and for the spherical value the result of the havearsine function without asin and sqrt is returned.

Definition at line 382 of file point.h.

◆ cheap_relative_distance_spherical()

template<unsigned int dim>
double WorldBuilder::Point< dim >::cheap_relative_distance_spherical ( const Point< 2 > &  two) const
inline

Computes the cheapest relative distance between this and a given point in spherical coordinates. The return value itself is only guartenteed to have the property that a larger value is further away. In the current implementation that means for the cartasian case the squared value is returned and for the spherical value the result of the havearsine function without asin and sqrt is returned.

Definition at line 364 of file point.h.

◆ distance()

template<unsigned int dim>
double WorldBuilder::Point< dim >::distance ( const Point< 2 > &  two) const

Computes the distance between this and a given point. In spherical coordinates it returns the central angle in radians.

Definition at line 69 of file point.cc.

Here is the caller graph for this function:

◆ get_array()

template<unsigned int dim>
const std::array<double,dim>& WorldBuilder::Point< dim >::get_array ( ) const
inline

return the internal array which stores the point data.

Definition at line 393 of file point.h.

Here is the caller graph for this function:

◆ get_coordinate_system()

template<unsigned int dim>
CoordinateSystem WorldBuilder::Point< dim >::get_coordinate_system ( ) const
inline

returns the coordinate system associated with the data.

Definition at line 403 of file point.h.

Here is the caller graph for this function:

◆ norm()

template<unsigned int dim>
double WorldBuilder::Point< dim >::norm ( ) const
inline

Computes the L2 norm: sqrt(x_i * x_i + y_i * y_i + z_i * z_i) in 3d.

Definition at line 413 of file point.h.

Here is the caller graph for this function:

◆ norm_square() [1/3]

template<unsigned int dim>
double WorldBuilder::Point< dim >::norm_square ( ) const
inline

Computes the square of the norm, which is the sum of the absolute squares x_i * x_i + y_i * y_i + z_i * z_i in 3d.

Definition at line 424 of file point.h.

Here is the caller graph for this function:

◆ norm_square() [2/3]

template<>
double WorldBuilder::Point< 2 >::norm_square ( ) const
inline

Definition at line 454 of file point.h.

◆ norm_square() [3/3]

template<>
double WorldBuilder::Point< 3 >::norm_square ( ) const
inline

Definition at line 461 of file point.h.

◆ operator*() [1/2]

template<unsigned int dim>
double WorldBuilder::Point< dim >::operator* ( const Point< dim > &  point_right) const
inline

dot product

Definition at line 187 of file point.h.

◆ operator*() [2/2]

template<unsigned int dim>
Point<dim> WorldBuilder::Point< dim >::operator* ( const double  scalar) const
inline

Multiply the vector with a scalar

Definition at line 203 of file point.h.

◆ operator*=()

template<unsigned int dim>
Point<dim>& WorldBuilder::Point< dim >::operator*= ( const double  scalar)
inline

Multiply the vector with a scalar

Definition at line 263 of file point.h.

◆ operator+()

template<unsigned int dim>
Point<dim> WorldBuilder::Point< dim >::operator+ ( const Point< dim > &  point_right) const
inline

add two points

Definition at line 230 of file point.h.

◆ operator+=()

template<unsigned int dim>
Point<dim>& WorldBuilder::Point< dim >::operator+= ( const Point< dim > &  point_right)
inline

add two points

Definition at line 284 of file point.h.

◆ operator-()

template<unsigned int dim>
Point<dim> WorldBuilder::Point< dim >::operator- ( const Point< dim > &  point_right) const
inline

Subtract two points

Definition at line 246 of file point.h.

◆ operator-=()

template<unsigned int dim>
Point<dim>& WorldBuilder::Point< dim >::operator-= ( const Point< dim > &  point_right)
inline

subtract two points

Definition at line 319 of file point.h.

◆ operator/()

template<unsigned int dim>
Point<dim> WorldBuilder::Point< dim >::operator/ ( const double  scalar) const
inline

Divide the vector through a scalar

Definition at line 216 of file point.h.

◆ operator/=()

template<unsigned int dim>
Point<dim>& WorldBuilder::Point< dim >::operator/= ( const double  scalar)
inline

Divide the vector through a scalar

Definition at line 273 of file point.h.

◆ operator=()

template<unsigned int dim>
Point<dim>& WorldBuilder::Point< dim >::operator= ( const Point< dim > &  point_right)
inline

Definition at line 176 of file point.h.

◆ operator==()

template<unsigned int dim>
bool WorldBuilder::Point< dim >::operator== ( const Point< dim > &  point_) const
inline

Check if all values are the same.

Note: compares floating points with an epsilon

Definition at line 299 of file point.h.

◆ operator[]() [1/2]

template<unsigned int dim>
const double& WorldBuilder::Point< dim >::operator[] ( const size_t  index) const
inline

access index (const)

Definition at line 332 of file point.h.

◆ operator[]() [2/2]

template<unsigned int dim>
double& WorldBuilder::Point< dim >::operator[] ( const size_t  index)
inline

access index

Definition at line 342 of file point.h.

Friends And Related Function Documentation

◆ operator<<

template<unsigned int dim>
std::ostream& operator<< ( std::ostream &  output,
const Point< dim > &  stream_point 
)
friend

Outputs the values of the point to std cout separated by spaces. This does not output the coordinate system.

Definition at line 434 of file point.h.

Member Data Documentation

◆ coordinate_system

template<unsigned int dim>
CoordinateSystem WorldBuilder::Point< dim >::coordinate_system
private

Definition at line 448 of file point.h.

◆ point

template<unsigned int dim>
std::array<double,dim> WorldBuilder::Point< dim >::point
private

Definition at line 447 of file point.h.


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