This module defines the signed distance function (SDF) abstract type and all types that inherit from it. The SDF abstract type defines the optical properties of an SDF (mus, mua, kappa, albedo, hgg, g2,and n), as well as a transform (4x4 matrix), and the layer ID code of the SDF. The SDF abstract type also provides an abstract interface (evaluate) which each inheriting function must implement. This evaluate function is the heart of the SDF implementation. Each individual evaluate is the direct implementation of that SDF, e.g. that function defines the mathematical SDF. For more information on SDFs, check out Inigo Quilez's website from which most of the below SDFs and transforms have been taken.
This is the module the user should import to other module not sdf_base!
Interface to box SDF initialising function
Initalising function for Box SDF.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(vector), | intent(in) | :: | lengths |
Lengths of each dimension of the box |
||
type(opticalProp_t), | intent(in) | :: | optProp |
Optical properties of the SDF |
||
integer, | intent(in) | :: | layer |
ID number of sdf |
||
real(kind=wp), | intent(in), | optional | :: | transform(4,4) |
Optional transform to apply to SDF |
Interface to capsule SDF initialising function
Initalising function for capsule SDF.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(vector), | intent(in) | :: | a |
Capsule startpoint |
||
type(vector), | intent(in) | :: | b |
Capsule endpoint |
||
real(kind=wp), | intent(in) | :: | r |
Capsule radius |
||
type(opticalProp_t), | intent(in) | :: | optProp |
Optical properties of the SDF |
||
integer, | intent(in) | :: | layer |
ID number of sdf |
||
real(kind=wp), | intent(in), | optional | :: | transform(4,4) |
Optional transform to apply to SDF |
Interface to cone SDF initialising function
Initalising function for Capped Cone SDF.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(vector), | intent(in) | :: | a |
Centre of base of Cone |
||
type(vector), | intent(in) | :: | b |
Tip of cone |
||
real(kind=wp), | intent(in) | :: | ra |
Radius of Cones base |
||
real(kind=wp), | intent(in) | :: | rb |
Radius of Cones tip. For rb = 0.0 get normal uncapped cone. |
||
type(opticalProp_t), | intent(in) | :: | optProp |
Optical properties of the SDF |
||
integer, | intent(in) | :: | layer |
ID number of sdf |
||
real(kind=wp), | intent(in), | optional | :: | transform(4,4) |
Optional transform to apply to SDF |
Interface to cylinder SDF initialising function
Initalising function for Cylinder SDF.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(vector), | intent(in) | :: | a |
Vector position at centre of the bottom circle |
||
type(vector), | intent(in) | :: | b |
Vector position at centre of the top circle |
||
real(kind=wp), | intent(in) | :: | radius |
Radius of cylinder |
||
type(opticalProp_t), | intent(in) | :: | optProp |
Optical properties of the SDF |
||
integer, | intent(in) | :: | layer |
ID number of sdf |
||
real(kind=wp), | intent(in), | optional | :: | transform(4,4) |
Optional transform to apply to SDF |
Interface to egg SDF initialising function
Initalising function for egg SDF. makes a Moss egg. ref.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | r1 |
R1 controls "fatness" of the egg. Actually controls the base circle radius. |
||
real(kind=wp), | intent(in) | :: | r2 |
R2 contorls the pointiness of the egg. Actually controls radius of top circle. |
||
real(kind=wp), | intent(in) | :: | h |
h controls the height of the egg. Actually controls y position of top circle. |
||
type(opticalProp_t), | intent(in) | :: | optProp |
Optical properties of the SDF |
||
integer, | intent(in) | :: | layer |
ID number of sdf |
||
real(kind=wp), | intent(in), | optional | :: | transform(4,4) |
Optional transform to apply to SDF |
Interface to plane SDF initialising function
Initalising function for plane SDF.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(vector), | intent(in) | :: | a |
Plane normal. must be normalised |
||
type(opticalProp_t), | intent(in) | :: | optProp |
Optical properties of the SDF |
||
integer, | intent(in) | :: | layer |
ID number of sdf |
||
real(kind=wp), | intent(in), | optional | :: | transform(4,4) |
Optional transform to apply to SDF |
Interface to segment SDF initialising function
Initalising function for segment SDF. Note this is a 2D function
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(vector), | intent(in) | :: | a |
segment start point |
||
type(vector), | intent(in) | :: | b |
segment end point |
||
type(opticalProp_t), | intent(in) | :: | optProp |
Optical properties of the SDF |
||
integer, | intent(in) | :: | layer |
ID number of sdf |
||
real(kind=wp), | intent(in), | optional | :: | transform(4,4) |
Optional transform to apply to SDF |
Initalising function for Sphere SDF.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | radius |
radius of the Sphere |
||
type(opticalProp_t), | intent(in) | :: | optProp |
Optical properties of the SDF |
||
integer, | intent(in) | :: | layer |
ID number of sdf |
||
real(kind=wp), | intent(in), | optional | :: | transform(4,4) |
Optional transform to apply to SDF |
Interface to torus SDF initialising function
Initalising function for Torus SDF.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | oradius |
Outer radius of Torus |
||
real(kind=wp), | intent(in) | :: | iradius |
Inner radius of Torus |
||
type(opticalProp_t), | intent(in) | :: | optProp |
Optical properties of the SDF |
||
integer, | intent(in) | :: | layer |
ID number of sdf |
||
real(kind=wp), | intent(in), | optional | :: | transform(4,4) |
Optional transform to apply to SDF |
Interface to triprisim SDF initialising function
Initalising function for triprisim SDF.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | h1 |
Height of triprisim |
||
real(kind=wp), | intent(in) | :: | h2 |
length of triprisim |
||
type(opticalProp_t), | intent(in) | :: | optProp |
Optical properties of the SDF |
||
integer, | intent(in) | :: | layer |
ID number of sdf |
||
real(kind=wp), | intent(in), | optional | :: | transform(4,4) |
Optional transform to apply to SDF |
Box SDF
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public | :: | layer |
Layer ID of SDF |
|||
type(vector), | public | :: | lengths |
Length of each dimension of the box |
|||
type(opticalProp_t), | public | :: | optProps |
Optical property of the SDF |
|||
real(kind=wp), | public | :: | transform(4,4) |
Transform to apply to SDF. |
Interface to box SDF initialising function
private function box_init (lengths, optProp, layer, transform) | Initalising function for Box SDF. |
procedure, public :: evaluate => evaluate_box |
Capsule SDF
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(vector), | public | :: | a | ||||
type(vector), | public | :: | b | ||||
integer, | public | :: | layer |
Layer ID of SDF |
|||
type(opticalProp_t), | public | :: | optProps |
Optical property of the SDF |
|||
real(kind=wp), | public | :: | r | ||||
real(kind=wp), | public | :: | transform(4,4) |
Transform to apply to SDF. |
Interface to capsule SDF initialising function
private function capsule_init (a, b, r, optProp, layer, transform) | Initalising function for capsule SDF. |
procedure, public :: evaluate => evaluate_capsule |
Cone SDF
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(vector), | public | :: | a | ||||
type(vector), | public | :: | b | ||||
integer, | public | :: | layer |
Layer ID of SDF |
|||
type(opticalProp_t), | public | :: | optProps |
Optical property of the SDF |
|||
real(kind=wp), | public | :: | ra | ||||
real(kind=wp), | public | :: | rb | ||||
real(kind=wp), | public | :: | transform(4,4) |
Transform to apply to SDF. |
Interface to cone SDF initialising function
private function cone_init (a, b, ra, rb, optProp, layer, transform) | Initalising function for Capped Cone SDF. |
procedure, public :: evaluate => evaluate_cone |
Cylinder SDF
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(vector), | public | :: | a | ||||
type(vector), | public | :: | b | ||||
integer, | public | :: | layer |
Layer ID of SDF |
|||
type(opticalProp_t), | public | :: | optProps |
Optical property of the SDF |
|||
real(kind=wp), | public | :: | radius | ||||
real(kind=wp), | public | :: | transform(4,4) |
Transform to apply to SDF. |
Interface to cylinder SDF initialising function
private function cylinder_init (a, b, radius, optProp, layer, transform) | Initalising function for Cylinder SDF. |
procedure, public :: evaluate => evaluate_cylinder |
Egg SDF
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
real(kind=wp), | public | :: | h | ||||
integer, | public | :: | layer |
Layer ID of SDF |
|||
type(opticalProp_t), | public | :: | optProps |
Optical property of the SDF |
|||
real(kind=wp), | public | :: | r1 | ||||
real(kind=wp), | public | :: | r2 | ||||
real(kind=wp), | public | :: | transform(4,4) |
Transform to apply to SDF. |
Interface to egg SDF initialising function
private function egg_init (r1, r2, h, optProp, layer, transform) | Initalising function for egg SDF. makes a Moss egg. ref. |
procedure, public :: evaluate => evaluate_egg |
Plane SDF
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(vector), | public | :: | a | ||||
integer, | public | :: | layer |
Layer ID of SDF |
|||
type(opticalProp_t), | public | :: | optProps |
Optical property of the SDF |
|||
real(kind=wp), | public | :: | transform(4,4) |
Transform to apply to SDF. |
Interface to plane SDF initialising function
private function plane_init (a, optProp, layer, transform) | Initalising function for plane SDF. |
procedure, public :: evaluate => evaluate_plane |
Segment SDF (2D)
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(vector), | public | :: | a | ||||
type(vector), | public | :: | b | ||||
integer, | public | :: | layer |
Layer ID of SDF |
|||
type(opticalProp_t), | public | :: | optProps |
Optical property of the SDF |
|||
real(kind=wp), | public | :: | transform(4,4) |
Transform to apply to SDF. |
Interface to segment SDF initialising function
private function segment_init (a, b, optProp, layer, transform) | Initalising function for segment SDF. Note this is a 2D function |
procedure, public :: evaluate => evaluate_segment |
Sphere SDF
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public | :: | layer |
Layer ID of SDF |
|||
type(opticalProp_t), | public | :: | optProps |
Optical property of the SDF |
|||
real(kind=wp), | public | :: | radius | ||||
real(kind=wp), | public | :: | transform(4,4) |
Transform to apply to SDF. |
private function sphere_init (radius, optProp, layer, transform) | Initalising function for Sphere SDF. |
procedure, public :: evaluate => evaluate_sphere |
Torus SDF
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
real(kind=wp), | public | :: | iradius | ||||
integer, | public | :: | layer |
Layer ID of SDF |
|||
type(opticalProp_t), | public | :: | optProps |
Optical property of the SDF |
|||
real(kind=wp), | public | :: | oradius | ||||
real(kind=wp), | public | :: | transform(4,4) |
Transform to apply to SDF. |
Interface to torus SDF initialising function
private function torus_init (oradius, iradius, optProp, layer, transform) | Initalising function for Torus SDF. |
procedure, public :: evaluate => evaluate_torus |
Triprisim SDF
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
real(kind=wp), | public | :: | h1 | ||||
real(kind=wp), | public | :: | h2 | ||||
integer, | public | :: | layer |
Layer ID of SDF |
|||
type(opticalProp_t), | public | :: | optProps |
Optical property of the SDF |
|||
real(kind=wp), | public | :: | transform(4,4) |
Transform to apply to SDF. |
Interface to triprisim SDF initialising function
private function triprism_init (h1, h2, optProp, layer, transform) | Initalising function for triprisim SDF. |
procedure, public :: evaluate => evaluate_triprism |
Initalising function for Box SDF.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(vector), | intent(in) | :: | lengths |
Lengths of each dimension of the box |
||
type(opticalProp_t), | intent(in) | :: | optProp |
Optical properties of the SDF |
||
integer, | intent(in) | :: | layer |
ID number of sdf |
||
real(kind=wp), | intent(in), | optional | :: | transform(4,4) |
Optional transform to apply to SDF |
Initalising function for capsule SDF.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(vector), | intent(in) | :: | a |
Capsule startpoint |
||
type(vector), | intent(in) | :: | b |
Capsule endpoint |
||
real(kind=wp), | intent(in) | :: | r |
Capsule radius |
||
type(opticalProp_t), | intent(in) | :: | optProp |
Optical properties of the SDF |
||
integer, | intent(in) | :: | layer |
ID number of sdf |
||
real(kind=wp), | intent(in), | optional | :: | transform(4,4) |
Optional transform to apply to SDF |
Initalising function for Capped Cone SDF.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(vector), | intent(in) | :: | a |
Centre of base of Cone |
||
type(vector), | intent(in) | :: | b |
Tip of cone |
||
real(kind=wp), | intent(in) | :: | ra |
Radius of Cones base |
||
real(kind=wp), | intent(in) | :: | rb |
Radius of Cones tip. For rb = 0.0 get normal uncapped cone. |
||
type(opticalProp_t), | intent(in) | :: | optProp |
Optical properties of the SDF |
||
integer, | intent(in) | :: | layer |
ID number of sdf |
||
real(kind=wp), | intent(in), | optional | :: | transform(4,4) |
Optional transform to apply to SDF |
Initalising function for Cylinder SDF.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(vector), | intent(in) | :: | a |
Vector position at centre of the bottom circle |
||
type(vector), | intent(in) | :: | b |
Vector position at centre of the top circle |
||
real(kind=wp), | intent(in) | :: | radius |
Radius of cylinder |
||
type(opticalProp_t), | intent(in) | :: | optProp |
Optical properties of the SDF |
||
integer, | intent(in) | :: | layer |
ID number of sdf |
||
real(kind=wp), | intent(in), | optional | :: | transform(4,4) |
Optional transform to apply to SDF |
Initalising function for egg SDF. makes a Moss egg. ref.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | r1 |
R1 controls "fatness" of the egg. Actually controls the base circle radius. |
||
real(kind=wp), | intent(in) | :: | r2 |
R2 contorls the pointiness of the egg. Actually controls radius of top circle. |
||
real(kind=wp), | intent(in) | :: | h |
h controls the height of the egg. Actually controls y position of top circle. |
||
type(opticalProp_t), | intent(in) | :: | optProp |
Optical properties of the SDF |
||
integer, | intent(in) | :: | layer |
ID number of sdf |
||
real(kind=wp), | intent(in), | optional | :: | transform(4,4) |
Optional transform to apply to SDF |
Initalising function for plane SDF.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(vector), | intent(in) | :: | a |
Plane normal. must be normalised |
||
type(opticalProp_t), | intent(in) | :: | optProp |
Optical properties of the SDF |
||
integer, | intent(in) | :: | layer |
ID number of sdf |
||
real(kind=wp), | intent(in), | optional | :: | transform(4,4) |
Optional transform to apply to SDF |
Initalising function for segment SDF. Note this is a 2D function
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(vector), | intent(in) | :: | a |
segment start point |
||
type(vector), | intent(in) | :: | b |
segment end point |
||
type(opticalProp_t), | intent(in) | :: | optProp |
Optical properties of the SDF |
||
integer, | intent(in) | :: | layer |
ID number of sdf |
||
real(kind=wp), | intent(in), | optional | :: | transform(4,4) |
Optional transform to apply to SDF |
Initalising function for Sphere SDF.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | radius |
radius of the Sphere |
||
type(opticalProp_t), | intent(in) | :: | optProp |
Optical properties of the SDF |
||
integer, | intent(in) | :: | layer |
ID number of sdf |
||
real(kind=wp), | intent(in), | optional | :: | transform(4,4) |
Optional transform to apply to SDF |
Initalising function for Torus SDF.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | oradius |
Outer radius of Torus |
||
real(kind=wp), | intent(in) | :: | iradius |
Inner radius of Torus |
||
type(opticalProp_t), | intent(in) | :: | optProp |
Optical properties of the SDF |
||
integer, | intent(in) | :: | layer |
ID number of sdf |
||
real(kind=wp), | intent(in), | optional | :: | transform(4,4) |
Optional transform to apply to SDF |
Initalising function for triprisim SDF.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | h1 |
Height of triprisim |
||
real(kind=wp), | intent(in) | :: | h2 |
length of triprisim |
||
type(opticalProp_t), | intent(in) | :: | optProp |
Optical properties of the SDF |
||
integer, | intent(in) | :: | layer |
ID number of sdf |
||
real(kind=wp), | intent(in), | optional | :: | transform(4,4) |
Optional transform to apply to SDF |