ddg.math.discrete_objects module

The module ‘discrete_objects’ defines coordinates and faces of objects.

ddg.math.discrete_objects.tetrahedron_faces()[source]

Generate faces of a tetrahedron as numpy.ndarray

The faces have type numpy.ndarray of shape (3,). They consist of integers representing the adjacent vertices.

Returns:
facesnumpy.ndarray

The faces of the tetrahedron

ddg.math.discrete_objects.tetrahedron_coordinates()[source]

Generate coordinates of a tetrahedron as numpy.ndarray

The coordinates are in 3D space. The object is centered at the origin, meaning at [0,0,0].

Returns:
coordsnumpy.ndarray

The coordinates of the tetrahedron

ddg.math.discrete_objects.cube_faces()[source]

Generate faces of a cube as numpy.ndarray

The faces have type numpy.ndarray of shape (4,). They consist of integers representing the adjacent vertices.

Returns:
facesnumpy.ndarray

The faces of the cube

ddg.math.discrete_objects.cube_coordinates()[source]

Generate coordinates of a cube as numpy.ndarray

The coordinates are in 3D space. The object is centered at the origin, meaning at [0,0,0].

Returns:
coordsnumpy.ndarray

The coordinates of the cube

ddg.math.discrete_objects.octahedron_faces()[source]

Generate faces of an octahedron as numpy.ndarray

The faces have type numpy.ndarray of shape (3,). They consist of integers representing the adjacent vertices.

Returns:
facesnumpy.ndarray

The faces of the octahedron

ddg.math.discrete_objects.octahedron_coordinates()[source]

Generate coordinates of an octahedron as numpy.ndarray

The coordinates are in 3D space. The object is centered at the origin, meaning at [0,0,0].

Returns:
coordsnumpy.ndarray

The coordinates of the octahedron

ddg.math.discrete_objects.dodecahedron_faces()[source]

Generate faces of a dodecahedron as numpy.ndarray

The faces have type numpy.ndarray of shape (5,). They consist of integers representing the adjacent vertices.

Returns:
facesnumpy.ndarray

The faces of the dodecahedron

ddg.math.discrete_objects.dodecahedron_coordinates()[source]

Generate coordinates of a dodecahedron as numpy.ndarray

The coordinates are in 3D space. The object is centered at the origin, meaning at [0,0,0].

Returns:
coordsnumpy.ndarray

The coordinates of the dodecahedron

ddg.math.discrete_objects.icosahedron_faces()[source]

Generate faces of an icosahedron as numpy.ndarray

The faces have type numpy.ndarray of shape (3,). They consist of integers representing the adjacent vertices.

Returns:
facesnumpy.ndarray

The faces of the icosahedron

ddg.math.discrete_objects.icosahedron_coordinates()[source]

Generate coordinates of an icosahedron as numpy.ndarray

The coordinates are in 3D space. The object is centered at the origin, meaning at [0,0,0].

Returns:
coordsnumpy.ndarray

The coordinates of the icosahedron

ddg.math.discrete_objects.disc_face(resolution)[source]

Generate the face of a disc as numpy.ndarray

A disc is a circle with an inscribed face. The face has type numpy.ndarray of shape (‘resolution’,). It consists of integers representing the adjacent vertices.

Parameters:
resolutionint

The number of vertices of the disc

Returns:
facenumpy.ndarray

The face of the disc

ddg.math.discrete_objects.disc_coordinates(resolution, center=(0, 0, 0), normal=(0, 0, 1), radius=1)[source]

Generate coordinates of a disc as numpy.ndarray

The coordinates are in 3D space. By default, the disc is centered at [0,0,0].

Parameters:
resolutionint

The number of vertices of the disc

centeriterable (default=(0,0,0))

The center of the disc in 3D space.

normaliterable (default=(0,0,1))

The normal vector of the disc.

radiusfloat (default=1)

The radius of the disc.

Returns:
coordsnumpy.ndarray

The coordinates of the disc

ddg.math.discrete_objects.cone_faces(resolution)[source]

Generate the face of a cone as numpy.ndarray.

The faces are of type numpy.ndarray with non-uniform lengths. They consist of integers representing the adjacent vertices.

Parameters:
resolutionint

The resolution of the cone.

Returns:
numpy.ndarray of shape (n + 1, k)

The faces of the cone where n is the resolution and k varies. Note that dtype=object because of k.

ddg.math.discrete_objects.cone_coordinates(resolution, radius=1, length=1, center=(0, 0, 0), normal=(0, 0, 1))[source]

Generate coordinates of a cone as numpy.ndarray.

The coordinates are in 3D. By default, the cone’s bottom is at [0,0,0] and the cone points upwards.

Parameters:
resolutionint

The number of vertices.

radiusfloat (default=1)

The radius of the base of the cone.

lengthfloat (default=1)

The length of the cone.

centeriterable (default=(0,0,0))

The center of the base.

normaliterable (default=(0,0,1))

The normal of the cone’s base.

Returns:
coordsnumpy.ndarray of shape (n + 1, 3)

The coordinates of the cone where n is the resolution.

ddg.math.discrete_objects.cylinder_faces(resolution)[source]

Generate the faces of a cylinder as numpy.ndarray

The faces are of type numpy.ndarray with non-uniform lengths. They consist of integers representing the adjacent vertices. The first face is the bottom face, the second the top and the remaining faces the side faces.

Parameters:
resolutionint

The resolution of the cylinder

Returns:
facesnumpy.ndarray

The faces of the cylinder

ddg.math.discrete_objects.cylinder_coordinates(resolution, top_radius=1, bot_radius=1, length=1, center=(0, 0, 0), normal=(0, 0, 1))[source]

Generate coordinates of a cylinder as numpy.ndarray

The coordinates are in 3D. By default, the cylinder’s bottom is at [0,0,0].

Parameters:
resolutionint

The number of vertices at each side.

top_radiusfloat

The radius of the top of the cylinder.

bot_radiusfloat

The radius of the bottom of the cylinder.

lengthfloat

The length of the cylinder.

centeriterable (default=(0,0,0))

The center of the bottom of the cylinder.

normaliterable (default=(0,0,1))

The normal of the cylinder’s top and bottom faces.

Returns:
coordsnumpy.ndarray

The coordinates of the cylinder

ddg.math.discrete_objects.arrow_faces(resolution)[source]

Generate faces of an arrow as numpy.ndarray

The faces are of type numpy.ndarray with non-uniform lengths. They consist of integers representing the adjacent vertices. First bottom face, then the faces of the stick, then the faces of the base of the tip and finally the faces of the tip.

Parameters:
resolutionint

The resolution of the arrow

Returns:
facesnumpy.ndarray

The faces of the arrow

ddg.math.discrete_objects.arrow_coordinates(resolution, heights=(0, 0.7, 0.7, 1), radii=(0.05, 0.05, 0.125))[source]

Generate coordinates of an arrow as numpy.ndarray

The coordinates are in 3D. By default, the arrow’s bottom is at [0,0,0] and it’s head at [0,0,1].

Parameters:
resolutionint

The resolution of the arrow

heightsiterable (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 tip and the forth the height of the tip of the head.

radiiiterable (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.

Returns:
coordinatesnumpy.ndarray

The coordinates of the arrow