ddg.datastructures.indexedfaceset.ifs_generator module
Generate geometric objects as indexed face sets.
- ddg.datastructures.indexedfaceset.ifs_generator.tetrahedron(co_attr='co')[source]
Create a tetrahedron as an indexed face set.
By default, standard coordinates of a unit tetrahedron, centered at (0, 0, 0), will be assigned to the vertices.
- Parameters:
- co_attrstr or None (default=”co”)
Name of the vertex attribute that stores the coordinates. If
co_attr=None, don’t assign any coordinates.
- Returns:
- objddg.datastructures.indexedfaceset.ifs.IndexedFaceSet
A tetrahedron.
- ddg.datastructures.indexedfaceset.ifs_generator.cube(co_attr='co')[source]
Create a cube as an indexed face set
By default, standard coordinates of a unit cube, centered at (0, 0, 0), will be assigned to the vertices.
- Parameters:
- co_attrstr or None (default=”co”)
Name of the vertex attribute that stores the coordinates. If
co_attr=None, don’t assign any coordinates.g
- Returns:
- objddg.datastructures.indexedfaceset.ifs.IndexedFaceSet
A cube.
- ddg.datastructures.indexedfaceset.ifs_generator.octahedron(co_attr='co')[source]
Create an octahedron as an indexed face set.
By default, standard coordinates of a unit octahedron, centered at (0, 0, 0), will be assigned to the vertices.
- Parameters:
- co_attrstr or None (default=”co”)
Name of the vertex attribute that stores the coordinates. If
co_attr=None, don’t assign any coordinates.g
- Returns:
- objddg.datastructures.indexedfaceset.ifs.IndexedFaceSet
An octahedron.
- ddg.datastructures.indexedfaceset.ifs_generator.dodecahedron(co_attr='co')[source]
Create a dodecahedron as an indexed face set.
By default, standard coordinates of a unit dodecahedron, centered at (0, 0, 0), will be assigned to the vertices.
- Parameters:
- co_attrstr or None (default=”co”)
Name of the vertex attribute that stores the coordinates. If
co_attr=None, don’t assign any coordinates.g
- Returns:
- objddg.datastructures.indexedfaceset.ifs.IndexedFaceSet
A dodecahedron.
- ddg.datastructures.indexedfaceset.ifs_generator.icosahedron(co_attr='co')[source]
Create an icosahedron as an indexed face set.
By default, standard coordinates of a unit icosahedron, centered at (0, 0, 0), will be assigned to the vertices.
- Parameters:
- co_attrstr or None (default=”co”)
Name of the vertex attribute that stores the coordinates. If
co_attr=None, don’t assign any coordinates.g
- Returns:
- objddg.datastructures.indexedfaceset.ifs.IndexedFaceSet
An icosahedron.
- ddg.datastructures.indexedfaceset.ifs_generator.disc(resolution=20, center=(0, 0, 0), normal=(0, 0, 1), radius=1, co_attr='co')[source]
Create a disc as an indexed face set.
By default, the disc is centered at (0, 0, 0), the normal is (0, 0, 1) and the radius is 1.
- Parameters:
- resolutionint (default=20)
The amount of vertices of the disc
- centerarray_like of shape (3,) (default=(0, 0, 0))
The center of the disc as a list in 3D space.
- normalarray_like of shape (3,) (default=(0, 0, 1))
The normal vector of the disc.
- radiusfloat (default=1)
The radius of the disc.
- co_attrstr or None (default=”co”)
Name of the vertex attribute that stores the coordinates. If
co_attr=None, don’t assign any coordinates.g
- Returns:
- objddg.datastructures.indexedfaceset.ifs.IndexedFaceSet
A disc.
- ddg.datastructures.indexedfaceset.ifs_generator.cone(resolution=20, fill_caps=True, radius=1, length=1, center=(0, 0, 0), normal=(0, 0, 1), co_attr='co')[source]
Create a cone as an indexed face set.
By default, the cone’s base will be at (0, 0, 0) and its tip at (0, 0, 1).
- Parameters:
- resolutionint (default=20)
The number of vertices of the base.
- fill_caps: bool (default=True)
If
True, include the face of the base.- radiusfloat (default=1)
The radius of the base of the cone.
- lengthfloat (default=1)
The length of the cone.
- centerarray_like of shape (3,) (default=(0, 0, 0))
The center of the base of the cone.
- normalarray_like of shape (3,) (default=(0, 0, 1))
The normal of the cone’s base face.
- co_attrstr or None (default=”co”)
Name of the vertex attribute that stores the coordinates. If
co_attr=None, don’t assign any coordinates.g
- Returns:
- objddg.datastructures.indexedfaceset.ifs.IndexedFaceSet
A cone.
- ddg.datastructures.indexedfaceset.ifs_generator.cylinder(resolution=20, fill_caps=True, top_radius=1, bot_radius=1, length=1, center=(0, 0, 0), normal=(0, 0, 1), co_attr='co')[source]
Create a cylinder as an indexed face set.
By default, the cylinder’s bottom will be at (0, 0, 0) and its top at (0, 0, 1).
- Parameters:
- resolutionint (default=20)
The number of vertices on each side.
- fill_capsbool (default=True)
If
True, include the faces of the bottom and the top.- top_radiusfloat (default=1)
The radius of the top of the cylinder.
- bot_radiusfloat (default=1)
The radius of the bottom of the cylinder
- lengthfloat (default=1)
The length of the cylinder.
- centerarray_like of shape (3,) (default=(0, 0, 0))
The center of the bottom of the cylinder.
- normalarray_like of shape (3,) (default=(0, 0, 1))
The normal of the cylinder’s top and bottom faces.
- co_attrstr or None (default=”co”)
Name of the vertex attribute that stores the coordinates. If
co_attr=None, don’t assign any coordinates.g
- Returns:
- objddg.datastructures.indexedfaceset.ifs.IndexedFaceSet
A cylinder.
- ddg.datastructures.indexedfaceset.ifs_generator.arrow(resolution=20, heights=(0, 0.7, 0.7, 1), radii=(0.05, 0.05, 0.125), co_attr='co')[source]
Create an arrow as an indexed face set.
This is useful to visualise vectors.
By default, the arrow will point up. The bottom will be at (0, 0, 0) and the tip at (0, 0, 1).
- Parameters:
- resolutionint (default=20)
The amount of vertices at the base of the tip
- heightsfloat sequence of length 4 (default=(0, 0.7, 0.7, 1))
First element defines height of the bottom of the stick, the second the height of the top of the stick, the third the height of the base of the head and the fourth the height of the tip.
- radiifloat sequence of length 3 (default=(0.05, 0.05, 0.125))
First element defines the radius of the bottom of the stick, second the radius of the top of the stick and the third the radius of the base of the tip.
- co_attrstr or None (default=”co”)
Name of the vertex attribute that stores the coordinates. If
co_attr=None, don’t assign any coordinates.g
- Returns:
- objddg.datastructures.indexedfaceset.ifs.IndexedFaceSet
An arrow.
- ddg.datastructures.indexedfaceset.ifs_generator.grid(shape, co_attr='co')[source]
Create a quad grid as an indexed face set.
The
shapedefines the number of vertices in each direction. Both 2D and 3D grids are supported.- Parameters:
- shapetuple of length 2 or 3
Shape of the grid. The first entry is the number of vertices in the x-direction, the second the number of vertices in the y-direction and the third (if given) the number of vertices in the z-direction.
- co_attrstr or None (default=”co”)
Name of the vertex attribute that stores the coordinates. If
co_attr=None, don’t assign any coordinates.g
- Returns:
- objddg.datastructures.indexedfaceset.ifs.IndexedFaceSet
A quad grid.
Examples
>>> from ddg.datastructures.indexedfaceset.ifs_generator import grid >>> quad_grid = grid((2, 3)) >>> quad_grid.vertex_attributes["co"] array([[0, 0], [1, 0], [0, 1], [1, 1], [0, 2], [1, 2]])
>>> quad_grid = grid((2, 3, 1)) >>> quad_grid.vertex_attributes["co"] array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [1, 1, 0], [0, 2, 0], [1, 2, 0]])
>>> quad_grid = grid((2, 3, 2)) >>> quad_grid.vertex_attributes["co"] array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [1, 1, 0], [0, 2, 0], [1, 2, 0], [0, 0, 1], [1, 0, 1], [0, 1, 1], [1, 1, 1], [0, 2, 1], [1, 2, 1]])
- ddg.datastructures.indexedfaceset.ifs_generator.triangle_grid(shape, co_attr='co')[source]
Create a triangle grid as an indexed face set.
The
shapedefines the number of vertices in each direction. Both 2D and 3D grids are supported.- Parameters:
- shapetuple of length 2 or 3
Shape of the grid. The first entry is the number of vertices in the x-direction, the second the number of vertices in the y-direction and the third (if given) the number of vertices in the z-direction.
- co_attrstr or None (default=”co”)
Name of the vertex attribute that stores the coordinates. If
co_attr=None, don’t assign any coordinates.g
- Returns:
- objddg.datastructures.indexedfaceset.ifs.IndexedFaceSet
A triangle grid.
Examples
>>> from ddg.datastructures.indexedfaceset.ifs_generator import triangle_grid >>> tri_grid = triangle_grid((2, 3)) >>> tri_grid.vertex_attributes["co"] array([[0, 0], [1, 0], [0, 1], [1, 1], [0, 2], [1, 2]])
>>> tri_grid = triangle_grid((2, 3, 1)) >>> tri_grid.vertex_attributes["co"] array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [1, 1, 0], [0, 2, 0], [1, 2, 0]])
>>> tri_grid = triangle_grid((2, 3, 2)) >>> tri_grid.vertex_attributes["co"] array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [1, 1, 0], [0, 2, 0], [1, 2, 0], [0, 0, 1], [1, 0, 1], [0, 1, 1], [1, 1, 1], [0, 2, 1], [1, 2, 1]])