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

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 to intersection point from origin

Type:

float

cart_i

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

Type:

np.ndarray[float]

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]

reset_intersection() None

Resets intersection attributes of ray

Parameters:

None

Return type:

None

class atom_access.objects.Sphere(radius: float, center: ndarray[Any, dtype[_ScalarType_co]])

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

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]

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