capytaine.meshes.symmetric_meshes module¶
- class capytaine.meshes.symmetric_meshes.ReflectionSymmetricMesh(half: AbstractMesh, *, plane: str, faces_metadata: Dict[str, ndarray] | None = None, name: str | None = None)[source]¶
Bases:
AbstractMeshA mesh with reflection symmetry across a plane.
This class represents a mesh that has reflection symmetry across either the xOz plane (y=0) or yOz plane (x=0). Only half of the mesh is stored, and the full mesh can be reconstructed by reflecting across the symmetry plane.
Supports nested symmetries: if the half mesh is itself a ReflectionSymmetricMesh, this represents a quarter mesh with symmetries across both planes.
- Variables:
half (AbstractMesh) – The half mesh
plane (str) – The symmetry plane, either “xOz” or “yOz”
faces_metadata (Dict[str, np.ndarray], optional) – Some arrays with the same first dimension (should be the number of faces of the whole mesh) storing some fields defined on all the faces of the mesh.
name (str, optional) – Name for the mesh
Examples
>>> # Create a mesh with xOz symmetry (y=0 plane) >>> half_mesh = Mesh(vertices=..., faces=...) >>> symmetric_mesh = ReflectionSymmetricMesh(half=half_mesh, plane="xOz") >>> >>> # Create a mesh with both xOz and yOz symmetries (quarter mesh) >>> quarter_mesh = Mesh(vertices=..., faces=...) >>> sym_xOz = ReflectionSymmetricMesh(half=quarter_mesh, plane="xOz") >>> sym_both = ReflectionSymmetricMesh(half=sym_xOz, plane="yOz") >>> >>> # Get the full merged mesh >>> full_mesh = symmetric_mesh.merged()
- clipped(*, origin, normal, name=None) ReflectionSymmetricMesh | Mesh[source]¶
- copy(*, faces_metadata=None, name=None) ReflectionSymmetricMesh[source]¶
- property faces: ndarray¶
- property faces_areas: ndarray¶
- property faces_centers: ndarray¶
- property faces_normals: ndarray¶
- property faces_radiuses: ndarray¶
- join_meshes(*meshes, return_masks=False, name=None) ReflectionSymmetricMesh | Mesh[source]¶
- mirrored(plane: Literal['xOz', 'yOz'], *, name=None) ReflectionSymmetricMesh[source]¶
- property nb_faces: int¶
- property nb_vertices: int¶
- property quadrature_points: ndarray¶
- translated(shift, *, name=None) ReflectionSymmetricMesh | Mesh[source]¶
- property vertices: ndarray¶
- with_normal_vector_going_down(**kwargs) ReflectionSymmetricMesh[source]¶
- class capytaine.meshes.symmetric_meshes.RotationSymmetricMesh(wedge: AbstractMesh, n: int, *, axis: Literal['z+', 'z-'] = 'z+', faces_metadata: Dict[str, ndarray] | None = None, name: str | None = None)[source]¶
Bases:
AbstractMeshA mesh with rotation symmetry around the Oz axis.
This class represents a mesh that has n-fold rotational symmetry about the z-axis. Only a wedge (1/n of the full mesh) is stored, and the full mesh can be reconstructed by rotating the wedge n times.
Supports nested symmetries: the wedge mesh can be a ReflectionSymmetricMesh for dihedral symmetry.
- Variables:
wedge (AbstractMesh) – The wedge mesh (1/n of the full mesh)
n (int) – The rotation order (number of rotations to complete full circle)
axis (either 'z+' or 'z-') – Only the z-axis is supported, but two possible orientations can be used. Both are equivalent, except for the ordering of the sub-meshes.
faces_metadata (Dict[str, np.ndarray], optional) – Some arrays with the same first dimension (should be the number of faces of the whole mesh) storing some fields defined on all the faces of the mesh.
name (str, optional) – Name for the mesh
Examples
>>> # Create a mesh with 3-fold rotation symmetry about z-axis >>> wedge_mesh = Mesh(vertices=..., faces=...) >>> symmetric_mesh = RotationSymmetricMesh(wedge=wedge_mesh, n=3) >>> >>> # Get the full merged mesh >>> full_mesh = symmetric_mesh.merged()
- clipped(*, origin, normal, name=None) RotationSymmetricMesh | Mesh[source]¶
- copy(*, faces_metadata=None, name=None) RotationSymmetricMesh[source]¶
- property faces: ndarray¶
- property faces_areas: ndarray¶
- property faces_centers: ndarray¶
- property faces_normals: ndarray¶
- property faces_radiuses: ndarray¶
- classmethod from_profile_points(points: ndarray, n: int, *, faces_metadata=None, name=None)[source]¶
Return the mesh defined by the set of points repeated n times around the z-axis.
Points will be sorted by increasing z-coordinate before making a mesh, in order to ensure that the normal vector are outwards.
- Parameters:
points (array of shape (…, 3)) – A list of points in 3D.
n (int) – The rotation order (number of rotations to complete full circle)
faces_metadata (Dict[str, np.ndarray], optional) – Some arrays with the same first dimension (should be the number of faces of the whole mesh) storing some fields defined on all the faces of the mesh.
name (str, optional) – Name for the mesh
Example
>>> meridian_points = np.array([(np.sqrt(1-z**2), 0.0, z) for z in np.linspace(-1.0, 1.0, 10)]) >>> sphere = RotationSymmetricMesh.from_profile_points(meridian_points, n=10)
- join_meshes(*meshes, return_masks=False, name=None) RotationSymmetricMesh | Mesh[source]¶
- mirrored(plane: Literal['xOz', 'yOz'], *, name=None) RotationSymmetricMesh[source]¶
- property nb_faces: int¶
- property nb_vertices: int¶
- property quadrature_points: ndarray¶
- rotated_with_matrix(R, *, name=None) RotationSymmetricMesh | Mesh[source]¶
- translated(shift, *, name=None) RotationSymmetricMesh | Mesh[source]¶
- property vertices: ndarray¶
- with_normal_vector_going_down(**kwargs) RotationSymmetricMesh[source]¶