CONTENTS IN DETAIL

ACKNOWLEDGMENTS

INTRODUCTION

Who This Book Is For

What You’ll Learn

About This Book

What Is the “Hardcore” About?

Why Python?

Contents at a Glance

Setting Up Your Environment

Downloading the Book’s Code

Installing Python

Installing and Configuring PyCharm

PyCharm Introduction

Creating Packages and Files

Creating Run Configurations

Debugging Python Code

Summary

PART I
BASICS

1
A SHORT PYTHON PRIMER

Python Packages and Modules

Modules

Packages

Running Files

Importing Code

Different Import Forms

Documenting the Code with Docstrings

Collections in Python

Sets

Tuples

Lists

Dictionaries

Destructuring

Summary

2
TWO PYTHON PARADIGMS

Functional Programming

Pure Functions

Immutability

Lambdas

Higher-Order Functions

Functions Inside Other Functions

Filter, Map, and Reduce

List Comprehensions

Object-Oriented Programming

Classes

Magic Methods

Type Hints

Summary

3
THE COMMAND LINE

Unix and Windows

Finding Your Shell

Installing the Windows Subsystem for Linux

Taking a First Look at the Shell

Files and Directories

Moving Around

Creating Files and Directories

Deleting Files and Directories

Commands Summary

Using Windows Subsystem for Linux

Running Python Scripts

Passing Arguments to the Script

Standard Input and Output

Redirecting the Output to a File

Redirecting the Input from a File

Using PyCharm’s Python Console

Summary

PART II
2D GEOMETRY

4
POINTS AND VECTORS

The Point Class

Calculating Distance Between Points

Addition and Subtraction Operators

The Vector Class

Addition and Subtraction Operators

Scaling Vectors

Displacing Points

Vector Norms

Immutable Design

Naming Convention

Dot Product

Projecting Vectors

Cross Product

Parallel and Perpendicular Vectors

Angles Between Vectors

Rotating Vectors

Sine and Cosine

Completing Our Classes

Checking Equality

String Representation

Vector Factories

Unit Testing

Testing Distances

Testing Vector Plus and Minus Operations

Testing Vector Product Operations

Testing Vector Parallelism and Perpendicularity

Three Golden Rules for Unit Testing

Summary

5
LINES AND SEGMENTS

Segment Class

The Segment’s Direction

The Segment’s Length

The t Parameter and Middle Points

Closest Point

Distance to a Point

Segment Intersections

Equality and String Representation

Line Class

Line Intersections

Segment’s Bisector

Summary

6
POLYGONS

Polygon Class

Sides

Centroid

Contains Point

Polygon Factory

Polygon Equality

Circle Class

Contains Point

Circle to Polygon

Equality and String Representation

Circle Factories

Rect Class

Contains Point

Intersections

Convert to Polygon

Equality

Rectangle Factories

Summary

7
AFFINE TRANSFORMATIONS

Affine Transformations

Examples of Affine Transformations

The Affine Transformation Class

Testing the Transformation of Points

Transform Segments and Polygons

Concatenating Transformations

Inverting Affine Transformations

Scaling

Rotating

Interpolating Transformations

Motivating Interpolation

Implementing Interpolation

Geom2D Final Touches

Test Files

Running All Tests

Package Imports

Summary

PART III
GRAPHICS AND SIMULATIONS

8
DRAWING VECTOR IMAGES

Bitmaps and Vector Images

The SVG Format

The viewBox

Space Transformation

The svg Package

Templates

Loading Templates

Image Templates

Attributes

The SVG Primitives

Lines

Rectangles

Circles

Polygons

Polylines

Text

Groups

Arrows

Primitives Result

Package Imports

Summary

9
BUILDING A CIRCLE FROM THREE POINTS

Application Architecture

Setup

Creating a Run Configuration

Why Use a Run Configuration?

Reading the Input and Configuration Files

Regular Expressions

Regular Expressions Cheat Sheet

Matching Points

The Configuration File

Problem Model and Resolution

Generating Output

Drawing the Output Circle

Drawing the Input Points

Result

Flip the Y-Axis

Distributing Our Application

