geometry Module

Defines a set of functions for intersecting a ray and a surface.

  • Circle
  • Plane
  • Cone
  • Cylinder
  • Ellipse
  • Sphere


Functions

public function intersectCircle(n, p0, radius, l0, l, t)

ref

Arguments

Type IntentOptional Attributes Name
type(vector), intent(in) :: n

Normal to the circle

type(vector), intent(in) :: p0

a centre of the circle

real(kind=wp), intent(in) :: radius

Radius of the circle

type(vector), intent(in) :: l0

origin of the ray

type(vector), intent(in) :: l

direction vector of the ray

real(kind=wp), intent(inout) :: t

Distance from l0 to the intersection point

Return Value logical

public function intersectCone(orig, dir, t, centre, radius, height)

calculates where a line, with origin:orig and direction:dir hits a cone, radius:radius and height:height with centre:centre. centre is the point under the apex at the cone's base. returns true if intersection exists returns t, the paramertised parameter of the line equation adapted from scratchapixel and pbrt need to check z height after moving ray if not this is an infinte cone cone lies height ways along z-axis

Arguments

Type IntentOptional Attributes Name
type(vector), intent(in) :: orig

origin of the ray

type(vector), intent(in) :: dir

Direction vector of the ray

real(kind=wp), intent(out) :: t

distance from orig to the intersection point

type(vector), intent(in) :: centre

Centre of the cone

real(kind=wp), intent(in) :: radius

Radius of the cones base

real(kind=wp), intent(in) :: height

Height of the cone

Return Value logical

public function intersectCylinder(orig, dir, t, centre, radius)

calculates where a line, with origin:orig and direction:dir hits a cylinder, centre:centre and radius:radius This solves for an infinitely long cylinder centered on the z axis with radius radius returns true if intersection exists returns t, the paramertised parameter of the line equation adapted from scratchapixel need to check z height after moving ray if not this is an infinite cylinder

Arguments

Type IntentOptional Attributes Name
type(vector), intent(in) :: orig

origin of the ray

type(vector), intent(in) :: dir

Direction vector of the ray

real(kind=wp), intent(out) :: t

distance from orig to the intersection point

type(vector), intent(in) :: centre

Centre of the cylinder

real(kind=wp), intent(in) :: radius

radius of the cylinder

Return Value logical

public function intersectEllipse(orig, dir, t, centre, semia, semib)

calculates where a line, with origin:orig and direction:dir hits a ellipse, centre:centre and axii:semia, semib returns true if intersection exists returns t, the paramertised parameter of the line equation adapted from scratchapixel and pbrt need to check z height after moving ray if not this is an infinte ellipse-cylinder ellipse lies length ways along z-axis semia and semib are the semimajor axis which are the half width and height.

Arguments

Type IntentOptional Attributes Name
type(vector), intent(in) :: orig

origin of the ray

type(vector), intent(in) :: dir

Direction vector of the ray

real(kind=wp), intent(out) :: t

distance from orig to the intersection point

type(vector), intent(in) :: centre

Centre of the ellipse

real(kind=wp), intent(in) :: semia

Half width of the ellipse

real(kind=wp), intent(in) :: semib

Half height of the ellipse

Return Value logical

public function intersectPlane(n, p0, l0, l, t)

ref

Arguments

Type IntentOptional Attributes Name
type(vector), intent(in) :: n

Normal to the plane

type(vector), intent(in) :: p0

a point on the plane

type(vector), intent(in) :: l0

origin of the ray

type(vector), intent(in) :: l

direction vector of the ray

real(kind=wp), intent(inout) :: t

Distance from l0 to the intersection point

Return Value logical

public function intersectSphere(orig, dir, t, centre, radius)

calculates where a line, with origin:orig and direction:dir hits a sphere, centre:centre and radius:radius returns true if intersection exists returns t, the paramertised parameter of the line equation adapted from scratchapixel

Arguments

Type IntentOptional Attributes Name
type(vector), intent(in) :: orig

Origin of the ray

type(vector), intent(in) :: dir

Direction vector of the ray

real(kind=wp), intent(out) :: t

Distance from orig to the intersection point

type(vector), intent(in) :: centre

Centre of the sphere

real(kind=wp), intent(in) :: radius

Radius of the sphere

Return Value logical

private function solveQuadratic(a, b, c, x0, x1)

solves quadratic equation given coeffs a, b, and c returns true if real solution returns x0 and x1 adapted from scratchapixel

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: a
real(kind=wp), intent(in) :: b
real(kind=wp), intent(in) :: c
real(kind=wp), intent(out) :: x0
real(kind=wp), intent(out) :: x1

Return Value logical