6. candy
— Predefined geometries for a special purpose.¶
This module contains some predefined special purpose geometries functions.
6.1. Contents¶
6.2. Functions defined in module candy¶
- candy.Axes(cs=None, *, size=1.0, psize=0.5, reverse=True, color=['red', 'green', 'blue', 'cyan', 'magenta', 'yellow'], linewidth=2, alpha=0.5, **kargs)[source]¶
A geometry representing the three axes of a coordinate system.
The default geometry consists of three colored lines of unit length along the positive directions of the axes of the coordinate system, and three colored triangles representing the coordinate planes. The triangles extend from the origin to half the length of the unit vectors. Default colors for the axes is red, green, blue.
- Parameters:
cs (
coordsys.CoordSys
) – If provided, the Axes will represent the specified CoordSys. Else, The axes are aligned along the global axes.size (float) – A scale factor for the unit vectors.
psize (float) – Relative scale factor for the coordinate plane triangles. If 0, no triangles will be drawn.
reverse (bool) – If True, also the negative unit axes are included, with colors 4..6.
color (3 or 6 colors) – A set of three or six colors to use for x,y,z axes. If reverse is True or psize > 0.0, the color set should have 6 colors, else 3 will suffice.
**kargs (keyword arguments) – Any extra keyword arguments will be added as attributes to the geometry.
- Returns:
List
– A List containing twoMesh
instances: the lines along the axes and the triangles in the coordinate planes.
- candy.Horse()[source]¶
A surface model of a horse.
- Returns:
TriSurface – A surface model of a horse. The model is loaded from a file.
- candy.KleinBottle(nu=128, nv=64, ru=(0.0, 1.0), rv=(0.0, 1.0))[source]¶
A Quad4 Mesh representing a Klein bottle.
A Klein bottle is a borderless non-orientable surface. In 3D the surface is self-intersecting.
- Parameters:
nu (int) – Number of elements along the longitudinal axis of the bottle.
nv (int) – Number of elements along the circumference of the bottle.
ru (tuple of floats) – The relative range of the longitudinal parameter. The default covers the full range [0., pi].
rv (tuple of floats) – The relative range of the circumferential parameter. The default covers the full range [0., 2*np.pi].
- Returns:
Mesh
– A Mesh of eltype Quad4 representing a Klein bottle. The Mesh has nu * nv elements and (nu+1) * (nv+1) nodes. The Mesh is not fused and will contain double nodes at the ends of the full parameter ranges. UseMesh.fuse()
andMesh.compact()
to remove double nodes.
Notes
One can check that the surface has no border from:
KleinBottle().fuse().compact().getBorder()
which returns an empty list.
The non-orientability and self-intersection of the surface can be checked from transforming the Klein bottle to a
TriSurface
and then using thecheck()
. For the non-fused bottle, this will report ‘orientable but self-intersecting’. For the fused bottle, the report will say ‘not an orientable manifold’.