A maior rede de estudos do Brasil

Grátis
433 pág.

## Pré-visualização | Página 1 de 50

```Python Programming in OpenGL

A Graphical Approach to Programming

Stan Blank, Ph.D.
Wayne City High School
Wayne City, Illinois
62895

October 6, 2009

2
Chapter 1 Introduction......................................................................................6
Chapter 2 Needs, Expectations, and Justifications ..........................................8
Section 2.1 What preparation do you need? ...............................................8
Section 2.2 What hardware and software do you need?.............................8
Section 2.3 My Expectations .......................................................................9
Section 2.5 Justifications...........................................................................10
Section 2.6 Python Installation ..................................................................11
Exercises .....................................................................................................12
Chapter 3 Your First Python Program ............................................................13
Section 3.1 Super-3 Numbers ...................................................................13
Section 3.2 Conclusion .............................................................................21
Exercises .....................................................................................................21
Chapter 4 Your First OpenGL Program..........................................................23
Section 4.1 The Interactive Python Interpreter ..........................................23
Section 4.2 Introducing Python OpenGL...................................................24
Section 4.3 Odds, Ends, and Terminology ................................................29
Section 4.4 Conclusion .............................................................................31
Exercises .....................................................................................................31
Chapter 5 2 Dimensional Graphics ................................................................33
Section 5.1 Plotting Points ........................................................................33
Exercises .....................................................................................................37
Section 5.2 Plotting 2D Functions .............................................................41
Exercises .....................................................................................................44
Sections 5.3 Parametric Equations .............................................................50
Exercises .....................................................................................................53
Section 5.4 An Example from Physics ......................................................65
Exercises .....................................................................................................74
Section 5.5 Polar Coordinates...................................................................80
Section 5.6 Conclusion .............................................................................89
Exercises .....................................................................................................90
Figures for Exercises 2-15...........................................................................95
Chapter 6 Patterns and Chaos in 2 Dimensions ............................................99
Section 6.1 PySkel ....................................................................................99
Section 6.2 Some Interesting Patterns....................................................101
Exercises ...................................................................................................106
Figures for exercises 7, 8, 9, and 10..........................................................111
Section 6.3 The Chaos Game.................................................................112
Exercises ...................................................................................................124
Section 6.4 The Barnsley Fern...............................................................129
Exercises ...................................................................................................133
Section 6.5 Chaos and the Logistic Map................................................136
Exercises ...................................................................................................143
Section 6.6 Predator-prey Relationships.................................................148
Exercises ...................................................................................................152
3
Chapter 7 Strange Attractors and Beautiful Fractals ....................................154
Section 7.1 Lorenz and the Weather.......................................................154
Exercises ...................................................................................................162
Section 7.2 Phase Portraits and Paint Swirls ..........................................167
Exercises ...................................................................................................170
Section 7.3 Mira (Look?) .........................................................................172
Exercises ...................................................................................................174
Section 7.4 The 3-Body Problem ............................................................175
Exercises ...................................................................................................178
Section 7.5 Newton’s Method and the Complex Plane ...........................183
Exercises ...................................................................................................193
Section 7.6 The Julia Set .......................................................................205
Exercises ...................................................................................................211
Section 7.7 Explorations with the Mandelbrot Set ...................................222
Exercises ...................................................................................................240
Chapter 8 2D Animation...............................................................................246
Section 8.1 Follow the Bouncing Ball ......................................................246
Exercises ...................................................................................................255
Section 8.2 A Little Gravity! .....................................................................261
Exercises ...................................................................................................264
Section 8.3 A Little MORE Gravity... a 2-Body Simulation ......................265
Exercises ...................................................................................................279
Section 8.4 The REAL 3 Body Problem ..................................................281
Exercises ...................................................................................................291
Section 8.5 From 3Body to NBody Using Arrays.....................................294
Exercises ...................................................................................................307
Section 8.6 Navigating the Stars ............................................................309```