Skip to main content

BoundingBox

Bounding box defines the bounding box.

Structure

A BoundingBox_ datatype contains [x_min, y_min, z_min, x_max, y_max, z_max and NSD to represents a bounding box.

Structure

TYPE :: BoundingBox_
INTEGER(I4B) :: NSD
!! Number of spatial dimension
!! NSD = 1, 2, 3 for 1D, 2D, 3D box
REAL(DFP) :: Box(2, 3)
!! Box contains the xmin, ymin, ...
!! `Box(1:2, 1:3)` an array containing box coordinates.
!!- `Box(1:2, 1:3)` an array containing box coordinates.
!!- `Box(1, 1)` is x_min
!!- `Box(2, 1)` is x_max
!!- `Box(1, 2)` is y_min
!!- `Box(2, 2)` is y_max
!!- `Box(1, 3)` is z_min
!!- `Box(2, 3)` is z_max
REAL(DFP) :: l(3)
END TYPE BoundingBox_

Getting started

Getting max and min

You can get max and min by using following operators:

  • .xmin.
  • .xmax.
  • .ymin.
  • .ymax.
  • .zmin.
  • .zmax.
See an example
PROGRAM main
USE easifemBase
IMPLICIT NONE

TYPE(BoundingBox_) :: obj
REAL(DFP) :: found, want

CALL initiate(obj, nsd=2, &
lim=[1.0_DFP, 2.0_DFP, 3.0_DFP, 4.0_DFP, 5.0_DFP, 6.0_DFP])

found = .xmin.obj
want = 1.0_DFP

CALL OK(found.approxeq.want, ".xmin.")

!----------------------------------------------------------------------------
!
!----------------------------------------------------------------------------

found = .xmax.obj
want = 2.0_DFP

CALL OK(found.approxeq.want, ".xmax.")

!----------------------------------------------------------------------------
!
!----------------------------------------------------------------------------

found = .ymin.obj
want = 3.0_DFP

CALL OK(found.approxeq.want, ".ymin.")

!----------------------------------------------------------------------------
!
!----------------------------------------------------------------------------

found = .ymax.obj
want = 4.0_DFP

CALL OK(found.approxeq.want, ".ymax.")

!----------------------------------------------------------------------------
!
!----------------------------------------------------------------------------

found = .zmin.obj
want = 5.0_DFP

CALL OK(found.approxeq.want, ".zmin.")

!----------------------------------------------------------------------------
!
!----------------------------------------------------------------------------

found = .zmax.obj
want = 6.0_DFP

CALL OK(found.approxeq.want, ".zmax.")

END PROGRAM main

Getting size

We can get the diameter of the box by using the following functions:

  • GetDiameter It returns the diameter of the box.
  • GetDiameterSqr It returns the square of diameter of the box
  • GetRadius It returns the radius
  • GetRadiusSqr It returns the square of radius.
See examples
PROGRAM main
USE easifemBase
IMPLICIT NONE

TYPE(BoundingBox_) :: obj
REAL(DFP) :: lim(6)

lim = [1, 2, 3, 4, 5, 6]
obj = BoundingBox(nsd=3, lim=lim)

CALL Display(GetDiameter(obj), "GetDiameter: ")
CALL Display(GetDiameterSqr(obj), "GetDiameterSqr: ")
CALL Display(GetRadius(obj), "GetRadius: ")
CALL Display(GetRadiusSqr(obj), "GetRadiusSqr: ")

END PROGRAM main

All methods