Example: bankruptcy

Python Programming in OpenGL

Python Programming in OpenGL A Graphical Approach to Programming Stan Blank, Wayne City High School Wayne City, Illinois 62895 October 6, 2009 Copyright 2009 2 Table of Contents Chapter 1 Chapter 2 Needs, Expectations, and Justifications ..8 Section What preparation do you need? ..8 Section What hardware and software do you need?..8 Section My Expectations ..9 Section Your Expectations ..9 Section Section Python Installation ..11 Exercises ..12 Chapter 3 Your First Python Program ..13 Section Super-3 Numbers ..13 Section Conclusion ..21 Exercises ..21 Chapter 4 Your First OpenGL Section The Interactive Python Interpreter ..23 Section Introducing Python OpenGL ..24 Section Odds, Ends, and Terminology ..29 Section Conclusion ..31 Exercises ..31 Chapter 5 2 Dimensional Graphics ..33 Section Plotting Points ..33 Exercises ..37 Section Plotting 2D Functions ..41 Exercises ..44 Sections Parametric Equations.

Oct 06, 2009 · Python Programming in OpenGL/GLUT Chapter 1 Introduction Before we begin our journey with Python and OpenGL, we first need to go back in time. History serves many purposes, but one of its more important functions is to provide us with a reference point so that we may see how far we’ve traveled. We’ll go

Tags:

  Introduction, Python

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of Python Programming in OpenGL

1 Python Programming in OpenGL A Graphical Approach to Programming Stan Blank, Wayne City High School Wayne City, Illinois 62895 October 6, 2009 Copyright 2009 2 Table of Contents Chapter 1 Chapter 2 Needs, Expectations, and Justifications ..8 Section What preparation do you need? ..8 Section What hardware and software do you need?..8 Section My Expectations ..9 Section Your Expectations ..9 Section Section Python Installation ..11 Exercises ..12 Chapter 3 Your First Python Program ..13 Section Super-3 Numbers ..13 Section Conclusion ..21 Exercises ..21 Chapter 4 Your First OpenGL Section The Interactive Python Interpreter ..23 Section Introducing Python OpenGL ..24 Section Odds, Ends, and Terminology ..29 Section Conclusion ..31 Exercises ..31 Chapter 5 2 Dimensional Graphics ..33 Section Plotting Points ..33 Exercises ..37 Section Plotting 2D Functions ..41 Exercises ..44 Sections Parametric Equations.

2 50 Exercises ..53 Section An Example from Physics ..65 Exercises ..74 Section Polar Section Conclusion ..89 Exercises ..90 Figures for Exercises 2-15 ..95 Chapter 6 Patterns and Chaos in 2 Dimensions ..99 Section Section Some Interesting Patterns ..101 Exercises ..106 Figures for exercises 7, 8, 9, and Section The Chaos Game ..112 Exercises ..124 Section The Barnsley Exercises ..133 Section Chaos and the Logistic Map ..136 Exercises ..143 Section Predator-prey Relationships ..148 Exercises ..152 3 Chapter 7 Strange Attractors and Beautiful Section Lorenz and the Weather ..154 Exercises ..162 Section Phase Portraits and Paint Exercises ..170 Section Mira (Look?)..172 Exercises ..174 Section The 3-Body Exercises ..178 Section Newton s Method and the Complex Plane ..183 Exercises ..193 Addendum: ..203 Addendum II: ..203 Section The Julia Set ..205 Exercises ..211 Section Explorations with the Mandelbrot Set.

3 222 Exercises ..240 Chapter 8 2D Animation ..246 Section Follow the Bouncing Ball ..246 Exercises ..255 Section A Little Gravity! ..261 Exercises ..264 Section A Little MORE a 2-Body Simulation ..265 Exercises ..279 Section The REAL 3 Body Problem ..281 Exercises ..291 Section From 3 Body to NBody Using Exercises ..307 Section Navigating the Stars ..309 Exercises ..320 Chapter 9 3D and 3D Animation ..322 Section Rotating Objects in Space ..322 Exercises ..330 Section Real Time Interactive Computer Animator (RTICA) ..336 The German Exercises ..350 illiTorus ..353 Exercises ..359 Chapter 10 Animation and Display Lists ..370 Electron The Quaternion Julia Set ..375 Alternate Quaternion Julia Set and Mandelbrot Chapter 11 Miscellaneous Programs ..388 The Random The 3D Sierpinski Sponge ..391 Rendering 4A Midpoint Conjecture ..397 Fog ..405 Nate Robins and Multiview ..415 Chapter 12 The Sphere ..421 The Bouncing Bouncing Ball VPython Lorenz.

4 424 VPython Mandlebrot ..426 5 My heartfelt thanks to Professor George K. Francis Without his inspiration, interest, and mentoring, NONE of this would have been possible 6 Python Programming in OpenGL /GLUT Chapter 1 introduction Before we begin our journey with Python and OpenGL , we first need to go back in time. History serves many purposes, but one of its more important functions is to provide us with a reference point so that we may see how far we ve traveled. We ll go back to about 1980 and the first computer Programming class in our high school. We were the proud owners of a single new Commodore VIC-20 and an old black and white TV that served as a monitor (almost). There were about 5 or 6 students in the class and we began to learn to program in There were no graphics worth mentioning and the only thing I remember is that we made such a fuss about getting the VIC to find the prime numbers from 2 to 997. If memory serves, it took about 30 minutes for the VIC to run this sophisticated 2 prime finding program.

