Objects

The following classes are available in the atom_access package.

  • Sphere – A sphere object with a radius and a center point.

  • Ray – Contains all information required to define a ray of light and its intersection with a sphere.

The intersection of a given ray with a given sphere can be calculated using the Ray.intersect method.

Rays can be generated using the Ray.from_zcw class method, which returns a list of rays evenly distributed on the surface of a sphere according to the ZCW algorithm.

This submodule contains ray and sphere objects and methods used for raytracing

class atom_access.objects.Ray(theta: float, phi: float)

Contains all information required to define a ray of light and its

intersection with an object. A ray is defined by its polar and azimuthal

angles, is assumed to have unit length, and passes through the origin.

Parameters:
  • theta (float) – Polar angle 0 <= theta <= pi

  • phi (float) – Azimuthal angle 0 <= phi <= 2pi

theta

Polar angle 0 <= theta <= pi

Type:

float

phi

Azimuthal angle 0 <= phi <= 2pi

Type:

float

r

Length of ray, assumed unity (ray is normalised)

Type:

float

x

x component of ray vector in cartesian coordinates

Type:

float

y

y component of ray vector in cartesian coordinates

Type:

float

z

z component of ray vector in cartesian coordinates

Type:

float

cart

Direction vector of ray as (3,) np.array

Type:

np.ndarray[float]

intersection

True if ray intersects with object

Type:

bool

r_i

Distance of closest intersection point from origin.

If no intersection, then this is set to np.inf.

Type:

float

cart_i

Position vector of closest intersection point as (3,) np.array

Type:

np.ndarray[float]

blocked_by

List of atom labels the ray intersects with, with the closest

listed first

Type:

list(str)

calc_cart_i() None

Calculates position vector of intersection point using intersection

distance

Parameters:

None

Return type:

None

classmethod from_zcw(density: int) list[Ray]

Generate a set of rays emanating from a single point using the ZCW

algorithm

See Appendix I in

Edén, M.; Levitt, M. H. J. Magn. Res., 1998, 132, 220-239.

Parameters:

density (int) – Density number for ZCW algorithm

Returns:

List of ray objects

Return type:

list[Ray]

property intersection: bool

True if ray intersects with object, else False

class atom_access.objects.Sphere(radius: float, center: ndarray[tuple[int, ...], dtype[_ScalarType_co]], name: str)

Contains all information required to define a sphere and to calculate

its intersection with a ray

Parameters:
  • radius (float) – Radius of sphere

  • center (np.ndarray[float]) – x,y,z coordinates of sphere center

  • name (str) – Name of sphere (e.g Atom label with indexing number)

radius

Radius of sphere

Type:

float

radius2

Squared radius of sphere

Type:

float

center

x,y,z coordinates of sphere center

Type:

np.ndarray[float]

center_dist

Distance to center from origin

Type:

np.ndarray[float]

name

Name of sphere (e.g Atom label with indexing number)

Type:

str

intersect(ray: Ray) tuple[bool, float, float]

Calculate intersection points of normalised ray vector with

sphere if they exist.

Parameters:

ray (Ray) – Ray object

Returns:

  • bool – True if intersection, else False

  • float – First intersection point, 0 if no intersection

  • float – Second intersection point, 0 if no intersection