egg_init Function

private function egg_init(r1, r2, h, optProp, layer, transform) result(out)

Initalising function for egg SDF. makes a Moss egg. ref.

Arguments

Type IntentOptional 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

Return Value type(egg)


Source Code

    function egg_init(r1, r2, h, optProp, layer, transform) result(out)
        !! Initalising function for egg SDF.
        !! makes a Moss egg. [ref](https://www.shadertoy.com/view/WsjfRt).

        type(egg) :: out
        
        !> R1 controls "fatness" of the egg. Actually controls the base circle radius.
        real(kind=wp),            intent(IN) :: r1
        !> R2 contorls the pointiness of the egg. Actually controls radius of top circle.
        real(kind=wp),            intent(in) :: r2
        !> h controls the height of the egg. Actually controls y position of top circle.
        real(kind=wp),            intent(in) :: h
        !> ID number of sdf
        integer,                  intent(IN) :: layer
        !> Optional transform to apply to SDF
        real(kind=wp),  optional, intent(IN) :: transform(4, 4)
        !> Optical properties of the SDF
        type(opticalProp_t),      intent(in) :: optProp

        real(kind=wp) :: t(4, 4)

        if(present(transform))then
            t = transform
        else
            t = identity()
        end if

        out%h = h
        out%r1 = r1
        out%r2 = r2
        out%layer = layer
        out%transform = t
        out%optProps = optProp

    end function egg_init