@@ -6,7 +6,7 @@ operates. The first step is to open up your python interpreter. This varies
66depending on your work style, but the simplest way is to type python in a
77command prompt:
88
9- .. code-block :: bash
9+ .. code :: bash
1010
1111 $ python
1212
@@ -15,14 +15,14 @@ functionality from SymPy and the Mechanics module, otherwise you will only have
1515basic python commands available to work with. We will use the import * method
1616to bring in all functions from the two modules:
1717
18- .. code-block :: python
18+ .. code :: python
1919
2020 >> > from sympy import *
2121 >> > from sympy.physics.mechanics import *
2222
2323 You can now see what functions and variables that are available to you with:
2424
25- .. code-block :: python
25+ .. code :: python
2626
2727 >> > dir ()
2828
@@ -37,45 +37,45 @@ know the name of the command that you want to use simply use the builtin help
3737function to bring up the documentation for the function. In our case we need to
3838use the ReferenceFrame class:
3939
40- .. code-block :: python
40+ .. code :: python
4141
4242 >> > help (ReferenceFrame)
4343
4444 Press `q ` to return to the command line. Now create an inertial reference frame
4545called N for Newtonian as was described in the help:
4646
47- .. code-block :: python
47+ .. code :: python
4848
4949 >> > N = ReferenceFrame(' N' )
5050
5151 Keep in mind that N is the variable name of which the reference frame named 'N'
5252is stored. It is important to note that `N ` is an object and it has properties
5353and functions associated with it. To see a list of them type:
5454
55- .. code-block :: python
55+ .. code :: python
5656
5757 >> > dir (N)
5858 Notice that three of the properties are `x `, `y `, and `z `. These are the
5959orthonormal unit vectors associated with the reference frame and are the
6060building blocks for creating vectors. We can create a vector by simply building
6161a linear combination of the unit vectors:
6262
63- .. code-block :: python
63+ .. code :: python
6464
6565 >> > v = 1 * N.x + 2 * N.y + 3 * N.z
6666
6767 Now a vector expressed in the N reference frame is stored in the variable `v `.
6868We can print `v ` to the screen by typing:
6969
70- .. code-block :: python
70+ .. code :: python
7171
7272 >> > print (v)
7373 N.x + 2 * N.y + 3 * N.z
7474
7575 The vector `v ` can be manipulated as expected. You can multiply and divide them
7676by scalars:
7777
78- .. code-block :: python
78+ .. code :: python
7979
8080 >> > 2 * v
8181 2 * N.x + 4 * N.y + 6 * N.z
@@ -88,7 +88,7 @@ remember to always declare numbers as floats (i.e. include a decimal).
8888
8989You can add and subtract vectors:
9090
91- .. code-block :: python
91+ .. code :: python
9292
9393 >> > v + v
9494 2 * N.x + 4 * N.y + 6 * N.z
@@ -98,28 +98,28 @@ You can add and subtract vectors:
9898
9999 Vectors also have some useful properties:
100100
101- .. code-block :: python
101+ .. code :: python
102102
103103 >> > dir (v)
104104
105105 You can find the magnitude of a vector by typing:
106106
107- .. code-block :: python
107+ .. code :: python
108108
109109 >> > v.magnitude()
110110 sqrt(14 )
111111
112112 You can compute a unit vector in the direction of `v `:
113113
114- .. code-block :: python
114+ .. code :: python
115115
116116 >> > v.normalize()
117117 sqrt(14 )/ 14 * N.x + sqrt(14 )/ 7 * N.y + 3 * sqrt(14 )/ 14 * N.z
118118
119119 You can find the measure numbers and the reference frame the vector was defined
120120in with:
121121
122- .. code-block :: python
122+ .. code :: python
123123
124124 >> > v.args
125125 [([1 ]
@@ -128,7 +128,7 @@ in with:
128128
129129 Dot and cross products of vectors can also be computed:
130130
131- .. code-block :: python
131+ .. code :: python
132132
133133 >> > dot(v, w)
134134 19
@@ -139,14 +139,14 @@ We've only used numbers as our measure numbers so far, but it is just as easy
139139to use symbols. We will introduce six symbols for our measure numbers with the
140140SymPy `symbols ` [`help(symbols) for the documentation `] function:
141141
142- .. code-block :: python
142+ .. code :: python
143143
144144 >> > a1, a2, a3 = symbols(' a1 a2 a3' )
145145 >> > b1, b2, b3 = symbols(' b1 b2 b3' )
146146
147147 And create two new vectors that are completely symbolic:
148148
149- .. code-block :: python
149+ .. code :: python
150150
151151 >> > x = a1 * N.x + a2 * N.y + a3 * N.z
152152 >> > y = b1 * N.x + b2 * N.y + b3 * N.z
@@ -157,15 +157,15 @@ And create two new vectors that are completely symbolic:
157157
158158 Numbers and symbols work together seamlessly:
159159
160- .. code-block :: python
160+ .. code :: python
161161
162162 >> > dot(v, x)
163163 a1 + 2 * a2 + 3 * a3
164164
165165 You can also differentiate a vector with respect to a variable in a reference
166166frame:
167167
168- .. code-block :: python
168+ .. code :: python
169169
170170 >> > x.diff(a1, N)
171171 N.x
@@ -175,7 +175,7 @@ create a new reference frame and orient it with respect to the `N` frame that
175175has already been created. We will use the `orient ` method of the new frame to
176176do a simple rotation through `alpha ` about the `N.x ` axis:
177177
178- .. code-block :: python
178+ .. code :: python
179179
180180 >> > A = ReferenceFrame(' A' )
181181 >> > alpha = symbols(' alpha' )
@@ -184,7 +184,7 @@ do a simple rotation through `alpha` about the `N.x` axis:
184184 Now the direction cosine matrix with of `A ` with respect to `N ` can be
185185computed:
186186
187- .. code-block :: python
187+ .. code :: python
188188
189189 >> > A.dcm(N)
190190 [1 , 0 , 0 ]
@@ -194,7 +194,7 @@ computed:
194194 Now that SymPy knows that `A ` and `N ` are oriented with respect to each other
195195we can express the vectors that we originally wrote in the `A ` frame:
196196
197- .. code-block :: python
197+ .. code :: python
198198
199199 >> > v.express(A)
200200 A.x + (3 * sin(alpha) + 2 * cos(alpha))* A.y + (- 2 * sin(alpha) + 3 * cos(alpha))* A.z
@@ -208,7 +208,7 @@ frames and vectors are time varying. The mechanics module provides a way to
208208specify quantities as time varying. Let's define two variables `beta ` and `d `
209209as variables which are functions of time:
210210
211- .. code-block :: python
211+ .. code :: python
212212
213213 >> > beta, d = dynamicsymbols(' beta d' )
214214
@@ -217,23 +217,23 @@ frame by `beta` and create a vector in that new frame that is a function of
217217`d `. This time we will use the `orientnew ` method of the `A ` frame to create
218218the new reference frame `B `:
219219
220- .. code-block :: python
220+ .. code :: python
221221
222222 >> > B = A.orientnew(' B' , ' Axis' , [beta, A.y])
223223 >> > vec = d * B.z
224224
225225 We can now compute the angular velocity of the reference frame `B ` with respect
226226to other reference frames:
227227
228- .. code-block :: python
228+ .. code :: python
229229
230230 >> > B.ang_vel_in(N)
231231 beta' *A.y
232232
233233 This allows us to now differentiate the vector, `vec `, with respect to time and
234234a reference frame:
235235
236- .. code-block :: python
236+ .. code :: python
237237
238238 >> > vecdot = vec.dt(N)
239239 >> > vecdot
@@ -248,7 +248,7 @@ varying variables. For example, we can define `omega` as the first time
248248derivative of `beta` which allows you to explicitly interact with the
249249derivatives:
250250
251- .. code- block :: python
251+ .. code:: python
252252
253253 >> > theta = dynamicsymbols(' theta' )
254254 >> > omega = dynamicsymbols(' theta' , 1 )
@@ -257,33 +257,33 @@ At this point we now have all the tools needed to setup the kinematics for a
257257dynamic system. Let' s start with a simple system where a point can move back
258258and forth on a spinning disc. First create an inertial reference frame:
259259
260- .. code- block :: python
260+ .. code:: python
261261
262262 >> > N = ReferenceFrame(' N' )
263263
264264Now create a reference frame for the disc:
265265
266- .. code- block :: python
266+ .. code:: python
267267
268268 >> > D = ReferenceFrame(' D' )
269269
270270The disc rotates with respect to `N` about the `N.x` axis through `theta` :
271271
272- .. code- block :: python
272+ .. code:: python
273273
274274 >> > theta = dynamicsymbols(' theta' )
275275 >> > D.orient(N, ' Axis' , [theta, N.x])
276276
277277Define one point at the origin of rotation which is fixed in `N` :
278278
279- .. code- block :: python
279+ .. code:: python
280280
281281 >> > no = Point(' no' )
282282 >> > no.set_vel(N, 0 )
283283
284284The second point, `p` , can move through `x` along the `D.y` axis:
285285
286- .. code- block :: python
286+ .. code:: python
287287
288288 >> > p = Point(' p' )
289289 >> > x = dynamicsymbols(' x' )
@@ -293,7 +293,7 @@ The second point, `p`, can move through `x` along the `D.y` axis:
293293
294294The velocity of the point in the `N` frame can now be computed:
295295
296- .. code- block :: python
296+ .. code:: python
297297
298298 >> > p.vel(N)
299299 x' *D.y + x*theta' * D.z
@@ -302,7 +302,7 @@ The velocity of the point in the `N` frame can now be computed:
302302
303303The acceleration of the point can also be computed:
304304
305- .. code- block :: python
305+ .. code:: python
306306
307307 >> > p.acc(N)
308308 (- x* theta' **2 + x' ' )*D.y + (x*theta' ' + 2*theta' * x' )*D.z
0 commit comments