Header file containing functions that compute the analytical solution of the signed distance function (SDF) for a 3D sphere and a 2D disk of defined radius on a grid. More...
#include <iostream>
#include "Vector/vector_dist.hpp"
#include "Grid/grid_dist_id.hpp"
Go to the source code of this file.
Functions | |
template<typename point_type , typename space_type > | |
space_type | get_analytic_sdf_sphere (point_type coords, space_type radius, space_type center_x=0, space_type center_y=0, space_type center_z=0) |
Computes the analytical signed distance function of a sphere for a given point in space. More... | |
template<size_t SDF_exact, typename grid_type , typename space_type > | |
void | init_analytic_sdf_sphere (grid_type &grid, space_type radius, space_type center_x=0, space_type center_y=0, space_type center_z=0) |
Initializes the exact solution of the signed distance function of a sphere on an OpenFPM grid. More... | |
template<typename point_type , typename space_type > | |
space_type | get_analytic_sdf_circle (point_type coords, space_type radius, space_type center_x=0, space_type center_y=0) |
Computes the analytical signed distance function of a circle for a given point in space. More... | |
template<size_t SDF_exact, typename grid_type , typename space_type > | |
void | init_analytic_sdf_circle (grid_type &grid, space_type radius, space_type center_x=0, space_type center_y=0) |
Initializes the exact solution of the signed distance function of a circle on an OpenFPM grid. More... | |
Header file containing functions that compute the analytical solution of the signed distance function (SDF) for a 3D sphere and a 2D disk of defined radius on a grid.
Definition in file AnalyticalSDF.hpp.
space_type get_analytic_sdf_circle | ( | point_type | coords, |
space_type | radius, | ||
space_type | center_x = 0 , |
||
space_type | center_y = 0 |
||
) |
Computes the analytical signed distance function of a circle for a given point in space.
At the center of the circle, φ_SDF_analytic = Radius. Moving outwards from the center on, the value for the SDF decreases steadily, eventually becomes 0 at the circle surface and negative beyond the surface. The analytic SDF for a circle of radius R and center (a, b, c) is thus:
\[ \phi_{SDF}(x, y, z) = R - \sqrt{((x-a)^2 + (y-b)^2 + (z-c)^2)} \]
point_type | Template type of OpenFPM Point<dimension, type>. |
space_type | Template type of radius. |
coords | Point_type coordinates of point. |
radius | Space_type radius of the sphere. |
center_x | Space_type x-coordinate of sphere center. |
center_y | Space_type y-coordinate of sphere center. |
center_z | Space_type z-coordinate of sphere center. |
Definition at line 116 of file AnalyticalSDF.hpp.
space_type get_analytic_sdf_sphere | ( | point_type | coords, |
space_type | radius, | ||
space_type | center_x = 0 , |
||
space_type | center_y = 0 , |
||
space_type | center_z = 0 |
||
) |
Computes the analytical signed distance function of a sphere for a given point in space.
At the center of the sphere, φ_SDF_analytic = Radius. Moving outwards from the center on, the value for the SDF decreases steadily, eventually becomes 0 at the sphere surface and negative beyond the surface. The analytic SDF for a sphere of radius R and center (a, b, c) is thus:
\[ \phi_{SDF}(x, y, z) = R - \sqrt{((x-a)^2 + (y-b)^2 + (z-c)^2)} \]
point_type | Template type of OpenFPM Point<dimension, type>. |
space_type | Template type of radius. |
coords | Point_type coordinates of point. |
radius | Space_type radius of the sphere. |
center_x | Space_type x-coordinate of sphere center. |
center_y | Space_type y-coordinate of sphere center. |
center_z | Space_type z-coordinate of sphere center. |
Definition at line 46 of file AnalyticalSDF.hpp.
void init_analytic_sdf_circle | ( | grid_type & | grid, |
space_type | radius, | ||
space_type | center_x = 0 , |
||
space_type | center_y = 0 |
||
) |
Initializes the exact solution of the signed distance function of a circle on an OpenFPM grid.
Solves the exact SDF for each grid nodes and writes the solution to a given property.
SDF_exact | Index of property where the anaytical solution for the SDF should be written to. |
grid_type | Template type of the input grid. |
space_type | Template type of radius and center coordinates. |
grid | Input OpenFPM grid. |
radius | Radius of the filled circle. |
center_x | X-coordinate of the circle center. |
center_y | Y-coordinate of the circle center. |
Definition at line 144 of file AnalyticalSDF.hpp.
void init_analytic_sdf_sphere | ( | grid_type & | grid, |
space_type | radius, | ||
space_type | center_x = 0 , |
||
space_type | center_y = 0 , |
||
space_type | center_z = 0 |
||
) |
Initializes the exact solution of the signed distance function of a sphere on an OpenFPM grid.
Solves the exact SDF for each grid nodes and writes the solution to a given property.
SDF_exact | Index of property where the anaytical solution for the SDF should be written to. |
grid_type | Template type of the input grid. |
space_type | Template type of radius the sphere is supposed to have. |
grid | Input OpenFPM grid. |
radius | Radius of the filled sphere. |
center_x | Space_type x-coordinate of sphere center. |
center_y | Space_type y-coordinate of sphere center. |
center_z | Space_type z-coordinate of sphere center. |
Definition at line 77 of file AnalyticalSDF.hpp.