Cartesian 3D point. More...
#include <cartesian.hpp>
Public Member Functions | |
PointCartesian3D () | |
Initialize point in the 3D cartesian space with coordinates (0, 0, 0). | |
PointCartesian3D (double x, double y, double z) | |
Initialize point in the 3D cartesian space with coordinates (x, y, z) as specified by the parameters. | |
PointCartesian3D (PointCartesian3D_t *initial_point, unsigned int initial_id=0) | |
Initialize point in the 3D cartesian space from a ViennaGrid point. | |
PointCartesian3D (PointCartesian3D_t &initial_point, unsigned int initial_id=-1) | |
Initialize point in the 3D cartesian space from a ViennaGrid point by copying it. | |
size_t | get_dimension () |
Get the dimension of the point. | |
const char * | get_coord_system () |
Get the name of the coordinate system. | |
double | get_coord (unsigned int index) |
Get the coordinate at given index (0 for x, 1 for y, 2 for z). | |
void | set_coord (unsigned int index, double new_value) |
Set the coordinate at given index (0 for x, 1 for y, 2 for z). | |
list | get_coord_list () |
Get coordinates as a Python list. | |
PointCartesian3D & | operator= (const PointCartesian3D &other) |
Assignment operator that copies the coordinates of the right operand to the left operand. | |
PointCartesian3D | operator+ (const PointCartesian3D &other) |
Addition operator which adds two points coordinate by coordinate. | |
PointCartesian3D | operator- (const PointCartesian3D &other) |
Subtraction operator which subtracts two points coordinate by coordinate. | |
PointCartesian3D | operator* (const double factor) |
Multiplication operator which multiplies a point and a scalar (real) number, coordinate by coordinate. | |
PointCartesian3D | operator/ (const double factor) |
Division operator which divides a point and a scalar (real) number, coordinate by coordinate. | |
PointCartesian3D | operator- () |
Unary operator which inverts the coordinates of a point. | |
PointCartesian3D_t & | get_point () |
Get ViennaGrid point. | |
unsigned int | get_id () |
Get ID of the point within the domain it is assigned to (if applicable). | |
void | set_id (unsigned int new_id) |
Set ID of the point within the domain it is assigned to. | |
PointCylindrical3D | to_cylindrical () |
Convert to cylindrical point. | |
PointSpherical3D | to_spherical () |
Convert to spherical point. | |
double | inner_prod (PointCartesian3D &other) |
Calculate the dot product of two points. | |
PointCartesian3D | cross_prod (PointCartesian3D &other) |
Calculate the cross product of two points. | |
double | norm_1 () |
Calculate the 1-norm of the point. | |
double | norm_2 () |
Calculate the 2-norm of the point. | |
double | norm_inf () |
Calculate the ∞-norm of the point. |
Cartesian 3D point.
PointCartesian3D::PointCartesian3D | ( | ) |
Initialize point in the 3D cartesian space with coordinates (0, 0, 0).
This constructor is meant to be used when the programmer creates an instance of the high-level Python point, and allocates memory in the heap for storing the point. As one would normally think, this should be paired with a destructor that frees the allocated memory. However, when we free the memory in the destructor, the program aborts and states that the program tried to perform a double-free.
PointCartesian3D::PointCartesian3D | ( | double | x, |
double | y, | ||
double | z | ||
) |
Initialize point in the 3D cartesian space with coordinates (x, y, z) as specified by the parameters.
This constructor is meant to be used when the programmer creates an instance of the high-level Python point, and allocates memory in the heap for storing the point. As one would normally think, this should be paired with a destructor that frees the allocated memory. However, when we free the memory in the destructor, the program aborts and states that the program tried to perform a double-free.
PointCartesian3D::PointCartesian3D | ( | PointCartesian3D_t * | initial_point, |
unsigned int | initial_id = 0 |
||
) |
Initialize point in the 3D cartesian space from a ViennaGrid point.
What this makes is to set the pointer to point to the ViennaGrid point and thus solves the issue caused by the fact that the ViennaGrid point was being copied, thus not being able to get references to the points stored in the domain and thus not being able to modify them.
This constructor is meant to be used by the wrapper code when the programmer tries to get a reference to a point stored in a domain (not when they want to define a point on their own!), and does not allocate memory in the heap, thus elliminating the need for the constructor to free that memory when this constructor has been used. At first, one would think that it should be distinguished in some way when the object has been instantiated using this constructor or any other constructor in order for the destructor to only free when another constructor has been called, not this one. However, we have shown that no freeing action is need at all.
PointCartesian3D::PointCartesian3D | ( | PointCartesian3D_t & | initial_point, |
unsigned int | initial_id = -1 |
||
) |
Initialize point in the 3D cartesian space from a ViennaGrid point by copying it.
This constructor is meant to be used by the wrapper code when the programmer runs an algorithm on points. Hence, it needs to allocate memory in the heap for the new ViennaGrid point.
As one would normally think, this should be paired with a destructor that frees the allocated memory. However, when we free the memory in the destructor, the program aborts and states that the program tried to perform a double-free.
PointCartesian3D PointCartesian3D::cross_prod | ( | PointCartesian3D & | other | ) |
Calculate the cross product of two points.
double PointCartesian3D::get_coord | ( | unsigned int | index | ) |
Get the coordinate at given index (0 for x, 1 for y, 2 for z).
list PointCartesian3D::get_coord_list | ( | ) |
Get coordinates as a Python list.
const char * PointCartesian3D::get_coord_system | ( | ) |
Get the name of the coordinate system.
For cartesian points, this always returns 'cartesian'.
size_t PointCartesian3D::get_dimension | ( | ) |
Get the dimension of the point.
For 3D points, this always returns 3.
unsigned int PointCartesian3D::get_id | ( | ) |
Get ID of the point within the domain it is assigned to (if applicable).
PointCartesian3D_t & PointCartesian3D::get_point | ( | ) |
Get ViennaGrid point.
double PointCartesian3D::inner_prod | ( | PointCartesian3D & | other | ) |
Calculate the dot product of two points.
double PointCartesian3D::norm_1 | ( | ) |
Calculate the 1-norm of the point.
double PointCartesian3D::norm_2 | ( | ) |
Calculate the 2-norm of the point.
double PointCartesian3D::norm_inf | ( | ) |
Calculate the ∞-norm of the point.
PointCartesian3D PointCartesian3D::operator* | ( | const double | factor | ) |
Multiplication operator which multiplies a point and a scalar (real) number, coordinate by coordinate.
PointCartesian3D PointCartesian3D::operator+ | ( | const PointCartesian3D & | other | ) |
Addition operator which adds two points coordinate by coordinate.
PointCartesian3D PointCartesian3D::operator- | ( | const PointCartesian3D & | other | ) |
Subtraction operator which subtracts two points coordinate by coordinate.
PointCartesian3D PointCartesian3D::operator- | ( | ) |
Unary operator which inverts the coordinates of a point.
PointCartesian3D PointCartesian3D::operator/ | ( | const double | factor | ) |
Division operator which divides a point and a scalar (real) number, coordinate by coordinate.
PointCartesian3D & PointCartesian3D::operator= | ( | const PointCartesian3D & | other | ) |
Assignment operator that copies the coordinates of the right operand to the left operand.
This operator cannot be wrapped to Python explicitly.
void PointCartesian3D::set_coord | ( | unsigned int | index, |
double | new_value | ||
) |
Set the coordinate at given index (0 for x, 1 for y, 2 for z).
void PointCartesian3D::set_id | ( | unsigned int | new_id | ) |
Set ID of the point within the domain it is assigned to.
PointCylindrical3D PointCartesian3D::to_cylindrical | ( | ) |
Convert to cylindrical point.
PointSpherical3D PointCartesian3D::to_spherical | ( | ) |
Convert to spherical point.