Geometry Functions
A collection of useful functions for geometry and coordinate transformations, including translations and transformations of meshio.Mesh objects together with included electromagnetic field data.
- lyceanem.geometry.geometryfunctions.axes_from_normal(boresight_vector, boresight_along='x')[source]
Calculates the required local axes within the global coordinate frame based upon the desired boresight, the standard is that the x-axis will be pointed along the desired boresight_vector, while the z-axis will be aligned as closely as possible to the global z-axis.
- Parameters:
boresight_vector (numpy.ndarray of float) – desired boresight vector, should be a 1x3 array.
- Returns:
rotation_matrix – the rotation matrix that aligns the boresight vector with the specified axis (x, y, or z).
- Return type:
- lyceanem.geometry.geometryfunctions.cell_centroids(field_data)[source]
In order to calculate the centroid of the triangle, take vertices from meshio triangle mesh, then put each triangle into origin space, creating oa,ob,oc vectors, then the centroid is a third of the sum of oa+ob+oc, converted back into global coordinates
- Parameters:
field_data (
meshio.Mesh) – mesh with points and triangles- Returns:
centroid_cloud – The centroid cloud, with the centroid of each triangle as a vertex, and the cell data from the original mesh as point data
- Return type:
meshio.Mesh
- lyceanem.geometry.geometryfunctions.compute_areas(field_data)[source]
Computes the area of each cell in the mesh and assigns it to the cell data. The area is calculated using Heron’s formula for triangles and quads. The area is also calculated for each point in the mesh, based on the area of the cells it is associated with.
- Parameters:
field_data (
meshio.Mesh) – The meshio mesh object containing the cells and points.- Returns:
field_data – The meshio mesh object with the computed areas added to the cell data and point data.
- Return type:
meshio.Mesh
- lyceanem.geometry.geometryfunctions.compute_normals(mesh)[source]
Computes the Cell Normals for meshio mesh objects, the point normals will also be calculated for all points which are connected to a triangle, quad, or vertex, isolated points will be propulated with a normal vector of nan. If the only cells are vertex cells, then the normals are defined from the mesh origin to each vertex.
- Parameters:
mesh (
meshio.Mesh) – The meshio mesh object containing the cells and points.- Returns:
mesh – The meshio mesh object with the computed normals added to the cell data and point data.
- Return type:
meshio.Mesh
- lyceanem.geometry.geometryfunctions.mesh_conversion(conversion_object)[source]
Convert the provide file object into
lyceanem.base_types.triangle_tformat for raycasting- Parameters:
conversion_object (solid object to be converted into
lyceanem.base_types.triangle_tformat, could bemeshio.Mesh,lyceanem.base_classes.structures, orlyceanem.base_classes.antenna_structures)- Returns:
triangles
- Return type:
numpy array of
lyceanem.base_types.triangle_t
- lyceanem.geometry.geometryfunctions.mesh_conversion_to_meshio(conversion_object)[source]
Convert the provided file object into meshio format
- Parameters:
conversion_object (solid object to be converted into meshio format, could be
meshio.Mesh,lyceanem.base_classes.structures, orlyceanem.base_classes.antenna_structures)- Returns:
meshio_mesh – The converted meshio mesh object
- Return type:
meshio.Mesh
- lyceanem.geometry.geometryfunctions.mesh_rotate(mesh, rotation, rotation_centre=array([[0., 0., 0.]], dtype=float32))[source]
Rotate the provided meshio mesh about the defined center using either rotation vector or rotation matrix. This function will also rotate the cartesian electric field vectors if present, or convert spherical vectors to cartesian then rotate.
- Parameters:
mesh (
meshio.Mesh)rotation (numpy.ndarray of float) – the rotation vector or rotation matrix for the desired rotation
rotation_centre (numpy.ndarray of float, optional) – Centre of rotation
- Returns:
mesh – The rotated mesh, with cartesian electric field vectors
- Return type:
meshio.Mesh
- lyceanem.geometry.geometryfunctions.mesh_transform(mesh, transform_matrix, rotate_only)[source]
Transform the provided meshio mesh using the provided transformation matrix. The transformation matrix should be a 4x4 matrix. This function should be used with care, as currently the electric field vectors are not transformed.
- Parameters:
mesh (
meshio.Mesh) – The mesh to be transformed.transform_matrix (numpy.ndarray of float) – The transformation matrix to be applied to the mesh. Should be a 4x4 matrix.
rotate_only (bool) – If True, only the rotation part of the transformation matrix will be applied. If False, the full transformation (including translation) will be applied.
- Returns:
mesh – The transformed mesh.
- Return type:
meshio.Mesh
- lyceanem.geometry.geometryfunctions.mesh_translate(mesh, translation_vector)[source]
Translate a mesh by a given translation vector.
- Parameters:
mesh (
meshio.Mesh) – The mesh to be translated.translation_vector (numpy.ndarray of float) – The translation vector to be applied to the mesh. Should be a 1x3 array.
- Returns:
mesh – The translated mesh.
- Return type:
meshio.Mesh
- lyceanem.geometry.geometryfunctions.theta_phi_r(field_data)[source]
Calculate the spherical coordinates for the provided field data relative to the origin
- Parameters:
field_data (
meshio.Mesh) – The meshio mesh object containing the points for which spherical coordinates are to be calculated.- Returns:
field_data – The meshio mesh object with the computed spherical coordinates added to the point data.
- Return type:
meshio.Mesh