radius Function

private pure function radius(self)

The sphere's radius (scene units).

Type Bound

Sphere

Arguments

Type IntentOptional Attributes Name
class(Sphere), intent(in) :: self

Return Value real(kind=wp)


Source Code

    function new_sphere(name, radius, color) result(s)
        character(len=*), intent(in) :: name                !! the frame's name
        real(wp), intent(in), optional :: radius            !! scene units (default 1)
        real(wp), intent(in), optional :: color(:)          !! [r, g, b] or [r, g, b, a] (0 to 1)
        type(Sphere) :: s
        s%ReferenceFrame = ReferenceFrame(name, color)
        if (present(radius)) s%radius_ = radius
    end function new_sphere

    !> The sphere's radius (scene units, > 0; default 1); can change at any time.
    subroutine set_radius(self, radius)
        class(Sphere), intent(inout) :: self
        real(wp), intent(in) :: radius                      !! scene units (<= 0: ignored)
        if (radius <= 0.0_wp) return
        self%radius_ = radius
        call update_sphere_transform(self)
    end subroutine set_radius

    !> The body's color (used without a texture); [r, g, b] or [r, g, b, a].
    subroutine sphere_set_color(self, color)
        class(Sphere), intent(inout) :: self
        real(wp), intent(in) :: color(:)                    !! [r, g, b] or [r, g, b, a] (0 to 1)
        call self%ReferenceFrame%set_color(color)
        call apply_material(self)
    end subroutine sphere_set_color

    !> The body's opacity, 0 (invisible) to 1 (opaque, the default): below 1
    !> it is drawn translucent (see the module documentation). Set below 1
    !> before a window first shows it to make it translucent; then the
    !> opacity can change at any time (a translucent body stays translucent,
    !> an opaque one opaque).
    subroutine set_opacity(self, opacity)
        class(Sphere), intent(inout) :: self
        real(wp), intent(in) :: opacity                     !! 0 to 1
        self%opacity_ = max(0.0_wp, min(1.0_wp, opacity))
        call apply_material(self)
    end subroutine set_opacity

    !> The body's opacity (set_opacity).
    pure real(wp) function opacity(self)
        class(Sphere), intent(in) :: self
        opacity = self%opacity_
    end function opacity

    !> The sphere's radius (scene units).
    pure real(wp) function radius(self)
        class(Sphere), intent(in) :: self
        radius = self%radius_
    end function radius