xmcd_projection.raytracing

class xmcd_projection.raytracing.RayTracing(mesh, p, n=[0, 0, 1], x0=[0, 0, 0], tol=1e-05)

Bases: object

Class that contains all the data required for raytracing.

get_piercings()

Gets the piercings of rays with direction self.p from a mesh to the screen with normal self.n.

Returns

for each triangle in the projected structure, lengths of the segment of the ray going through the tetrahedron with the given index.

Return type

list of tuples of arrays (lengths (n,), indices(n,))

static get_tetra_magnetisation(tetra, magnetisation)

Gets the magnetization of tetrahedra from per-vertex magnetisation

get_xmcd(magnetisation)

Gets the xmcd data based on the per-vertex magnetization of the mesh.

Parameters

magnetisation ((n,3) array) – magnetization

Returns

XMCD value for each face of the projected structure.

Return type

(m,) array

property piercings

List of tuples of two arrays for each face of the projected structure. Second array are the indices of the intersected tetrahedra and the first are the lengths of the intersections.

Returns

list of (2,) tuple

property struct

trimesh.Trimesh structure made from the triangles at the outside edge of the mesh

property struct_projected

trimesh.Trimesh structure made by projecting struct on the plan along the beam direction

xmcd_projection.raytracing.get_piercings_frompt_lengths(locations, intersected_tetrahedra_indx)

Gets the lengths and the unique index of intersected tetrahedra. I.e. from the locations of intersections and the indices of intersected tetrahedra, get the tetrahedra that were pierced twice and the length of the intersection segment.

xmcd_projection.raytracing.get_points_piercings(ray_origins, p, triangles, tol=0.001)

Gets the ray piercings of triangles for each of the ray_origins along the vector p. Returns the piercings as a list of tuples of two arrays for each of the ray origins. Second array are the indices of the intersected tetrahedra and the first are the lengths of the intersections.

Parameters
  • ray_origins ((n,3) array) – Origins of the rays

  • p ((3,) array) – Ray vector

  • triangles ((n,3,3) array) – Triangles

Returns

piercings list

Return type

list

xmcd_projection.raytracing.ray_triangle_id(triangles, ray_origins, ray_directions, triangles_normal=None, tree=None)

Find the intersections between a group of triangles and rays :param triangles: Triangles in space :type triangles: (n, 3, 3) float :param ray_origins: Ray origin points :type ray_origins: (m, 3) float :param ray_directions: Ray direction vectors :type ray_directions: (m, 3) float :param triangles_normal: Normal vector of triangles, optional :type triangles_normal: (n, 3) float :param tree: Rtree object holding triangle bounds :type tree: rtree.Index

Returns

  • index_triangle ((h,) int) – Index of triangles hit

  • index_ray ((h,) int) – Index of ray that hit triangle

  • locations ((h, 3) float) – Position of intersection in space