DOLFIN
DOLFIN C++ interface
Public Member Functions | List of all members
dolfin::Point Class Reference

#include <Point.h>

Public Member Functions

 Point (const double x=0.0, const double y=0.0, const double z=0.0)
 
 Point (std::size_t dim, const double *x)
 
 Point (const Array< double > &x)
 
 Point (const Point &p)
 
 ~Point ()
 Destructor.
 
double & operator[] (std::size_t i)
 
double operator[] (std::size_t i) const
 
double x () const
 
double y () const
 
double z () const
 
double * coordinates ()
 
const double * coordinates () const
 
std::array< double, 3 > array () const
 
Point operator+ (const Point &p) const
 
Point operator- (const Point &p) const
 
const Pointoperator+= (const Point &p)
 Add given point.
 
const Pointoperator-= (const Point &p)
 Subtract given point.
 
Point operator- ()
 Unary minus.
 
Point operator* (double a) const
 Multiplication with scalar.
 
const Pointoperator*= (double a)
 Incremental multiplication with scalar.
 
Point operator/ (double a) const
 Division by scalar.
 
const Pointoperator/= (double a)
 Incremental division by scalar.
 
const Pointoperator= (const Point &p)
 Assignment operator.
 
bool operator== (const Point &p) const
 Equal to operator.
 
bool operator!= (const Point &p) const
 Not equal to operator.
 
double squared_distance (const Point &p) const
 
double distance (const Point &p) const
 
double norm () const
 
double squared_norm () const
 
const Point cross (const Point &p) const
 
double dot (const Point &p) const
 
Point rotate (const Point &a, double theta) const
 
std::string str (bool verbose=false) const
 

Detailed Description

A Point represents a point in :math:\mathbb{R}^3 with coordinates :math:x, y, z, or alternatively, a vector in :math:\mathbb{R}^3, supporting standard operations like the norm, distances, scalar and vector products etc.

Constructor & Destructor Documentation

◆ Point() [1/4]

dolfin::Point::Point ( const double  x = 0.0,
const double  y = 0.0,
const double  z = 0.0 
)
inlineexplicit

Create a point at (x, y, z). Default value (0, 0, 0).

Parameters
x(double) The x-coordinate.
y(double) The y-coordinate.
z(double) The z-coordinate.

◆ Point() [2/4]

dolfin::Point::Point ( std::size_t  dim,
const double *  x 
)
inline

Create point from array

Parameters
dim(std::size_t) Dimension of the array.
x(double) The array to create a Point from.

◆ Point() [3/4]

dolfin::Point::Point ( const Array< double > &  x)
inline

Create point from Array

Parameters
x(Array<double>) Array of coordinates.

◆ Point() [4/4]

dolfin::Point::Point ( const Point p)
inline

Copy constructor

Parameters
p(Point) The object to be copied.

Member Function Documentation

◆ array()

std::array<double, 3> dolfin::Point::array ( ) const
inline

Return copy of coordinate array

Returns list of double The coordinates.

◆ coordinates() [1/2]

double* dolfin::Point::coordinates ( )
inline

Return coordinate array

Returns
double* The coordinates.

◆ coordinates() [2/2]

const double* dolfin::Point::coordinates ( ) const
inline

Return coordinate array (const. version)

Returns
double* The coordinates.

◆ cross()

const Point Point::cross ( const Point p) const

Compute cross product with given vector

Parameters
p(Point) Another point.
Returns
Point The cross product.

◆ distance()

double dolfin::Point::distance ( const Point p) const
inline

Compute distance to given point

Parameters
p(Point) The point to compute distance to.
Returns
double The distance.
Point p1(0, 4, 0);
Point p2(2, 0, 4);
info("%g", p1.distance(p2));

◆ dot()

double Point::dot ( const Point p) const

Compute dot product with given vector

Parameters
p(Point) Another point.
Returns
double The dot product.
Point p1(1.0, 4.0, 8.0);
Point p2(2.0, 0.0, 0.0);
info("%g", p1.dot(p2));

◆ norm()

double dolfin::Point::norm ( ) const
inline

Compute norm of point representing a vector from the origin

Returns
double The (Euclidean) norm of the vector from the origin to the point.
Point p(1.0, 2.0, 2.0);
info("%g", p.norm());

◆ operator+()

Point dolfin::Point::operator+ ( const Point p) const
inline

Compute sum of two points

Parameters
p(Point)
Returns
Point

◆ operator-()

Point dolfin::Point::operator- ( const Point p) const
inline

Compute difference of two points

Parameters
p(Point)
Returns
Point

◆ operator[]() [1/2]

double& dolfin::Point::operator[] ( std::size_t  i)
inline

Return address of coordinate in direction i

Parameters
i(std::size_t) Direction.

Returns

Returns
double Address of coordinate in the given direction.

◆ operator[]() [2/2]

double dolfin::Point::operator[] ( std::size_t  i) const
inline

Return coordinate in direction i

Parameters
i(std::size_t) Direction.
Returns
double The coordinate in the given direction.

◆ rotate()

Point Point::rotate ( const Point a,
double  theta 
) const

Rotate around a given axis

Parameters
a(Point) The axis to rotate around. Must be unit length.
theta(double) The rotation angle.
Returns
Point The rotated point.

◆ squared_distance()

double Point::squared_distance ( const Point p) const

Compute squared distance to given point

Parameters
p(Point) The point to compute distance to.
Returns
double The squared distance.

◆ squared_norm()

double dolfin::Point::squared_norm ( ) const
inline

Compute norm of point representing a vector from the origin

Returns
double The squared (Euclidean) norm of the vector from the origin of the point.
Point p(1.0, 2.0, 2.0);
info("%g", p.squared_norm());

◆ str()

std::string Point::str ( bool  verbose = false) const

Return informal string representation (pretty-print)

Parameters
verbose(bool) Flag to turn on additional output.
Returns
std::string An informal representation of the function space.

◆ x()

double dolfin::Point::x ( ) const
inline

Return x-coordinate

Returns
double The x-coordinate.

◆ y()

double dolfin::Point::y ( ) const
inline

Return y-coordinate

Returns
double The y-coordinate.

◆ z()

double dolfin::Point::z ( ) const
inline

Return z-coordinate

Returns
double The z-coordinate.

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