Understanding the Problem

Finding a Solution

Running the App Without an Input File

Summary

10
GRAPHICAL USER INTERFACES AND THE CANVAS

Tkinter

Our First GUI Program

The Canvas

Drawing Our Geometric Primitives

The Canvas Wrapper Class

Drawing Segments

Drawing Polygons

Drawing Arrows

Summary

11
ANIMATIONS, SIMULATIONS, AND THE TIME LOOP

Defining Terms

What Is an Animation?

What Is a System?

What Is a Simulation?

What Is the Time Loop?

Our First Animation

Setup

Adding a Frame Count Label

Updating the System

Creating Motion

Abstracting the Main Loop Function

Refactoring Our Simulation

Playing with the Circle Divisions

Playing with the Affine Transformation

Cleaning Up the Module

Summary

12
ANIMATING AFFINE TRANSFORMATIONS

Application Architecture and Visibility Diagrams

Setting Up

Creating a Run Configuration

Creating a Bash Script

Reading the Configuration File

Reading Input

Formatting the Input

Adding Example Input

Parsing the Affine Transformation

Parsing the Geometric Primitives

Running the Simulation

Building the User Interface

Implementing the Simulation Logic

Drawing the Axes

Summary

PART IV
SYSTEMS OF EQUATIONS

13
MATRICES AND VECTORS

List Utils

Setup

Vectors

Implementing the Vector Class

Testing the Vector Class

Matrices

Setting Values

Getting Values

Scaling Values

Matrix Equality

Testing the Matrix Class

Summary

14
LINEAR EQUATIONS

Systems of Linear Equations

Numerical Methods

Cholesky Decomposition

LU Factorization Methods

Understanding Cholesky

A Factorization by Hand

A Resolution by Hand

Implementing Cholesky

Testing Cholesky: An Integration Test

Summary

PART V
TRUSS STRUCTURES

15
STRUCTURAL MODELS

Solving Structural Problems

Structural Member Internal Forces

Elastic Bodies Subject to External Forces

Axial and Shear Forces

Bending and Torsional Moments

Tension and Compression

Hooke’s Law

Stress-Strain Diagrams

Plane Trusses

Two-Force Members

Stiffness Matrices in Global Coordinates

Original Structure Model

The Node Class

The Bar Class

The Structure Class

Creating a Structure from the Python Shell

The Structure Solution Model

The Solution Nodes

The Solution Bars

The Structure Solution

Summary

16
STRUCTURE RESOLUTION

Structure Resolution

Interpreting the Stiffness Matrix Terms

Structure Initialization

The Main Structure Resolution Algorithm

Numbering Degrees of Freedom

Assembling and Resolving the System of Equations

Creating the Solution

The Result

Advanced Unit Testing: Test Doubles

Test Doubles

The unittest.mock Package

Testing the Structure Solution Class

Testing the Structure Resolution Process

Summary

17
READING INPUT FROM A FILE

Defining the Input Format

The Nodes Format

The Loads Format

The Bars Format

The File Format

Finding the Regular Expressions

The Nodes Regex

The Loads Regex

The Bars Regex

Setup

Parsing Nodes

Testing the Node Parser

Parsing Bars

Testing the Bar Parser

Parsing Loads

Testing the Load Parser

Parsing the Structure

Overview

Setup

Ignoring Blank Lines and Comments

Parsing the Lines

Splitting the Lines and Instantiating the Structure

The Result

Testing the Structure Parser

Summary

18
PRODUCING AN SVG IMAGE AND TEXT FILE

Setup

From Structure Solution to SVG

The Configuration File

The Settings

The Solution Drawing Function

Captions

The Bars

The Nodes

The Node Reactions

The Loads

Putting It All Together

The Final Result

From Structure Solution to Text

Structure Solution’s String

The Nodes

The Bars

The Unicode Characters

Putting It All Together

Summary

19
ASSEMBLING OUR APPLICATION

A General Overview

Setup

Input Arguments

Generating the Output

The Main Script

Trying the App

Playing with the Arguments

Solving a Large Structure

Summary

BIBLIOGRAPHY

INDEX

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.32.213