1
$\begingroup$

I want to simplify my complicated code write neat and systematic code. I use animate after solving differential equations. It's my Phd code and is very heavy and complicated. I want to simplify my graphics. It consists of a lot of lines a lot of Disk and ... . I want to know that can I define contents of graphics before it.

s = NDSolve[{D[D[L, θ1'[t]], t] - D[L, θ1[t]] + 
      D[RDF, θ1'[t]] == 0, θ1[0] == 
     Pi/6, θ1'[0] == 0}, {θ1}, {t, 50},];

Animate[Graphics[{Line[{θ1, 
      2 θ1}, {3 θ1, θ1}], Line[{}, {}], ..., 
    Disk[{θ1, 2 θ1}, {3 θ1, θ1}], ..., 
    Rectangle[{, }, {, }]}], {t, 1, 50}] /. s

for example Like that

 s = NDSolve[{D[D[L, θ1'[t]], t] - D[L, θ1[t]] + 
      D[RDF, θ1'[t]] == 0, θ1[0] == 
     Pi/6, θ1'[0] == 0}, {θ1}, {t, 50},];

Line1= Line[{θ1, 2 θ1}, {3 θ1, θ1}]
Line2=...
Disk1=Line[{θ1, 2 θ1}, {3 θ1, θ1}]
Disk2=...

Animate[Graphics[{Line1, Line2, ...,], {t, 1, 50}] /. s

I have not any answer and after received an idea I can Edit my question with a real and simple example that help other users.

$\endgroup$
2
  • $\begingroup$ hi, it is not clear what is the question here. Can you please clarify what is it you are asking? $\endgroup$
    – Nasser
    Jan 10, 2017 at 9:27
  • $\begingroup$ I want define line, disk, rectangle and... before or out of graphics function for more neat code. if I use 54 lines, 15 disk, and a lot of shapes it become very unteady and it can make problem in editing and readability of my code. $\endgroup$
    – Farshid
    Jan 10, 2017 at 9:55

1 Answer 1

3
$\begingroup$

I think probably this question is a duplicate of How are parameters evaluated for a Plot in Manipulate.

A simple example of what I think you are attempting:

line = Line[{{t, 3}, {4, 5 - t}}]

Animate[Graphics[line[t]], {t, 1, 10}]  (* failure *)

A solution from the Accepted answer to the referenced Question:

ClearAll[line]

line[t_] := Line[{{t, 3}, {4, 5 - t}}]

Animate[Graphics[line[t]], {t, 1, 10}]
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.