Frameworks¶
Module for the functionality concerning frameworks.
- class pyrigi.framework.framework.Framework(graph, realization)[source]¶
Bases:
FrameworkBaseThis class provides the functionality for frameworks.
Definitions
- Parameters:
graph (
Graph) – A graph without loops.realization (
dict[Vertex,Point]) – A dictionary mapping the vertices of the graph to points in \(\RR^d\). The dimension \(d\) is retrieved from the points in realization. Ifgraphis empty, and hence also therealization, the dimension is set to 0 (Empty()can be used to construct an empty framework with different dimension).
Examples
>>> F = Framework(Graph([[0,1]]), {0:[1,2], 1:[0,5]}) >>> print(F) Framework in 2-dimensional space consisting of: Graph with vertices [0, 1] and edges [[0, 1]] Realization {0:(1, 2), 1:(0, 5)}
Notice that the realization of a vertex can be accessed using
[ ]:>>> F[0] Matrix([ [1], [2]])
Methods
Attribute getters
Return the dimension of the framework.
Return a copy of the underlying graph.
realization([as_points, numerical])Return a copy of the realization.
Framework properties
is_congruent(other_framework[, numerical, ...])Return whether the given framework is congruent to the framework.
is_congruent_realization(other_realization)Return whether the given realization is congruent to the framework.
is_equivalent(other_framework[, numerical, ...])Return whether the given framework is equivalent to the framework.
is_equivalent_realization(other_realization)Return whether the given realization is equivalent to the framework.
is_injective([numerical, tolerance])Return whether the realization is injective.
is_quasi_injective([numerical, tolerance])Return whether the realization is quasi-injective.
Class methods
Circular(graph)Return the framework with a regular unit circle realization in the plane.
Collinear(graph[, dim])Return the framework with a realization on the x-axis.
Complete(points)Generate a framework on the complete graph from a given list of points.
Empty([dim])Generate an empty framework.
Random(graph[, dim, rand_range, numerical])Return a framework with random realization.
Simplicial(graph[, dim])Return the framework with a realization on the
dim-simplex.from_points(points)Generate a framework from a list of points.
Framework manipulation
add_edge(edge)Add an edge to the framework.
add_edges(edges)Add a list of edges to the framework.
add_vertex(point[, vertex])Add a vertex to the framework with the corresponding coordinates.
add_vertices(points[, vertices])Add a list of vertices to the framework.
delete_edge(edge)Delete an edge from the framework.
delete_edges(edges)Delete a list of edges from the framework.
delete_vertex(vertex)Delete a vertex from the framework.
delete_vertices(vertices)Delete a list of vertices from the framework.
projected_realization([proj_dim, ...])Return the realization projected to a lower dimension and the projection matrix.
rescale(factor[, inplace])Scale the framework.
rotate(**kwargs)Alias for rotating frameworks based on
rotate2D()androtate3D().rotate2D(angle[, rotation_center, inplace])Rotate the planar framework counterclockwise.
rotate3D(angle[, axis_direction, ...])Rotate the spatial framework counterclockwise around a specified rotation axis.
set_realization(realization)Change the realization of the framework.
set_vertex_pos(vertex, point)Change the coordinates of a single given vertex.
set_vertex_positions(subset_of_realization)Change the coordinates of vertices given by a dictionary.
set_vertex_positions_from_lists(vertices, points)Change the coordinates of a given list of vertices.
translate(vector[, inplace])Translate the framework.
Infinitesimal rigidity
inf_flexes([include_trivial, vertex_order, ...])Return a basis of the space of infinitesimal flexes.
is_dependent(**kwargs)Return whether the framework is dependent.
is_dict_inf_flex(vert_to_flex, **kwargs)Return whether a dictionary specifies an infinitesimal flex of the framework.
is_dict_nontrivial_inf_flex(vert_to_flex, ...)Return whether a dictionary specifies an infinitesimal flex which is nontrivial.
is_dict_stress(dict_stress, **kwargs)Return whether a dictionary specifies an equilibrium stress of the framework.
is_dict_trivial_inf_flex(inf_flex, **kwargs)Return whether an infinitesimal flex specified by a dictionary is trivial.
is_independent(**kwargs)Return whether the framework is independent.
is_inf_flexible(**kwargs)Return whether the framework is infinitesimally flexible.
is_inf_rigid([numerical, tolerance])Return whether the framework is infinitesimally rigid.
is_isostatic(**kwargs)Return whether the framework is isostatic.
is_min_inf_rigid([use_copy])Return whether the framework is minimally infinitesimally rigid.
is_nontrivial_flex(inf_flex, **kwargs)Alias for
is_vector_nontrivial_inf_flex()andis_dict_nontrivial_inf_flex().is_redundantly_inf_rigid([use_copy])Return if the framework is infinitesimally redundantly rigid.
is_stress(stress, **kwargs)Alias for
is_vector_stress()andis_dict_stress().is_trivial_flex(inf_flex, **kwargs)Alias for
is_vector_trivial_inf_flex()andis_dict_trivial_inf_flex().is_vector_inf_flex(inf_flex[, vertex_order, ...])Return whether a vector is an infinitesimal flex of the framework.
is_vector_nontrivial_inf_flex(inf_flex[, ...])Return whether an infinitesimal flex is nontrivial.
is_vector_stress(stress[, edge_order, ...])Return whether a vector is an equilibrium stress.
is_vector_trivial_inf_flex(inf_flex, **kwargs)Return whether an infinitesimal flex is trivial.
nontrivial_inf_flexes(**kwargs)Return non-trivial infinitesimal flexes.
rigidity_matrix([vertex_order, edge_order])Construct the rigidity matrix of the framework.
rigidity_matrix_rank([numerical, tolerance])Return the rank of the rigidity matrix.
stress_matrix(stress[, edge_order, vertex_order])Construct the stress matrix of a stress.
stress_matrix_rank(stress[, edge_order, ...])Return the rank of the stress matrix for a given stress.
stresses([edge_order, numerical, tolerance])Return a basis of the space of equilibrium stresses.
trivial_inf_flexes([vertex_order])Return a basis of the vector subspace of trivial infinitesimal flexes.
Plotting
animate3D_rotation([plot_style, ...])Plot this framework in 3D and animate a rotation around an axis.
plot([plot_style])Plot the framework.
plot2D([plot_style, projection_matrix, ...])Plot the framework in 2D.
plot3D([plot_style, projection_matrix, ...])Plot the provided framework in 3D.
Other
edge_lengths([numerical])Return the dictionary of the edge lengths.
generate_stl_bars([scale, width_of_bars, ...])Generate STL files for the bars of the framework.
is_prestress_stable([numerical, tolerance, ...])Return whether the framework is prestress stable.
is_second_order_rigid([numerical, ...])Return whether the framework is second-order rigid.
to_tikz([vertex_style, edge_style, ...])Create a TikZ code for the framework.
Notes
Internally, the realization is represented as
dict[Vertex,Matrix]. However,realization()can also returndict[Vertex,Point].- classmethod Circular(graph)[source]¶
Return the framework with a regular unit circle realization in the plane.
- Parameters:
graph (
Graph) – Underlying graph on which the framework is constructed.- Return type:
Examples
>>> import pyrigi.graphDB as graphs >>> F = Framework.Circular(graphs.CompleteBipartite(4, 2)) >>> print(F) Framework in 2-dimensional space consisting of: Graph with vertices [0, 1, 2, 3, 4, 5] and edges ... Realization {0:(1, 0), 1:(1/2, sqrt(3)/2), ...
- classmethod Collinear(graph, dim=1)[source]¶
Return the framework with a realization on the x-axis.
- Parameters:
- Return type:
Examples
>>> import pyrigi.graphDB as graphs >>> print(Framework.Collinear(graphs.Complete(3), dim=2)) Framework in 2-dimensional space consisting of: Graph with vertices [0, 1, 2] and edges [[0, 1], [0, 2], [1, 2]] Realization {0:(0, 0), 1:(1, 0), 2:(2, 0)}
- classmethod Complete(points)[source]¶
Generate a framework on the complete graph from a given list of points.
The vertices of the underlying graph are taken to be the list
[0,...,len(points)-1].- Parameters:
points (
Sequence[Point]) – The realization of the framework that this method outputs is provided as a list of points.- Return type:
Examples
>>> F = Framework.Complete([(1,),(2,),(3,),(4,)]); print(F) Framework in 1-dimensional space consisting of: Graph with vertices [0, 1, 2, 3] and edges [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3]] Realization {0:(1,), 1:(2,), 2:(3,), 3:(4,)}
- classmethod Empty(dim=2)¶
Generate an empty framework.
- Parameters:
dim (
int) – A natural number that determines the dimension in which the framework is realized.- Return type:
Examples
>>> F = Framework.Empty(dim=1); print(F) Framework in 1-dimensional space consisting of: Graph with vertices [] and edges [] Realization {}
- classmethod Random(graph, dim=2, rand_range=None, numerical=False)[source]¶
Return a framework with random realization.
Depending on the parameter
numerical, the realization either consists of random integers (numerical=False) or random floats (numerical=True).- Parameters:
dim (
int) – The dimension of the constructed framework.graph (
Graph) – Graph for which the random realization should be constructed.rand_range (
int|Sequence[int]) – Sets the range of random numbers from which the realization is sampled. The format is either an interval(a,b)or a single integera, which produces the range(-a,a). Ifrand_range=None, then the range is set to(-a,a)fora = 10^4 * n * dimin the case thatnumerical=False, wherenis the number of vertices. Fornumerical=True, we set the default interval to(-1,1).numerical (
bool) – A boolean indicating whether numerical coordinates should be used.
- Return type:
Examples
>>> F = Framework.Random(Graph([(0,1), (1,2), (0,2)])) >>> print(F) Framework in 2-dimensional space consisting of: Graph with vertices [0, 1, 2] and edges [[0, 1], [0, 2], [1, 2]] Realization {0:(122, 57), 1:(27, 144), 2:(50, 98)}
- classmethod Simplicial(graph, dim=None)[source]¶
Return the framework with a realization on the
dim-simplex.- Parameters:
- Return type:
Examples
>>> F = Framework.Simplicial(Graph([(0,1), (1,2), (2,3), (0,3)]), 4) >>> F.realization(as_points=True) {0: [0, 0, 0, 0], 1: [1, 0, 0, 0], 2: [0, 1, 0, 0], 3: [0, 0, 1, 0]} >>> F = Framework.Simplicial(Graph([(0,1), (1,2), (2,3), (0,3)])) >>> F.realization(as_points=True) {0: [0, 0, 0], 1: [1, 0, 0], 2: [0, 1, 0], 3: [0, 0, 1]}
- __getitem__(vertex)¶
Return the coordinates of a given vertex in the realization.
- Parameters:
vertex (
Vertex)- Return type:
Examples
>>> F = Framework(Graph([[0,1]]), {0:[1,2], 1:[0,5]}) >>> F[0] Matrix([ [1], [2]])
- add_edge(edge)¶
Add an edge to the framework.
Notes
This method only alters the graph attribute.
- add_edges(edges)¶
Add a list of edges to the framework.
Notes
For each edge that has to be added,
add_edge()is called.
- add_vertex(point, vertex=None)¶
Add a vertex to the framework with the corresponding coordinates.
If no vertex is provided (
None), then an integer is chosen instead.- Parameters:
- Return type:
Examples
>>> F = Framework.Empty(dim=2) >>> F.add_vertex((1.5,2), 'a') >>> F.add_vertex((3,1)) >>> print(F) Framework in 2-dimensional space consisting of: Graph with vertices ['a', 1] and edges [] Realization {a:(1.50000000000000, 2), 1:(3, 1)}
- add_vertices(points, vertices=None)¶
Add a list of vertices to the framework.
- Parameters:
points (
Sequence[Point]) – List of points consisting of coordinates in \(\RR^d\). It is checked that all points lie in the same ambient space.vertices (
Sequence[Vertex]) – List of vertices. If the list of vertices is empty, we generate vertices with the methodadd_vertex(). Otherwise, the list of vertices needs to have the same length as the list of points.
- Return type:
Examples
>>> F = Framework.Empty(dim=2) >>> F.add_vertices([(1.5,2), (3,1)], ['a',0]) >>> print(F) Framework in 2-dimensional space consisting of: Graph with vertices ['a', 0] and edges [] Realization {a:(1.50000000000000, 2), 0:(3, 1)}
Notes
For each vertex that has to be added,
add_vertex()is called.
- animate3D_rotation(plot_style=None, vertex_colors_custom=None, edge_colors_custom=None, total_frames=100, delay=75, rotation_axis=None, **kwargs)[source]¶
Plot this framework in 3D and animate a rotation around an axis.
For additional parameters and implementation details, see
animate3D().- Parameters:
plot_style (
PlotStyle) – An instance of thePlotStyleclass that defines the visual style for plotting, seePlotStylefor more details.vertex_colors_custom (
Sequence[Sequence[Vertex]] |dict[str,Sequence[Vertex]]) – Optional parameter to specify the colors of vertices. It can be aSequence[Sequence[Vertex]]to define groups of vertices with the same color or adict[str, Sequence[Vertex]]where the keys are color strings and the values are lists of vertices. The omitted vertices are given the valueplot_style.vertex_color.edge_colors_custom (
Sequence[Sequence[Edge]] |dict[str,Sequence[Edge]]) – Optional parameter to specify the colors of edges. It can be aSequence[Sequence[Edge]]to define groups of edges with the same color or adict[str, Sequence[Edge]]where the keys are color strings and the values are lists of edges. The omitted edges are given the valueplot_style.edge_color.total_frames (
int) – Total number of frames for the animation sequence.delay (
int) – Delay between frames in milliseconds.rotation_axis (
str|Sequence[Number]) – The user can input a rotation axis or vector. By default, a rotation around the z-axis is performed. This can either a character ('x','y', or'z') or a vector (e.g.[1, 0, 0]).
- Return type:
Examples
>>> from pyrigi import frameworkDB >>> F = frameworkDB.Complete(4, dim=3) >>> F.animate3D_rotation()
- delete_edges(edges)¶
Delete a list of edges from the framework.
- delete_vertex(vertex)¶
Delete a vertex from the framework.
- delete_vertices(vertices)¶
Delete a list of vertices from the framework.
- edge_lengths(numerical=False)[source]¶
Return the dictionary of the edge lengths.
- Parameters:
numerical (
bool) – IfTrue, numerical positions are used for the computation of the edge lengths.- Return type:
Examples
>>> G = Graph([(0,1), (1,2), (2,3), (0,3)]) >>> F = Framework(G, {0:[0,0], 1:[1,0], 2:[1,'1/2 * sqrt(5)'], 3:['1/2','4/3']}) >>> F.edge_lengths(numerical=False) {(0, 1): 1, (0, 3): sqrt(73)/6, (1, 2): sqrt(5)/2, (2, 3): sqrt((-4/3 + sqrt(5)/2)**2 + 1/4)} >>> F.edge_lengths(numerical=True) {(0, 1): 1.0, (0, 3): 1.4240006242195884, (1, 2): 1.118033988749895, (2, 3): 0.5443838790578374}
- classmethod from_points(points)[source]¶
Generate a framework from a list of points.
The list of vertices of the underlying graph is taken to be
[0,...,len(points)-1]. The underlying graph has no edges.- Parameters:
points (
Sequence[Point]) – The realization of the framework that this method outputs is provided as a list of points.- Return type:
Examples
>>> F = Framework.from_points([(1,2), (2,3)]) >>> print(F) Framework in 2-dimensional space consisting of: Graph with vertices [0, 1] and edges [] Realization {0:(1, 2), 1:(2, 3)}
- generate_stl_bars(scale=1.0, width_of_bars=8.0, height_of_bars=3.0, holes_diameter=4.3, filename_prefix='bar_', output_dir='stl_output')[source]¶
Generate STL files for the bars of the framework.
The STL files are generated in the working folder. The naming convention for the files is
bar_i-j.stl, whereiandjare the vertices of an edge.- Parameters:
scale (
float) – Scale factor for the lengths of the edges, default is 1.0.width_of_bars (
float) – Width of the bars, default is 8.0 mm.height_of_bars (
float) – Height of the bars, default is 3.0 mm.holes_diameter (
float) – Diameter of the holes at the ends of the bars, default is 4.3 mm.filename_prefix (
str) – Prefix for the filenames of the generated STL files, default isbar_.output_dir (
str) – Name or path of the folder where the STL files are saved, default isstl_output. Relative to the working directory.
- Return type:
Examples
>>> G = Graph([(0,1), (1,2), (2,3), (0,3)]) >>> F = Framework(G, {0:[0,0], 1:[1,0], 2:[1,'1/2 * sqrt(5)'], 3:[1/2,'4/3']}) >>> F.generate_stl_bars(scale=20) STL files for the bars have been generated in the folder `stl_output`.
- property graph: Graph¶
Return a copy of the underlying graph.
Examples
>>> F = Framework.Random(Graph([(0,1), (1,2), (0,2)])) >>> print(F.graph) Graph with vertices [0, 1, 2] and edges [[0, 1], [0, 2], [1, 2]]
- inf_flexes(include_trivial=False, vertex_order=None, numerical=False, tolerance=1e-09, fixed_vertices=[])[source]¶
Return a basis of the space of infinitesimal flexes.
Return a lift of a basis of the quotient of the vector space of infinitesimal flexes modulo trivial infinitesimal flexes, if
include_trivial=False. Return a basis of the vector space of infinitesimal flexes ifinclude_trivial=True.Definitions
- Parameters:
include_trivial (
bool) – Boolean that decides, whether the trivial flexes should be included.vertex_order (
Sequence[Vertex]) – A list of vertices, providing the ordering for the entries of the infinitesimal flexes. If none is provided, the list fromGraph.vertex_list()is taken.numerical (
bool) – Determines whether the output is symbolic (default) or numerical.tolerance (
float) – Used tolerance when computing the infinitesimal flex numerically.fixed_vertices (
Sequence[Vertex]) – Fixed vertices are assigned a flex of length 0. The default value is an empty list. They can be provided as a sequence of vertices.
- Return type:
list[MutableDenseMatrix] |list[list[float]]
Examples
>>> F = Framework.Complete([[0,0], [1,0], [1,1], [0,1]]) >>> F.delete_edges([(0,2), (1,3)]) >>> F.inf_flexes(include_trivial=False) [Matrix([ [1], [0], [1], [0], [0], [0], [0], [0]])] >>> F = Framework( ... Graph([[0, 1], [0, 3], [0, 4], [1, 3], [1, 4], [2, 3], [2, 4]]), ... {0: [0, 0], 1: [0, 1], 2: [0, 2], 3: [1, 2], 4: [-1, 2]}, ... ) >>> F.inf_flexes() [Matrix([ [0], [0], [0], [0], [0], [1], [0], [0], [0], [0]])]
- is_congruent(other_framework, numerical=False, tolerance=1e-09)[source]¶
Return whether the given framework is congruent to the framework.
Definitions
- is_congruent_realization(other_realization, numerical=False, tolerance=1e-09)[source]¶
Return whether the given realization is congruent to the framework.
Definitions
- is_dependent(**kwargs)[source]¶
Return whether the framework is dependent.
See also
is_independent().- Return type:
Definitions
- is_dict_inf_flex(vert_to_flex, **kwargs)[source]¶
Return whether a dictionary specifies an infinitesimal flex of the framework.
Definitions
- Parameters:
vert_to_flex (
dict[Vertex,Sequence[Number]]) – Dictionary that maps the vertex labels to vectors of the same dimension as the framework is.- Return type:
Examples
>>> F = Framework.Complete([[0,0], [1,1]]) >>> F.is_dict_inf_flex({0:[0,0], 1:[-1,1]}) True >>> F.is_dict_inf_flex({0:[0,0], 1:["sqrt(2)","-sqrt(2)"]}) True
Notes
See
is_vector_inf_flex().
- is_dict_nontrivial_inf_flex(vert_to_flex, **kwargs)[source]¶
Return whether a dictionary specifies an infinitesimal flex which is nontrivial.
See
is_vector_nontrivial_inf_flex()for details, particularly concerning the possible parameters.Definitions
- Parameters:
vert_to_flex (
dict[Vertex,Sequence[Number]]) – An infinitesimal flex of the framework in the form of a dictionary.- Return type:
Examples
>>> from pyrigi import frameworkDB as fws >>> F = fws.Square() >>> q = {0:[0,0], 1: [0,0], 2:[-2,0], 3:[-2,0]} >>> F.is_dict_nontrivial_inf_flex(q) True >>> q = {0:[1,-1], 1: [1,1], 2:[-1,1], 3:[-1,-1]} >>> F.is_dict_nontrivial_inf_flex(q) False
- is_dict_stress(dict_stress, **kwargs)[source]¶
Return whether a dictionary specifies an equilibrium stress of the framework.
Definitions
- Parameters:
dict_stress (
dict[Edge,Number]) – Dictionary that maps the edges to stress values.- Return type:
Examples
>>> F = Framework.Complete([[0,0], [1,0], ['1/2',0]]) >>> F.is_dict_stress({(0,1):'-1/2', (0,2):1, (1,2):1}) True >>> F.is_dict_stress({(0,1):1, (1,2):'-1/2', (0,2):1}) False
Notes
See
is_vector_stress().
- is_dict_trivial_inf_flex(inf_flex, **kwargs)[source]¶
Return whether an infinitesimal flex specified by a dictionary is trivial.
See
is_vector_trivial_inf_flex()for details, particularly concerning the possible parameters.Definitions
- Parameters:
inf_flex (
dict[Vertex,Sequence[Number]]) – An infinitesimal flex of the framework in the form of a dictionary.- Return type:
Examples
>>> from pyrigi import frameworkDB as fws >>> F = fws.Square() >>> q = {0:[0,0], 1: [0,0], 2:[-2,0], 3:[-2,0]} >>> F.is_dict_trivial_inf_flex(q) False >>> q = {0:[1,-1], 1: [1,1], 2:[-1,1], 3:[-1,-1]} >>> F.is_dict_trivial_inf_flex(q) True
- is_equivalent(other_framework, numerical=False, tolerance=1e-09)[source]¶
Return whether the given framework is equivalent to the framework.
Definitions
- is_equivalent_realization(other_realization, numerical=False, tolerance=1e-09)[source]¶
Return whether the given realization is equivalent to the framework.
Definitions
- is_independent(**kwargs)[source]¶
Return whether the framework is independent.
For implementation details and possible parameters, see
rigidity_matrix_rank().- Return type:
Definitions
Examples
>>> F = Framework.Complete([[0,0], [1,0], [1,1], [0,1]]) >>> F.is_independent() False >>> F.delete_edge((0,2)) >>> F.is_independent() True
- is_inf_flexible(**kwargs)[source]¶
Return whether the framework is infinitesimally flexible.
For implementation details and possible parameters, see
is_inf_rigid().- Return type:
Definitions
- is_inf_rigid(numerical=False, tolerance=1e-09)[source]¶
Return whether the framework is infinitesimally rigid.
Definitions
- Parameters:
numerical (
bool) –If
True, the rigidity matrix rank computation for determining rigidity is numerical.Warning: For
numerical=Truethe numerical rank computation may produce different results than the computation over symbolic coordinates.tolerance (
float) – Numerical tolerance used for computing the rigidity matrix rank.
- Return type:
Examples
>>> from pyrigi import frameworkDB >>> F1 = frameworkDB.CompleteBipartite(4,4) >>> F1.is_inf_rigid() True >>> F2 = frameworkDB.Cycle(4,dim=2) >>> F2.is_inf_rigid() False
- is_injective(numerical=False, tolerance=1e-09)[source]¶
Return whether the realization is injective.
- Parameters:
- Return type:
Notes
For comparing whether two vectors are the same,
misc.is_zero_vector()is used. See its documentation for the description of the parameters.
- is_isostatic(**kwargs)[source]¶
Return whether the framework is isostatic.
For implementation details and possible parameters, see
is_independent()andis_inf_rigid().- Return type:
Definitions
- is_min_inf_rigid(use_copy=True, **kwargs)[source]¶
Return whether the framework is minimally infinitesimally rigid.
For implementation details and possible parameters, see
is_inf_rigid().Definitions
Minimal infinitesimal rigidity
- Parameters:
use_copy (
bool) – IfFalse, the framework’s edges are deleted and added back during runtime. Otherwise, a new modified framework is created, while the original framework remains unchanged (default).- Return type:
Examples
>>> F = Framework.Complete([[0,0], [1,0], [1,1], [0,1]]) >>> F.is_min_inf_rigid() False >>> F.delete_edge((0,2)) >>> F.is_min_inf_rigid() True
- is_nontrivial_flex(inf_flex, **kwargs)[source]¶
Alias for
is_vector_nontrivial_inf_flex()andis_dict_nontrivial_inf_flex().It is distinguished between instances of
listand instances ofdictto call one of the alias methods.Definitions
- is_prestress_stable(numerical=False, tolerance=1e-09, inf_flexes=None, stresses=None)[source]¶
Return whether the framework is prestress stable.
See also
is_second_order_rigid().Definitions
- Parameters:
numerical (
bool) – IfTrue, numerical infinitesimal flexes and stresses are used in the check for prestress stability. In case thatnumerical=False, this method only properly works for symbolic coordinates.tolerance (
float) – Numerical tolerance used for the check that something is an approximate zero.inf_flexes (
Sequence[InfFlex]) – Precomputed infinitesimal flexes and equilibrium stresses can be provided to avoid recomputation. If not provided, they are computed here.stresses (
Sequence[Stress]) – Precomputed infinitesimal flexes and equilibrium stresses can be provided to avoid recomputation. If not provided, they are computed here.
- Return type:
Examples
>>> from pyrigi import frameworkDB as fws >>> F = fws.Frustum(3) >>> F.is_prestress_stable() True
- is_quasi_injective(numerical=False, tolerance=1e-09)[source]¶
Return whether the realization is quasi-injective.
Definitions
- Parameters:
- Return type:
Notes
For comparing whether two vectors are the same,
misc.is_zero_vector()is used. See its documentation for the description of the parameters.
- is_redundantly_inf_rigid(use_copy=True, **kwargs)[source]¶
Return if the framework is infinitesimally redundantly rigid.
For implementation details and possible parameters, see
is_inf_rigid().Definitions
Redundant infinitesimal rigidity
- Parameters:
use_copy (
bool) – IfFalse, the framework’s edges are deleted and added back during runtime. Otherwise, a new modified framework is created, while the original framework remains unchanged (default).- Return type:
Examples
>>> F = Framework.Empty(dim=2) >>> F.add_vertices([(1,0), (1,1), (0,3), (-1,1)], ['a','b','c','d']) >>> F.add_edges([('a','b'), ('b','c'), ('c','d'), ('a','d'), ('a','c'), ('b','d')]) >>> F.is_redundantly_inf_rigid() True >>> F.delete_edge(('a','c')) >>> F.is_redundantly_inf_rigid() False
- is_second_order_rigid(numerical=False, tolerance=1e-09, inf_flexes=None, stresses=None)[source]¶
Return whether the framework is second-order rigid.
Checking second-order-rigidity for a general framework is computationally hard. If there is only one stress or only one infinitesimal flex, second-order rigidity is identical to prestress stability, so we can apply
is_prestress_stable(). See also Theorem 33.Definitions
- Parameters:
numerical (
bool) – IfTrue, numerical infinitesimal flexes and stresses are used in the check for prestress stability. In case thatnumerical=False, this method only properly works for symbolic coordinates.tolerance (
float) – Numerical tolerance used for the check that something is an approximate zero.inf_flexes (
Sequence[InfFlex]) – Precomputed infinitesimal flexes and equilibrium stresses can be provided to avoid recomputation. If not provided, they are computed here.stresses (
Sequence[Stress]) – Precomputed infinitesimal flexes and equilibrium stresses can be provided to avoid recomputation. If not provided, they are computed here.
- Return type:
Examples
>>> from pyrigi import frameworkDB as fws >>> F = fws.Frustum(3) >>> F.is_second_order_rigid() True
- is_stress(stress, **kwargs)[source]¶
Alias for
is_vector_stress()andis_dict_stress().One of the alias methods is called depending on the type of the input.
- is_trivial_flex(inf_flex, **kwargs)[source]¶
Alias for
is_vector_trivial_inf_flex()andis_dict_trivial_inf_flex().Ii is distinguished between instances of
listand instances ofdictto call one of the alias methods.Definitions
- is_vector_inf_flex(inf_flex, vertex_order=None, numerical=False, tolerance=1e-09)[source]¶
Return whether a vector is an infinitesimal flex of the framework.
Definitions
- Parameters:
inf_flex (
Sequence[Number]) – An infinitesimal flex of the framework specified by a vector.vertex_order (
Sequence[Vertex]) – A list of vertices specifying the order in whichinf_flexis given. If none is provided, the list fromvertex_list()is taken.numerical (
bool) – A Boolean determining whether the evaluation of the product of theinf_flexand the rigidity matrix is symbolic or numerical.tolerance (
float) – Absolute tolerance that is the threshold for acceptable numerical flexes. This parameter is used to determine the number of digits, to which accuracy the symbolic expressions are evaluated.
- Return type:
Examples
>>> from pyrigi import frameworkDB as fws >>> F = fws.Square() >>> q = [0,0,0,0,-2,0,-2,0] >>> F.is_vector_inf_flex(q) True >>> q[0] = 1 >>> F.is_vector_inf_flex(q) False >>> F = Framework.Complete([[0,0], [1,1]]) >>> F.is_vector_inf_flex(["sqrt(2)","-sqrt(2)",0,0], vertex_order=[1,0]) True
- is_vector_nontrivial_inf_flex(inf_flex, vertex_order=None, numerical=False, tolerance=1e-09)[source]¶
Return whether an infinitesimal flex is nontrivial.
Definitions
- Parameters:
inf_flex (
Sequence[Number]) – An infinitesimal flex of the framework.vertex_order (
Sequence[Vertex]) – A list of vertices specifying the order in whichinf_flexis given. If none is provided, the list fromGraph.vertex_list()is taken.numerical (
bool) – A Boolean determining whether the evaluation of the product of the inf_flex and the rigidity matrix is symbolic or numerical.tolerance (
float) – Absolute tolerance that is the threshold for acceptable numerical flexes. This parameter is used to determine the number of digits, to which accuracy the symbolic expressions are evaluated.
- Return type:
Examples
>>> from pyrigi import frameworkDB as fws >>> F = fws.Square() >>> q = [0,0,0,0,-2,0,-2,0] >>> F.is_vector_nontrivial_inf_flex(q) True >>> q = [1,-1,1,1,-1,1,-1,-1] >>> F.is_vector_inf_flex(q) True >>> F.is_vector_nontrivial_inf_flex(q) False
Notes
This is done by solving a linear system composed of a matrix \(A\) whose columns are given by a basis of the trivial flexes and the vector \(b\) given by the input flex. \(b\) is trivial if and only if there is a linear combination of the columns in \(A\) producing \(b\). In other words, when there is a solution to \(Ax=b\), then \(b\) is a trivial infinitesimal motion. Otherwise, \(b\) is nontrivial.
In the
numerical=Truecase we compute a least squares solution \(x\) of the overdetermined linear system and compare the values in \(Ax\) to the values in \(b\).
- is_vector_stress(stress, edge_order=None, numerical=False, tolerance=1e-09)[source]¶
Return whether a vector is an equilibrium stress.
Definitions
- Parameters:
stress (
Sequence[Number]) – A vector to be checked whether it is a stress of the framework.edge_order (
Sequence[Edge]) – A list of edges, providing the ordering for the entries of thestress. If none is provided, the list fromGraph.edge_list()is taken.numerical (
bool) – A Boolean determining whether the evaluation of the product of thestressand the rigidity matrix is symbolic or numerical.tolerance – Absolute tolerance that is the threshold for acceptable equilibrium stresses. This parameter is used to determine the number of digits, to which accuracy the symbolic expressions are evaluated.
- Return type:
Examples
>>> G = Graph([[0,1],[0,2],[0,3],[1,2],[2,3],[3,1]]) >>> pos = {0: (0, 0), 1: (0,1), 2: (-1,-1), 3: (1,-1)} >>> F = Framework(G, pos) >>> omega1 = [-8, -4, -4, 2, 2, 1] >>> F.is_stress(omega1) True >>> omega1[0] = 0 >>> F.is_stress(omega1) False >>> from pyrigi import frameworkDB >>> F = frameworkDB.Complete(5, dim=2) >>> stresses=F.stresses() >>> F.is_stress(stresses[0]) True
- is_vector_trivial_inf_flex(inf_flex, **kwargs)[source]¶
Return whether an infinitesimal flex is trivial.
See also
is_nontrivial_vector_inf_flex()for details, particularly concerning the possible parameters.Definitions
Examples
>>> from pyrigi import frameworkDB as fws >>> F = fws.Square() >>> q = [0,0,0,0,-2,0,-2,0] >>> F.is_vector_trivial_inf_flex(q) False >>> q = [1,-1,1,1,-1,1,-1,-1] >>> F.is_vector_trivial_inf_flex(q) True
- nontrivial_inf_flexes(**kwargs)[source]¶
Return non-trivial infinitesimal flexes.
See
inf_flexes()for possible keywords.- Return type:
Definitions
Examples
>>> import pyrigi.graphDB as graphs >>> F = Framework.Circular(graphs.CompleteBipartite(3, 3)) >>> F.nontrivial_inf_flexes() [Matrix([ [ 3/2], [-sqrt(3)/2], [ 1], [ 0], [ 0], [ 0], [ 3/2], [-sqrt(3)/2], [ 1], [ 0], [ 0], [ 0]])]
- plot(plot_style=None, **kwargs)[source]¶
Plot the framework.
The framework can be plotted only if its dimension is less than 3. For plotting a projection of a higher dimensional framework, use
plot2D()orplot3D()instead. For various formatting options, seePlotStyle.
- plot2D(plot_style=None, projection_matrix=None, random_seed=None, coordinates=None, inf_flex=None, stress=None, vertex_colors_custom=None, edge_colors_custom=None, stress_label_positions=None, arc_angles_dict=None, filename=None, dpi=300, fixed_vertices=[], **kwargs)[source]¶
Plot the framework in 2D.
If the framework is in dimensions higher than 2 and
projection_matrixwithcoordinatesareNone, a random projection matrix containing two orthonormal vectors is generated and used for projection into 2D. For various formatting options, seePlotStyle. Onlycoordinatesorprojection_matrixparameter can be used, not both!- Parameters:
plot_style (
PlotStyle) – An instance of thePlotStyleclass that defines the visual style for plotting, seePlotStylefor more details.projection_matrix (
MutableDenseMatrix) – The matrix used for projecting the realization when the dimension is greater than 2. The matrix must have dimensions(2, dim), wheredimis the dimension of the framework. IfNone, a random projection matrix is generated.random_seed (
int) – The random seed used for generating the projection matrix.coordinates (
Sequence[int]) – Indices of two coordinates to which the framework is projected.inf_flex (
Union[int,InfFlex]) – Optional parameter for plotting a given infinitesimal flex. The standard input format is aMatrixthat is the output of e.g. the methodinf_flexes(). Alternatively, anintcan be specified to directly choose the 0,1,2,…-th nontrivial infinitesimal flex (according to the methodnontrivial_inf_flexes()) for plotting. For these input types, it is important to use the same vertex order as the one fromGraph.vertex_list(). If the vertex order needs to be specified, adict[Vertex, Sequence[Number]]can be provided, which maps the vertex labels to vectors (i.e. a sequence of coordinates).stress (
Union[int,Stress]) – Optional parameter for plotting a given equilibrium stress. The standard input format is aMatrixthat is the output of e.g. the methodstresses(). Alternatively, anintcan be specified to directly choose the 0,1,2,…-th equilibrium stress (according to the methodstresses()) for plotting. For these input types, it is important to use the same edge order as the one fromGraph.edge_list(). If the edge order needs to be specified, aDict[Edge, Number]can be provided, which maps the edges to numbers (i.e. coordinates).vertex_colors_custom (
Sequence[Sequence[Vertex]] |dict[str,Sequence[Vertex]]) – It is possible to provide custom vertex colors through this parameter. They can either be provided through a partition of vertices or a dictionary withstrcolor keywords that map to lists of vertices.edge_colors_custom (
Sequence[Sequence[Edge]] |dict[str,Sequence[Edge]]) – Optional parameter to specify the colors of edges. It can be aSequence[Sequence[Edge]]to define groups of edges with the same color or adict[str, Sequence[Edge]]where the keys are color strings and the values are lists of edges. The omitted edges are given the valueplot_style.edge_color.stress_label_positions (
dict[DirectedEdge,float]) – Dictionary specifying the position of stress labels along the edges. Keys areDirectedEdgeobjects, and values are floats (e.g., 0.5 for midpoint). Omitted edges are given the value0.5.arc_angles_dict (
Sequence[float] |dict[DirectedEdge,float]) – Optional parameter to specify custom arc angle for edges. Can be aSequence[float]or adict[Edge, float]where values define the curvature angle of edges in radians.filename (
str) – The filename under which the produced figure is saved. The default value isNonewhich indicates that the figure is currently not saved. The figure is saved as a.pngfile using thesavemethod frommatplotlib.dpi (
Dots per inched in case the figure is saved. Default is 300 for producing) – a print-quality image.fixed_vertices (
Sequence[Vertex]) – Vertices that are assigned a zero flex in the plot.
- Return type:
Examples
>>> from pyrigi import Graph, Framework >>> G = Graph([(0,1), (1,2), (2,3), (0,3), (0,2), (1,3), (0,4)]) >>> F = Framework(G, {0:(0,0), 1:(1,0), 2:(1,2), 3:(0,1), 4:(-1,0)}) >>> from pyrigi import PlotStyle2D >>> style = PlotStyle2D(vertex_color="green", edge_color="blue") >>> F.plot2D(plot_style=style)
Use keyword arguments
>>> F.plot2D(vertex_color="red", edge_color="black", vertex_size=500)
Specify stress and its labels positions
>>> stress_label_positions = {(0, 1): 0.7, (1, 2): 0.2} >>> F.plot2D(stress=0, stress_label_positions=stress_label_positions)
Specify infinitesimal flex
>>> F.plot2D(inf_flex=0)
Use both stress and infinitesimal flex
>>> F.plot2D(stress=0, inf_flex=0)
Use custom edge colors
>>> edge_colors = {'red': [(0, 1), (1, 2)], 'blue': [(2, 3), (0, 3)]} >>> F.plot2D(edge_colors_custom=edge_colors)
The following is just to close all figures after running the example:
>>> import matplotlib.pyplot >>> matplotlib.pyplot.close("all")
- plot3D(plot_style=None, projection_matrix=None, random_seed=None, coordinates=None, inf_flex=None, stress=None, vertex_colors_custom=None, edge_colors_custom=None, stress_label_positions=None, filename=None, dpi=300, fixed_vertices=[], **kwargs)[source]¶
Plot the provided framework in 3D.
If the framework is in a dimension higher than 3 and
projection_matrixwithcoordinatesareNone, a random projection matrix containing three orthonormal vectors is generated and used for projection into 3D. For various formatting options, seePlotStyle. Only the parametercoordinatesorprojection_matrixcan be used, not both at the same time.- Parameters:
plot_style (
PlotStyle) – An instance of thePlotStyleclass that defines the visual style for plotting, seePlotStylefor more details.projection_matrix (
MutableDenseMatrix) – The matrix used for projecting the realization when the dimension is greater than 3. The matrix must have dimensions(3, dim), wheredimis the dimension of the framework. IfNone, a random projection matrix is generated.random_seed (
int) – The random seed used for generating the projection matrix.coordinates (
Sequence[int]) – Indices of two coordinates to which the framework is projected.inf_flex (
Union[int,InfFlex]) – Optional parameter for plotting a given infinitesimal flex. The standard input format is aMatrixthat is the output of e.g. the methodinf_flexes(). Alternatively, anintcan be specified to directly choose the 0,1,2,…-th nontrivial infinitesimal flex (according to the methodnontrivial_inf_flexes()) for plotting. For these input types, is important to use the same vertex order as the one fromGraph.vertex_list(). If the vertex order needs to be specified, adict[Vertex, Sequence[Number]]can be provided, which maps the vertex labels to vectors (i.e. a sequence of coordinates).stress (
Union[int,Stress]) – Optional parameter for plotting a given equilibrium stress. The standard input format is aMatrixthat is the output of e.g. the methodstresses(). Alternatively, anintcan be specified to directly choose the 0,1,2,…-th equilibrium stress (according to the methodstresses()) for plotting. For these input types, is important to use the same edge order as the one fromGraph.edge_list(). If the edge order needs to be specified, aDict[Edge, Number]can be provided, which maps the edges to numbers (i.e. coordinates).vertex_colors_custom (
Sequence[Sequence[Vertex]] |dict[str,Sequence[Vertex]]) – Optional parameter to specify the colors of vertices. It can be aSequence[Sequence[Vertex]]to define groups of vertices with the same color or adict[str, Sequence[Vertex]]where the keys are color strings and the values are lists of vertices. The omitted vertices are given the valueplot_style.vertex_color.edge_colors_custom (
Sequence[Sequence[Edge]] |dict[str,Sequence[Edge]]) – Optional parameter to specify the colors of edges. It can be aSequence[Sequence[Edge]]to define groups of edges with the same color or adict[str, Sequence[Edge]]where the keys are color strings and the values are lists of edges. The omitted edges are given the valueplot_style.edge_color.stress_label_positions (
dict[DirectedEdge,float]) – Dictionary specifying the position of stress labels along the edges. Keys areDirectedEdgeobjects, and values are floats (e.g., 0.5 for midpoint). Omitted edges are given the value0.5.filename (
str) – The filename under which the produced figure is saved. The default value isNonewhich indicates that the figure is currently not saved. The figure is saved as a.pngfile using thesavemethod frommatplotlib.dpi (
Dots per inched in case the figure is saved. Default is 300 for producing) – a print-quality image.fixed_vertices (
Sequence[Vertex]) – Vertices that are assigned a zero flex in the plot.
- Return type:
Examples
>>> from pyrigi import frameworkDB >>> F = frameworkDB.Octahedron(realization="Bricard_plane") >>> F.plot3D()
>>> from pyrigi import PlotStyle3D >>> style = PlotStyle3D(vertex_color="green", edge_color="blue") >>> F.plot3D(plot_style=style)
Use keyword arguments
>>> F.plot3D(vertex_color="red", edge_color="black", vertex_size=500)
Specify stress and its positions
>>> stress_label_positions = {(0, 2): 0.7, (1, 2): 0.2} >>> F.plot3D(stress=0, stress_label_positions=stress_label_positions)
Specify infinitesimal flex
>>> F.plot3D(inf_flex=0)
Use both stress and infinitesimal flex
>>> F.plot3D(stress=0, inf_flex=0)
Use custom edge colors
>>> edge_colors = {'red': [(5, 1), (1, 2)], 'blue': [(2, 4), (4, 3)]} >>> F.plot3D(edge_colors_custom=edge_colors)
The following is just to close all figures after running the example:
>>> import matplotlib.pyplot >>> matplotlib.pyplot.close("all")
- projected_realization(proj_dim=None, projection_matrix=None, random_seed=None, coordinates=None)[source]¶
Return the realization projected to a lower dimension and the projection matrix.
- Parameters:
proj_dim (
int) – The dimension to which the framework is projected. This is determined fromprojection_matrixif it is provided.projection_matrix (
MutableDenseMatrix) – The matrix used for projecting the placement of vertices. The matrix must have dimensions(proj_dim, dim), wheredimis the dimension of the given framework. IfNone, a numerical random projection matrix is generated.random_seed (
int) – The random seed used for generating the projection matrix.coordinates (
Sequence[int]) – Indices of coordinates to which projection is applied. Providing the parameter overrides the previous ones.
- Return type:
Suggested Improvements
Generate random projection matrix over symbolic rationals.
- realization(as_points=False, numerical=False)¶
Return a copy of the realization.
- Parameters:
as_points (
bool) – IfTrue, then the vertex positions type ispyrigi.data_type.Point, otherwiseMatrix(default).numerical (
bool) – IfTrue, the vertex positions are converted to floats.
- Return type:
Examples
>>> F = Framework.Complete([(0,0), (1,0), (1,1)]) >>> F.realization(as_points=True) {0: [0, 0], 1: [1, 0], 2: [1, 1]} >>> F.realization() {0: Matrix([ [0], [0]]), 1: Matrix([ [1], [0]]), 2: Matrix([ [1], [1]])}
- rigidity_matrix(vertex_order=None, edge_order=None)[source]¶
Construct the rigidity matrix of the framework.
Definitions
- Parameters:
vertex_order (
Sequence[Vertex]) – A list of vertices, providing the ordering for the columns of the rigidity matrix. If none is provided, the list fromGraph.vertex_list()is taken.edge_order (
Sequence[Edge]) – A list of edges, providing the ordering for the rows of the rigidity matrix. If none is provided, the list fromGraph.edge_list()is taken.
- Return type:
Examples
>>> F = Framework.Complete([(0,0),(2,0),(1,3)]) >>> F.rigidity_matrix() Matrix([ [-2, 0, 2, 0, 0, 0], [-1, -3, 0, 0, 1, 3], [ 0, 0, 1, -3, -1, 3]])
- rigidity_matrix_rank(numerical=False, tolerance=1e-09)[source]¶
Return the rank of the rigidity matrix.
Definitions
- Parameters:
numerical (
bool) –If
True, the rank of the rigidity matrix with entries as floats is computed.Warning: For
numerical=Truethe numerical rank computation may produce different results than the computation over exact coordinates.tolerance (
float) – Numerical tolerance used for computing the rigidity matrix rank.
- Return type:
Examples
>>> K4 = Framework.Complete([[0,0], [1,0], [1,1], [0,1]]) >>> K4.rigidity_matrix_rank() # the complete graph is a circuit 5 >>> K4.delete_edge([0,1]) >>> K4.rigidity_matrix_rank() # deleting a bar gives full rank 5 >>> K4.delete_edge([2,3]) >>> K4.rigidity_matrix_rank() #so now deleting an edge lowers the rank 4
- rotate(**kwargs)[source]¶
Alias for rotating frameworks based on
rotate2D()androtate3D().For implementation details and possible parameters, see
rotate2D()androtate3D().
- rotate2D(angle, rotation_center=[0, 0], inplace=True)[source]¶
Rotate the planar framework counterclockwise.
- Parameters:
angle (
float) – Rotation angle. If you want the coordinates to stay symbolic even after the rotation, you need to input the angle as a sympy expression.rotation_center (
Point) – The center of rotation. By default, this is the origin.inplace (
bool) – IfTrue(default), then this framework is rotated. Otherwise, a new rotated framework is returned.
- Return type:
- rotate3D(angle, axis_direction=[0, 0, 1], axis_shift=[0, 0, 0], inplace=True)[source]¶
Rotate the spatial framework counterclockwise around a specified rotation axis.
- Parameters:
angle (
Number) – Rotation angle around the axis of rotation. If you want the coordinates to stay symbolic even after the rotation, you need to input the angle as a sympy expression.axis_direction (
Sequence[Number]) – Direction of the rotation axis. By default, this is thez-axis.axis_shift (
Point) – A point through which the rotation axis passes. By default, this is the origin.inplace (
bool) – IfTrue(default), then this framework is rotated. Otherwise, a new rotated framework is returned.
- Return type:
- set_realization(realization)¶
Change the realization of the framework.
Definitions
- Parameters:
realization (
dict[Vertex,Point]) – A realization of the underlying graph of the framework. It must contain all vertices from the underlying graph. Furthermore, all points in the realization need to be contained in \(\RR^d\) for \(d\) being the current dimension of the framework.- Return type:
Examples
>>> F = Framework.Complete([(0,0), (1,0), (1,1)]) >>> F.set_realization( ... {vertex: (vertex, vertex + 1) for vertex in F.graph.vertex_list()} ... ) >>> print(F) Framework in 2-dimensional space consisting of: Graph with vertices [0, 1, 2] and edges [[0, 1], [0, 2], [1, 2]] Realization {0:(0, 1), 1:(1, 2), 2:(2, 3)}
- set_vertex_pos(vertex, point)¶
Change the coordinates of a single given vertex.
- Parameters:
- Return type:
Examples
>>> F = Framework.from_points([(0,0)]) >>> F.set_vertex_pos(0, (6,2)) >>> print(F) Framework in 2-dimensional space consisting of: Graph with vertices [0] and edges [] Realization {0:(6, 2)}
- set_vertex_positions(subset_of_realization)¶
Change the coordinates of vertices given by a dictionary.
Examples
>>> F = Framework.Complete([(0,0),(0,0),(1,0),(1,0)]) >>> F.realization(as_points=True) {0: [0, 0], 1: [0, 0], 2: [1, 0], 3: [1, 0]} >>> F.set_vertex_positions({1:(0,1),3:(1,1)}) >>> F.realization(as_points=True) {0: [0, 0], 1: [0, 1], 2: [1, 0], 3: [1, 1]}
- set_vertex_positions_from_lists(vertices, points)¶
Change the coordinates of a given list of vertices.
It is necessary that both lists have the same length. No vertex from
verticescan be contained multiple times. We apply the methodset_vertex_positions()to the corresponding pairs ofverticesandpoints.Examples
>>> F = Framework.Complete([(0,0),(0,0),(1,0),(1,0)]) >>> F.realization(as_points=True) {0: [0, 0], 1: [0, 0], 2: [1, 0], 3: [1, 0]} >>> F.set_vertex_positions_from_lists([1,3], [(0,1),(1,1)]) >>> F.realization(as_points=True) {0: [0, 0], 1: [0, 1], 2: [1, 0], 3: [1, 1]}
- stress_matrix(stress, edge_order=None, vertex_order=None)[source]¶
Construct the stress matrix of a stress.
Definitions
- Parameters:
stress (
Stress) – A stress of the framework given as a vector.edge_order (
Sequence[Edge]) – A list of edges, providing the ordering of edges instress. IfNone,Graph.edge_list()is assumed.vertex_order (
Sequence[Vertex]) – Specification of row/column order of the stress matrix. IfNone,Graph.vertex_list()is assumed.
- Return type:
Examples
>>> G = Graph([[0,1],[0,2],[0,3],[1,2],[2,3],[3,1]]) >>> pos = {0: (0, 0), 1: (0,1), 2: (-1,-1), 3: (1,-1)} >>> F = Framework(G, pos) >>> omega = [-8, -4, -4, 2, 2, 1] >>> F.stress_matrix(omega) Matrix([ [-16, 8, 4, 4], [ 8, -4, -2, -2], [ 4, -2, -1, -1], [ 4, -2, -1, -1]])
- stress_matrix_rank(stress, edge_order=None, numerical=False, tolerance=1e-09)[source]¶
Return the rank of the stress matrix for a given stress.
Definitions
- Parameters:
stress (
Stress) – A stress of the framework given as a vector.edge_order (
Sequence[Edge]) – A list of edges, providing the ordering of edges instress. IfNone,Graph.edge_list()is assumed.numerical (
bool) –If
True, the rank of the stress matrix with entries as floats is computed.Warning: For
numerical=Truethe numerical rank computation may produce different results than the computation over exact coordinates.tolerance (
float) – Numerical tolerance used for computing the rank.
- Return type:
Examples
>>> F = Framework.Complete([(0, 0), (0, 1), (-1, -1), (1, -1)]) >>> omega = [-8, -4, -4, 2, 2, 1] >>> F.is_stress(omega) True >>> F.stress_matrix(omega) Matrix([ [-16, 8, 4, 4], [ 8, -4, -2, -2], [ 4, -2, -1, -1], [ 4, -2, -1, -1]]) >>> F.stress_matrix_rank(omega) 1
- stresses(edge_order=None, numerical=False, tolerance=1e-09)[source]¶
Return a basis of the space of equilibrium stresses.
Definitions
- Parameters:
edge_order (
Sequence[Edge]) – A list of edges, providing the ordering for the entries of the stresses. If none is provided, the list fromGraph.edge_list()is taken.numerical (
bool) – Determines whether the output is symbolic (default) or numerical.tolerance (
float) – Used tolerance when computing the stresses numerically.
- Return type:
list[MutableDenseMatrix] |list[list[float]]
Examples
>>> G = Graph([[0,1],[0,2],[0,3],[1,2],[2,3],[3,1]]) >>> pos = {0: (0, 0), 1: (0,1), 2: (-1,-1), 3: (1,-1)} >>> F = Framework(G, pos) >>> F.stresses() [Matrix([ [-8], [-4], [-4], [ 2], [ 2], [ 1]])]
- to_tikz(vertex_style='fvertex', edge_style='edge', label_style='labelsty', figure_opts='', vertex_in_labels=False, vertex_out_labels=False, default_styles=True)[source]¶
Create a TikZ code for the framework.
The framework must have dimension 2. For using it in
LaTeXyou need to use thetikzpackage. For more examples on formatting options, see alsoGraph.to_tikz().- Parameters:
vertex_style (
str|dict[str,Sequence[Vertex]]) – If a single style is given as a string, then all vertices get this style. If a dictionary from styles to a list of vertices is given, vertices are put in style accordingly. The vertices missing in the dictionary do not get a style.edge_style (
str|dict[str,Sequence[Edge]]) – If a single style is given as a string, then all edges get this style. If a dictionary from styles to a list of edges is given, edges are put in style accordingly. The edges missing in the dictionary do not get a style.label_style (
str) – The style for labels that are placed next to vertices.figure_opts (
str) – Options for the tikzpicture environment.vertex_in_labels (
bool) – A bool on whether vertex names should be put as labels on the vertices.vertex_out_labels (
bool) – A bool on whether vertex names should be put next to vertices.default_styles (
bool) – A bool on whether default style definitions should be put to the options.
- Return type:
Examples
>>> G = Graph([(0, 1), (1, 2), (2, 3), (0, 3)]) >>> F=Framework(G,{0: [0, 0], 1: [1, 0], 2: [1, 1], 3: [0, 1]}) >>> print(F.to_tikz()) \begin{tikzpicture}[fvertex/.style={circle,inner sep=0pt,minimum size=3pt,fill=white,draw=black,double=white,double distance=0.25pt,outer sep=1pt},edge/.style={line width=1.5pt,black!60!white}] \node[fvertex] (0) at (0, 0) {}; \node[fvertex] (1) at (1, 0) {}; \node[fvertex] (2) at (1, 1) {}; \node[fvertex] (3) at (0, 1) {}; \draw[edge] (0) to (1) (0) to (3) (1) to (2) (2) to (3); \end{tikzpicture}
>>> print(F.to_tikz(vertex_in_labels=True)) \begin{tikzpicture}[fvertex/.style={circle,inner sep=1pt,minimum size=3pt,fill=white,draw=black,double=white,double distance=0.25pt,outer sep=1pt,font=\scriptsize},edge/.style={line width=1.5pt,black!60!white}] \node[fvertex] (0) at (0, 0) {$0$}; \node[fvertex] (1) at (1, 0) {$1$}; \node[fvertex] (2) at (1, 1) {$2$}; \node[fvertex] (3) at (0, 1) {$3$}; \draw[edge] (0) to (1) (0) to (3) (1) to (2) (2) to (3); \end{tikzpicture}
- translate(vector, inplace=True)[source]¶
Translate the framework.
- Parameters:
vector (
Union[Point,MutableDenseMatrix]) – Translation vectorinplace (
bool) – IfTrue(default), then this framework is translated. Otherwise, a new translated framework is returned.
- Return type:
- trivial_inf_flexes(vertex_order=None)[source]¶
Return a basis of the vector subspace of trivial infinitesimal flexes.
Definitions
- Parameters:
vertex_order (
Sequence[Vertex]) – A list of vertices, providing the ordering for the entries of the infinitesimal flexes.- Return type:
Examples
>>> F = Framework.Complete([(0,0), (2,0), (0,2)]) >>> F.trivial_inf_flexes() [Matrix([ [1], [0], [1], [0], [1], [0]]), Matrix([ [0], [1], [0], [1], [0], [1]]), Matrix([ [ 0], [ 0], [ 0], [ 2], [-2], [ 0]])]