Graph Motion¶
This is implementation of motions of a graph.
AUTHORS:
- Jan Legerský (2019-01-24): initial version
- Jan Legerský (2020-03-12): update to SageMath 9.0
Classes¶
-
class
flexrilog.graph_motion.
GraphMotion
(graph)[source]¶ Bases:
sage.structure.sage_object.SageObject
-
classmethod
GridConstruction
(graph, NAC_coloring, zigzag=False, check=True, red_components_ordered=[], blue_components_ordered=[])[source]¶ Return the motion obtained by grid construction for given NAC-coloring.
-
classmethod
ParametricMotion
(graph, parametrization, par_type, active_NACs=None, sampling_type=None, interval=None, check=True)[source]¶ Return parametric motion of a graph with a given parametrization.
INPUT:
graph
– an instance of FlexRiGraphparametrization
– a dictionary with a key being a vertex of the graph and its value being the position given as a vector.par_type
– type of the parametrization:rational
orsymbolic
-
classmethod
SpatialEmbeddingConstruction
(graph, active_NACs, check=True, four_cycle_motion=None, vertex_at_origin=None, subs_dict={})[source]¶ Return a motion given by spatial embedding construction.
INPUT:
graph
– an instance of FlexRiGraphactive_NACs
– a pair of NAC-colorings used to construct a spatial embedding, seeflexrilog.flexible_rigid_graph.FlexRiGraph.spatial_embeddings_four_directions()
.four_cycle_motion
– a motion of a 4-cycle used to construct the motion of the whole graph. IfNone
(default), thenDeltoid()
is used.
-
animation_SVG
(realizations, fileName='', edge_partition=True, first=None, totalTime=12, width=500, repetitions='indefinite', radius='default', return_IPythonSVG=True, flipY=True, rel_margin=0.1, colors=[], rnd_str=True, vertex_labels=True)[source]¶ Save an SVG animation.
EXAMPLES:
sage: from flexrilog import GraphGenerator, GraphMotion sage: G = GraphGenerator.ThreePrismGraph() sage: delta = G.NAC_colorings()[0] sage: M = GraphMotion.GridConstruction(G, delta.conjugated(), zigzag=[[[0,0], [0,1]], [[0,0], [3/4,1/2], [2,0]]]) sage: M.animation_SVG() <IPython.core.display.SVG object>
TODO:
Doc, examples
-
classmethod
-
class
flexrilog.graph_motion.
ParametricGraphMotion
(graph, input_format, active_NACs, data, check)[source]¶ Bases:
flexrilog.graph_motion.GraphMotion
-
animation_SVG
(fileName='', edge_partition=True, first=None, totalTime=12, width=500, repetitions='indefinite', radius='default', return_IPythonSVG=True, fps=25, flipY=True, rel_margin=0.1, colors=[], rnd_str=True, vertex_labels=True)[source]¶ Save an SVG animation.
EXAMPLES:
sage: from flexrilog import GraphGenerator, GraphMotion sage: G = GraphGenerator.ThreePrismGraph() sage: delta = G.NAC_colorings()[0] sage: M = GraphMotion.GridConstruction(G, delta.conjugated(), zigzag=[[[0,0], [0,1]], [[0,0], [3/4,1/2], [2,0]]]) sage: M.animation_SVG() <IPython.core.display.SVG object>
TODO:
Doc, examples
-
collisions
()[source]¶ Return vertex-edge collisions.
OUTPUT:
A dictionary where key
v
is a vertex and the corresponding value is a list of edgese
such thatv
collides withe
for some parameter value.EXAMPLES:
sage: from flexrilog import GraphMotion sage: GraphMotion.Deltoid().collisions() {0: [(1, 2), (2, 3)], 1: [(0, 3), (2, 3)], 3: [(0, 1), (1, 2)]}
sage: from flexrilog import FlexRiGraph sage: t = var('t') sage: edges = [(1, 4), (1, 5), (1, 6), (2, 4), (2, 5), (2, 6), (3, 5), (3, 6), (3, 4)] sage: M = GraphMotion.ParametricMotion(FlexRiGraph(edges), ....: {1: vector([sin(t),0]), 2: vector([sqrt(1+sin(t)^2),0]), 3: vector([-sqrt(2+sin(t)^2),0]), ....: 4: vector([0,cos(t)]), 5: vector([0,sqrt(1+cos(t)*cos(t))]), 6: vector([0,-sqrt(2+cos(t)^2)])}, ....: 'symbolic') sage: M.collisions() {1: [(3, 4), (2, 4)], 4: [(1, 5), (1, 6)]}
WARNING:
It is not guaranteed that all collisions are found, since it depends on numerical root finding of complicated expressions.
-
generate_POVray
(filename, height_function, antialias=True, frames=200, width=1024, height=768, labels=False, camera_location=[3.0, 3.0, 3.0], look_at=[0.0, 0.3, 0.0], compile_animation=False)[source]¶ Generate files for POV-ray animation.
TODO:
description, make radius as parameter
-
merge_animations
(motions, total_time=12, fps=25, **kwargs)[source]¶ Return an animation by concatenating a list of motions.
-