Acknowledgments |
|
xxi | |
Introduction |
|
xxiii | |
Who This Book Is For |
|
xxiii | |
What You'll Learn |
|
xxiv | |
About This Book |
|
xxiv | |
What Is the "Hardcore" About? |
|
xxv | |
Why Python? |
|
xxv | |
Contents at a Glance |
|
xxvii | |
Setting Up Your Environment |
|
xxix | |
Downloading the Book's Code |
|
xxix | |
Installing Python |
|
xxx | |
Installing and Configuring PyCharm |
|
xxxi | |
PyCharm Introduction |
|
xxxiv | |
Creating Packages and Files |
|
xxxv | |
Creating Run Configurations |
|
xxxvi | |
Debugging Python Code |
|
xxxix | |
Summary |
|
xliv | |
|
|
|
|
3 | (20) |
|
Python Packages and Modules |
|
|
3 | (2) |
|
|
4 | (1) |
|
|
4 | (1) |
|
|
5 | (1) |
|
|
5 | (4) |
|
|
6 | (3) |
|
Documenting the Code with Docstrings |
|
|
9 | (2) |
|
|
11 | (9) |
|
|
11 | (1) |
|
|
12 | (3) |
|
|
15 | (3) |
|
|
18 | (2) |
|
|
20 | (1) |
|
|
21 | (2) |
|
|
23 | (26) |
|
|
23 | (13) |
|
|
24 | (1) |
|
|
25 | (1) |
|
|
26 | (1) |
|
|
27 | (1) |
|
Functions Inside Other Functions |
|
|
28 | (1) |
|
|
29 | (6) |
|
|
35 | (1) |
|
Object-Oriented Programming |
|
|
36 | (9) |
|
|
37 | (6) |
|
|
43 | (2) |
|
|
45 | (2) |
|
|
47 | (2) |
|
|
49 | (16) |
|
|
49 | (1) |
|
|
50 | (1) |
|
Installing the Windows Subsystem for Linux |
|
|
50 | (1) |
|
Taking a First Look at the Shell |
|
|
51 | (1) |
|
|
51 | (5) |
|
|
52 | (1) |
|
Creating Files and Directories |
|
|
53 | (1) |
|
Deleting Files and Directories |
|
|
54 | (1) |
|
|
55 | (1) |
|
Using Windows Subsystem for Linux |
|
|
55 | (1) |
|
|
56 | (1) |
|
Passing Arguments to the Script |
|
|
57 | (1) |
|
Standard Input and Output |
|
|
58 | (1) |
|
Redirecting the Output to a File |
|
|
58 | (1) |
|
Redirecting the Input from a File |
|
|
58 | (1) |
|
Using PyCharm's Python Console |
|
|
59 | (2) |
|
|
61 | (4) |
|
|
|
|
65 | (36) |
|
|
67 | (4) |
|
Calculating Distance Between Points |
|
|
68 | (1) |
|
Addition and Subtraction Operators |
|
|
69 | (2) |
|
|
71 | (14) |
|
Addition and Subtraction Operators |
|
|
72 | (1) |
|
|
73 | (1) |
|
|
73 | (1) |
|
|
74 | (2) |
|
|
76 | (1) |
|
|
77 | (1) |
|
|
77 | (1) |
|
|
78 | (1) |
|
|
79 | (1) |
|
Parallel and Perpendicular Vectors |
|
|
80 | (1) |
|
|
81 | (2) |
|
|
83 | (1) |
|
|
84 | (1) |
|
|
85 | (5) |
|
|
85 | (3) |
|
|
88 | (1) |
|
|
89 | (1) |
|
|
90 | (9) |
|
|
90 | (4) |
|
Testing Vector Plus and Minus Operations |
|
|
94 | (1) |
|
Testing Vector Product Operations |
|
|
95 | (1) |
|
Testing Vector Parallelism and Perpendicularity |
|
|
96 | (1) |
|
Three Golden Rules for Unit Testing |
|
|
97 | (2) |
|
|
99 | (2) |
|
|
101 | (30) |
|
|
101 | (23) |
|
|
103 | (2) |
|
|
105 | (2) |
|
The t Parameter and Middle Points |
|
|
107 | (7) |
|
|
114 | (3) |
|
|
117 | (1) |
|
|
117 | (4) |
|
Equality and String Representation |
|
|
121 | (3) |
|
|
124 | (4) |
|
|
126 | (2) |
|
|
128 | (1) |
|
|
129 | (2) |
|
|
131 | (40) |
|
|
132 | (16) |
|
|
133 | (4) |
|
|
137 | (2) |
|
|
139 | (5) |
|
|
144 | (2) |
|
|
146 | (2) |
|
|
148 | (7) |
|
|
149 | (1) |
|
|
150 | (2) |
|
Equality and String Representation |
|
|
152 | (1) |
|
|
153 | (2) |
|
|
155 | (14) |
|
|
158 | (1) |
|
|
158 | (6) |
|
|
164 | (1) |
|
|
165 | (2) |
|
|
167 | (2) |
|
|
169 | (2) |
|
|
171 | (32) |
|
|
172 | (5) |
|
Examples of Affine Transformations |
|
|
174 | (3) |
|
The Affine Transformation Class |
|
|
177 | (15) |
|
Testing the Transformation of Points |
|
|
178 | (1) |
|
Transform Segments and Polygons |
|
|
179 | (2) |
|
Concatenating Transformations |
|
|
181 | (3) |
|
Inverting Affine Transformations |
|
|
184 | (3) |
|
|
187 | (2) |
|
|
189 | (3) |
|
Interpolating Transformations |
|
|
192 | (5) |
|
|
192 | (3) |
|
Implementing Interpolation |
|
|
195 | (2) |
|
|
197 | (2) |
|
|
197 | (1) |
|
|
197 | (1) |
|
|
198 | (1) |
|
|
199 | (4) |
|
PART III GRAPHICS AND SIMULATIONS |
|
|
|
|
203 | (30) |
|
Bitmaps and Vector Images |
|
|
204 | (1) |
|
|
204 | (6) |
|
|
207 | (1) |
|
|
208 | (2) |
|
|
210 | (7) |
|
|
210 | (2) |
|
|
212 | (1) |
|
|
213 | (2) |
|
|
215 | (2) |
|
|
217 | (12) |
|
|
217 | (2) |
|
|
219 | (2) |
|
|
221 | (1) |
|
|
222 | (1) |
|
|
223 | (1) |
|
|
224 | (1) |
|
|
225 | (1) |
|
|
226 | (3) |
|
|
229 | (2) |
|
|
231 | (1) |
|
|
231 | (2) |
|
9 Building A Circle From Three Points |
|
|
233 | (32) |
|
|
234 | (1) |
|
|
235 | (4) |
|
Creating a Run Configuration |
|
|
236 | (3) |
|
Why Use a Run Configuration? |
|
|
239 | (1) |
|
Reading the Input and Configuration Files |
|
|
239 | (10) |
|
|
241 | (5) |
|
Regular Expressions Cheat Sheet |
|
|
246 | (1) |
|
|
246 | (2) |
|
|
248 | (1) |
|
Problem Model and Resolution |
|
|
249 | (1) |
|
|
250 | (8) |
|
Drawing the Output Circle |
|
|
251 | (3) |
|
|
254 | (2) |
|
|
256 | (2) |
|
|
258 | (1) |
|
Distributing Our Application |
|
|
258 | (5) |
|
Understanding the Problem |
|
|
259 | (1) |
|
|
260 | (3) |
|
Running the App Without an Input File |
|
|
263 | (1) |
|
|
263 | (2) |
|
10 Graphical User Interfaces And The Canvas |
|
|
265 | (22) |
|
|
266 | (10) |
|
|
266 | (4) |
|
|
270 | (6) |
|
Drawing Our Geometric Primitives |
|
|
276 | (9) |
|
|
276 | (2) |
|
|
278 | (1) |
|
|
279 | (2) |
|
|
281 | (4) |
|
|
285 | (2) |
|
11 Animations, Simulations, And The Time Loop |
|
|
287 | (20) |
|
|
288 | (3) |
|
|
288 | (1) |
|
|
288 | (1) |
|
|
289 | (2) |
|
|
291 | (1) |
|
|
292 | (7) |
|
|
292 | (2) |
|
Adding a Frame Count Label |
|
|
294 | (2) |
|
|
296 | (1) |
|
|
297 | (2) |
|
Abstracting the Main Loop Function |
|
|
299 | (2) |
|
Refactoring Our Simulation |
|
|
301 | (4) |
|
Playing with the Circle Divisions |
|
|
302 | (1) |
|
Playing with the Affine Transformation |
|
|
303 | (2) |
|
|
305 | (1) |
|
|
305 | (2) |
|
12 Animating Affine Transformations |
|
|
307 | (30) |
|
Application Architecture and Visibility Diagrams |
|
|
308 | (1) |
|
|
309 | (2) |
|
Creating a Run Configuration |
|
|
310 | (1) |
|
|
310 | (1) |
|
Reading the Configuration File |
|
|
311 | (1) |
|
|
312 | (13) |
|
|
312 | (1) |
|
|
313 | (2) |
|
Parsing the Affine Transformation |
|
|
315 | (2) |
|
Parsing the Geometric Primitives |
|
|
317 | (8) |
|
|
325 | (9) |
|
Building the User Interface |
|
|
325 | (2) |
|
Implementing the Simulation Logic |
|
|
327 | (2) |
|
|
329 | (5) |
|
|
334 | (3) |
|
PART IV SYSTEMS OF EQUATIONS |
|
|
|
|
337 | (22) |
|
|
338 | (1) |
|
|
339 | (1) |
|
|
340 | (6) |
|
Implementing the Vector Class |
|
|
340 | (4) |
|
|
344 | (2) |
|
|
346 | (12) |
|
|
347 | (2) |
|
|
349 | (1) |
|
|
350 | (1) |
|
|
351 | (3) |
|
|
354 | (4) |
|
|
358 | (1) |
|
|
359 | (28) |
|
Systems of Linear Equations |
|
|
359 | (2) |
|
|
361 | (1) |
|
|
361 | (21) |
|
|
362 | (3) |
|
|
365 | (1) |
|
|
366 | (1) |
|
|
367 | (3) |
|
|
370 | (11) |
|
Testing Cholesky: An Integration Test |
|
|
381 | (1) |
|
|
382 | (5) |
|
|
|
|
387 | (40) |
|
Solving Structural Problems |
|
|
388 | (1) |
|
Structural Member Internal Forces |
|
|
388 | (4) |
|
Elastic Bodies Subject to External Forces |
|
|
389 | (1) |
|
|
390 | (1) |
|
Bending and Torsional Moments |
|
|
391 | (1) |
|
|
392 | (2) |
|
|
392 | (1) |
|
|
393 | (1) |
|
|
394 | (2) |
|
|
396 | (1) |
|
Stiffness Matrices in Global Coordinates |
|
|
397 | (3) |
|
|
400 | (11) |
|
|
400 | (4) |
|
|
404 | (4) |
|
|
408 | (2) |
|
Creating a Structure from the Python Shell |
|
|
410 | (1) |
|
The Structure Solution Model |
|
|
411 | (15) |
|
|
411 | (3) |
|
|
414 | (7) |
|
|
421 | (5) |
|
|
426 | (1) |
|
|
427 | (38) |
|
|
428 | (19) |
|
Interpreting the Stiffness Matrix Terms |
|
|
429 | (1) |
|
|
429 | (1) |
|
The Main Structure Resolution Algorithm |
|
|
430 | (2) |
|
Numbering Degrees of Freedom |
|
|
432 | (1) |
|
Assembling and Resolving the System of Equations |
|
|
433 | (8) |
|
|
441 | (2) |
|
|
443 | (4) |
|
Advanced Unit Testing: Test Doubles |
|
|
447 | (6) |
|
|
447 | (1) |
|
The unittest.mock Package |
|
|
448 | (5) |
|
Testing the Structure Solution Class |
|
|
453 | (4) |
|
Testing the Structure Resolution Process |
|
|
457 | (6) |
|
|
463 | (2) |
|
17 Reading Input From A File |
|
|
465 | (28) |
|
Defining the Input Format |
|
|
465 | (3) |
|
|
466 | (1) |
|
|
466 | (1) |
|
|
467 | (1) |
|
|
467 | (1) |
|
Finding the Regular Expressions |
|
|
468 | (3) |
|
|
468 | (1) |
|
|
469 | (1) |
|
|
470 | (1) |
|
|
471 | (1) |
|
|
471 | (3) |
|
|
473 | (1) |
|
|
474 | (2) |
|
|
475 | (1) |
|
|
476 | (2) |
|
|
477 | (1) |
|
|
478 | (14) |
|
|
479 | (1) |
|
|
480 | (1) |
|
Ignoring Blank Lines and Comments |
|
|
480 | (1) |
|
|
481 | (2) |
|
Splitting the Lines and Instantiating the Structure |
|
|
483 | (1) |
|
|
484 | (3) |
|
Testing the Structure Parser |
|
|
487 | (5) |
|
|
492 | (1) |
|
18 Producing An Svg Image And Text File |
|
|
493 | (36) |
|
|
494 | (1) |
|
From Structure Solution to SVG |
|
|
494 | (27) |
|
|
495 | (1) |
|
|
496 | (1) |
|
The Solution Drawing Function |
|
|
497 | (2) |
|
|
499 | (2) |
|
|
501 | (8) |
|
|
509 | (2) |
|
|
511 | (6) |
|
|
517 | (1) |
|
|
518 | (1) |
|
|
519 | (2) |
|
From Structure Solution to Text |
|
|
521 | (7) |
|
Structure Solution's String |
|
|
522 | (1) |
|
|
523 | (2) |
|
|
525 | (1) |
|
|
526 | (1) |
|
|
527 | (1) |
|
|
528 | (1) |
|
19 Assembling Our Application |
|
|
529 | (18) |
|
|
529 | (1) |
|
|
530 | (1) |
|
|
531 | (3) |
|
|
534 | (1) |
|
|
535 | (1) |
|
|
536 | (10) |
|
Playing with the Arguments |
|
|
540 | (2) |
|
Solving a Large Structure |
|
|
542 | (4) |
|
|
546 | (1) |
Bibliography |
|
547 | (2) |
Index |
|
549 | |