5 We had no disk storage and the memory in the computer was I think the processor speed was about 1 Mhz and might have been much lower4, but we didn t care because we were computing! The next step occurred the following year when we purchased 10 TI 99/4a computers for $50 They were not much better than the VIC-20, but we at least were able to store programs using cassette tape recorders. Cassette storage wasn t much fun, extremely slow, and unreliable. I remember some slow, crude rudimentary graphics, but nothing that stands out in my mind. Finally, in 1982, things began to get exciting. We were able to purchase several Apple II+ computers with disk drives. We thought we were in heaven! The Apples were neat looking, nearly indestructible6, and much faster than anything we had used previously. Plus, they could actually produce usable GRAPHICS. Not just crude blocky stuff (which you could choose if you but why?), but nice points and lines on the screen!

6 These Apples had 64K of memory (all you could ever or so we thought) and the disk storage was amazing. We could store 140K of programs on one floppy disk!7 Our prime number generator took only 53 seconds on the Apple, which was over 30 times faster than the VIC- 20. Had I been acquainted with my friend George Francis at that time, we would have been able to do even more with these dependable Our final conversion was to the PC platform in 1987-88. We now had a lab of 12 true-blue IBM PC s with color monitors and hard drives running Windows (or was it 1 BASIC is a computer Beginner s All-Purpose Symbolic Instruction Code. It has been much maligned over the years; unjustly in my opinion. 2 Here, sophisticated means brute strength and ignorance . But the program worked and we were thrilled! 3 This is 4 thousand bytes of memory. Compare this to my current laptop which has 2 BILLION (gigabytes) of memory.)

7 4 Again, my current laptop has a processor that runs at 2 Ghz, over 2000x faster! 5 These were truly awful computers. Texas Instruments introduced them at a price of over $1000 and ended up selling them at Wal-Mart for $ I m not certain they were worth that much. 6 I personally saw one dropped on a concrete sidewalk. It bounced once or twice and worked fine for several years afterward. No, I wasn't the one who dropped it. 7 Again, my trusty laptop has a 60 gigabyte hard drive. That s 60 billion bytes. I also have a portable USB "diskless" drive that holds nearly 2000x the capacity of that Apple disk! 8 UIUC Math Prof. George K. Francis had a lab of Apples then that did some amazing graphics with a 1983 Forth compiler written by one of his colleagues. It would have been nice to have that! ). By today s standards, they were painfully slow, but at the time we thought that we were cutting edge. Memory was now in the megabyte range and processor speed was over 10 Mhz.

8 I remember plotting Mandelbrot sets in less than 10 minutes, which was relatively fast for that era. We have steadily improved to our present lab setup of PC machines running nearly at 1 Ghz (or faster) with at least 128 mb of RAM (or more) and dedicated video cards for The computers in our labs are supercomputers compared to where we started! In fact, if we were to take the computer in front of you back to 1980, it would have been one of the fastest on the planet! So this was a brief history of our high school computer lab. The Programming class curriculum followed the lab, as you might guess. We would spend 3 quarters learning to program and then the 4th quarter was reserved for student projects. Invariably, once graphic capabilities were available, all 4th quarter projects would involve graphics. The first graphics on the Apple were slow and rather crude by present standards. They were barely interactive, if at all. Even on our first PC s it would take several minutes to display minimal fractal images.

9 Not so today. With the computers we have in our lab we can create sophisticated graphics that can be manipulated in something we didn t even dream of back in 1980! It only took me 20 years to realize that my students were trying to tell me something! For the past 5 years we have concentrated on learning computer Programming through computer graphics and that is what you will be doing this year. Learning how to program is hard work, but at the same time, it is very rewarding and can be great fun! So, if a picture is worth a thousand words, how much more valuable is a changeable, interactive, creative graphics scene? You can graph mathematical functions in 2D, 3D, and even 4D. You can create true stereo images! You can design programs to simulate real-world events and you can manipulate the laws of physics and create your own worlds. If you are an artist, the computer becomes your easel. If you like games, you can program your own according to your own specifications.

10 The computer can become a window into your mind and your limitations are governed by your imagination. What you can envision, you can create! Now how cool is that? Oh, I forgot to say that you can make a fantastic living doing this just ask the folks at 9 Previous computers used the cpu and onboard memory for graphics. This made them slow. A dedicated graphics board handles most of the work and has its own much speedier memory. This allows us to create some rather fancy graphics. By comparison, my laptop has 256 mb of video memory more than the system memory of many computers. 10 You know, the people who made The Incredibles and other such movies. Chapter 2 Needs, Expectations, and Justifications Section What preparation do you need? In order to successfully complete this class, you will need to have some knowledge of computer operations as a prerequisite. This class is NOT an introduction to computers or a computer concepts class.


Related search queries