Shapes¶
Shape¶
-
class
pydy.viz.shapes.
Shape
(name='unnamed', color='grey', material='default')[source]¶ Instantiates a shape. This is primarily used as a superclass for more specific shapes like Cube, Cylinder, Sphere etc.
Shapes must be associated with a reference frame and a point using the VisualizationFrame class.
Parameters: name : str, optional
A name assigned to the shape.
color : str, optional
A color string from list of colors in THREE_COLORKEYWORDS
Examples
>>> from pydy.viz.shapes import Shape >>> s = Shape() >>> s.name 'unnamed' >>> s.color 'grey' >>> s.name = 'my-shape1' >>> s.name 'my-shape1' >>> s.color = 'blue' >>> s.color 'blue' >>> a = Shape(name='my-shape2', color='red') >>> a.name 'my-shape2' >>> a.color 'red'
-
color
¶ Returns the color attribute of the shape.
-
generate_dict
(constant_map={})[source]¶ Returns a dictionary containing all the data associated with the Shape.
Parameters: constant_map : dictionary
If any of the shape’s geometry are defined as SymPy expressions, then this dictionary should map all SymPy Symbol’s found in the expressions to floats.
-
material
¶ Returns the material attribute of the shape.
-
name
¶ Returns the name attribute of the shape.
-
Cube¶
-
class
pydy.viz.shapes.
Cube
(length, **kwargs)[source]¶ Instantiates a cube of a given size.
Parameters: length : float or SymPy expression
The length of the cube.
Examples
>>> from pydy.viz.shapes import Cube >>> s = Cube(10.0) >>> s.name 'unnamed' >>> s.color 'grey' >>>s.length 10.0 >>> s.name = 'my-shape1' >>> s.name 'my-shape1' >>> s.color = 'blue' >>> s.color 'blue' >>> s.length = 12.0 >>> s.length 12.0 >>> a = Cube('my-shape2', 'red', length=10) >>> a.name 'my-shape2' >>> a.color 'red' >>> a.length 10.0
Cylinder¶
-
class
pydy.viz.shapes.
Cylinder
(length, radius, **kwargs)[source]¶ Instantiates a cylinder with given length and radius.
Parameters: length : float or SymPy expression
The length of the cylinder.
radius : float or SymPy expression
The radius of the cylinder.
Examples
>>> from pydy.viz.shapes import Cylinder >>> s = Cylinder(10.0, 5.0) >>> s.name 'unnamed' >>> s.color 'grey' >>> s.length 10.0 >>> s.radius 5.0 >>> s.name = 'my-shape1' >>> s.name 'my-shape1' >>> s.color = 'blue' >>> s.color 'blue' >>> s.length = 12.0 >>> s.length 12.0 >>> s.radius = 6.0 >>> s.radius 6.0 >>> a = Cylinder(10.0, 5.0, name='my-shape2', color='red') >>> a.name 'my-shape2' >>> a.color 'red' >>> a.length 10.0 >>> a.radius 5.0
Cone¶
-
class
pydy.viz.shapes.
Cone
(length, radius, **kwargs)[source]¶ Instantiates a cone with given length and base radius.
Parameters: length : float or SymPy expression
The length of the cone.
radius : float or SymPy expression
The base radius of the cone.
Examples
>>> from pydy.viz.shapes import Cone >>> s = Cone(10.0, 5.0) >>> s.name 'unnamed' >>> s.color 'grey' >>> s.length 10.0 >>> s.radius 5.0 >>> s.name = 'my-shape1' >>> s.name 'my-shape1' >>> s.color = 'blue' >>> s.color 'blue' >>> s.length = 12.0 >>> s.length 12.0 >>> s.radius = 6.0 >>> s.radius 6.0 >>> a = Cone(10.0, 5.0, name='my-shape2', color='red') >>> a.name 'my-shape2' >>> a.color 'red' >>> a.length 10.0 >>> a.radius 5.0
Sphere¶
-
class
pydy.viz.shapes.
Sphere
(radius=10.0, **kwargs)[source]¶ Instantiates a sphere with a given radius.
Parameters: radius : float or SymPy expression
The radius of the sphere.
Examples
>>> from pydy.viz.shapes import Sphere >>> s = Sphere(10.0) >>> s.name 'unnamed' >>> s.color 'grey' >>>s.radius 10.0 >>> s.name = 'my-shape1' >>> s.name 'my-shape1' >>> s.color = 'blue' >>> s.color 'blue' >>> s.radius = 12.0 >>> s.radius 12.0 >>> a = Sphere(10.0, name='my-shape2', color='red') >>> a.name 'my-shape2' >>> a.color 'red' >>> a.radius 10.0
Circle¶
-
class
pydy.viz.shapes.
Circle
(radius=10.0, **kwargs)[source]¶ Instantiates a circle with a given radius.
Parameters: radius : float or SymPy Expression
The radius of the circle.
Examples
>>> from pydy.viz.shapes import Circle >>> s = Circle(10.0) >>> s.name 'unnamed' >>> s.color 'grey' >>>s.radius 10.0 >>> s.name = 'my-shape1' >>> s.name 'my-shape1' >>> s.color = 'blue' >>> s.color 'blue' >>> s.radius = 12.0 >>> s.radius 12.0 >>> a = Circle(10.0, name='my-shape2', color='red') >>> a.name 'my-shape2' >>> a.color 'red' >>> a.radius 10.0
Plane¶
-
class
pydy.viz.shapes.
Plane
(length=10.0, width=5.0, **kwargs)[source]¶ Instantiates a plane with a given length and width.
Parameters: length : float or SymPy expression
The length of the plane.
width : float or SymPy expression
The width of the plane.
Examples
>>> from pydy.viz.shapes import Plane >>> s = Plane(10.0, 5.0) >>> s.name 'unnamed' >>> s.color 'grey' >>> s.length 10.0 >>> s.width 5.0 >>> s.name = 'my-shape1' >>> s.name 'my-shape1' >>> s.color = 'blue' >>> s.color 'blue' >>> s.length = 12.0 >>> s.length 12.0 >>> s.width = 6.0 >>> s.width 6.0 >>> a = Plane(10.0, 5.0, name='my-shape2', color='red') >>> a.name 'my-shape2' >>> a.color 'red' >>> a.length 10.0 >>> a.width 5.0
Tetrahedron¶
-
class
pydy.viz.shapes.
Tetrahedron
(radius=10.0, **kwargs)[source]¶ Instantiates a Tetrahedron inscribed in a given radius circle.
Parameters: radius : float or SymPy expression
The radius of the circum-scribing sphere of around the tetrahedron.
Examples
>>> from pydy.viz.shapes import Tetrahedron >>> s = Tetrahedron(10.0) >>> s.name 'unnamed' >>> s.color 'grey' >>>s.radius 10.0 >>> s.name = 'my-shape1' >>> s.name 'my-shape1' >>> s.color = 'blue' >>> s.color 'blue' >>> s.radius = 12.0 >>> s.radius 12.0 >>> a = Tetrahedron(10.0, name='my-shape2', color='red') >>> a.name 'my-shape2' >>> a.color 'red' >>> a.radius 10.0
Octahedron¶
-
class
pydy.viz.shapes.
Tetrahedron
(radius=10.0, **kwargs)[source] Instantiates a Tetrahedron inscribed in a given radius circle.
Parameters: radius : float or SymPy expression
The radius of the circum-scribing sphere of around the tetrahedron.
Examples
>>> from pydy.viz.shapes import Tetrahedron >>> s = Tetrahedron(10.0) >>> s.name 'unnamed' >>> s.color 'grey' >>>s.radius 10.0 >>> s.name = 'my-shape1' >>> s.name 'my-shape1' >>> s.color = 'blue' >>> s.color 'blue' >>> s.radius = 12.0 >>> s.radius 12.0 >>> a = Tetrahedron(10.0, name='my-shape2', color='red') >>> a.name 'my-shape2' >>> a.color 'red' >>> a.radius 10.0
Icosahedron¶
-
class
pydy.viz.shapes.
Icosahedron
(radius=10.0, **kwargs)[source]¶ Instantiates an icosahedron inscribed in a sphere of the given radius.
Parameters: radius : float or a SymPy expression
Radius of the circum-scribing sphere for Icosahedron
Examples
>>> from pydy.viz.shapes import Icosahedron >>> s = Icosahedron(10) >>> s.name 'unnamed' >>> s.color 'grey' >>>s.radius 10.0 >>>#These can be changed later too .. >>> s.name = 'my-shape1' >>> s.name 'my-shape1' >>> s.color = 'blue' >>> s.color 'blue' >>> s.radius = 12.0 >>> s.radius 12 >>> a = Icosahedron(10.0, name='my-shape2', color='red') >>> a.name 'my-shape2' >>> a.color 'red' >>> a.radius 10.0
Torus¶
-
class
pydy.viz.shapes.
Torus
(radius, tube_radius, **kwargs)[source]¶ Instantiates a torus with a given radius and section radius.
Parameters: radius : float or SymPy expression
The radius of the torus.
tube_radius : float or SymPy expression
The radius of the torus tube.
Examples
>>> from pydy.viz.shapes import Torus >>> s = Torus(10.0, 5.0) >>> s.name 'unnamed' >>> s.color 'grey' >>> s.radius 10.0 >>> s.tube_radius 5.0 >>> s.name = 'my-shape1' >>> s.name 'my-shape1' >>> s.color = 'blue' >>> s.color 'blue' >>> s.radius = 12.0 >>> s.radius 12.0 >>> s.tube_radius = 6.0 >>> s.tube_radius 6.0 >>> a = Torus(10.0, 5.0, name='my-shape2', color='red') >>> a.name 'my-shape2' >>> a.color 'red' >>> a.radius 10.0 >>> a.tube_radius 5.0
TorusKnot¶
-
class
pydy.viz.shapes.
TorusKnot
(radius, tube_radius, **kwargs)[source]¶ Instantiates a torus knot with given radius and section radius.
Parameters: radius : float or SymPy expression
The radius of the torus knot.
tube_radius : float or SymPy expression
The radius of the torus knot tube.
Examples
>>> from pydy.viz.shapes import TorusKnot >>> s = TorusKnot(10.0, 5.0) >>> s.name 'unnamed' >>> s.color 'grey' >>> s.radius 10.0 >>> s.tube_radius 5.0 >>> s.name = 'my-shape1' >>> s.name 'my-shape1' >>> s.color = 'blue' >>> s.color 'blue' >>> s.radius = 12.0 >>> s.radius 12.0 >>> s.tube_radius = 6.0 >>> s.tube_radius 6.0 >>> a = TorusKnot(10.0, 5.0, name='my-shape2', color='red') >>> a.name 'my-shape2' >>> a.color 'red' >>> a.radius 10.0 >>> a.tube_radius 5.0
Tube¶
-
class
pydy.viz.shapes.
Tube
(radius, points, **kwargs)[source]¶ Instantiates a tube that sweeps along a path.
Parameters: radius : float or SymPy expression
The radius of the tube.
points : array_like, shape(n, 3)
An array of n (x, y, z) coordinates representing points that the tube’s center line should follow.
Examples
>>> from pydy.viz.shapes import Tube >>> points = [[1.0, 2.0, 1.0], [2.0, 1.0, 1.0], [2.0, 3.0, 4.0]] >>> s = Tube(10.0, points) >>> s.name 'unnamed' >>> s.color 'grey' >>> s.points [[1.0, 2.0, 1.0], [2.0, 1.0, 1.0], [2.0, 3.0, 4.0]] >>> s.name = 'my-shape1' >>> s.name 'my-shape1' >>> s.color = 'blue' >>> s.color 'blue' >>> s.radius = 14.0 >>> s.radius 14.0 >>> s.points = [[2.0, 1.0, 4.0], [1.0, 2.0, 4.0], ... [2.0, 3.0, 1.0], [1.0, 1.0, 3.0]] >>> s.points [[2.0, 1.0, 4.0], [1.0, 2.0, 4.0], [2.0, 3.0, 1.0], [1.0, 1.0, 3.0]] >>> a = Tube(12.0, points, name='my-shape2', color='red') >>> a.name 'my-shape2' >>> a.color 'red' >>> a.radius 12.0 >>> a.points [[1.0, 2.0, 1.0], [2.0, 1.0, 1.0], [2.0, 3.0, 4.0]]