• Complain

B. J. Korites - Python Graphics: A Reference for Creating 2D and 3D Images

Here you can read online B. J. Korites - Python Graphics: A Reference for Creating 2D and 3D Images full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2018, publisher: Apress, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

B. J. Korites Python Graphics: A Reference for Creating 2D and 3D Images
  • Book:
    Python Graphics: A Reference for Creating 2D and 3D Images
  • Author:
  • Publisher:
    Apress
  • Genre:
  • Year:
    2018
  • Rating:
    3 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 60
    • 1
    • 2
    • 3
    • 4
    • 5

Python Graphics: A Reference for Creating 2D and 3D Images: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Python Graphics: A Reference for Creating 2D and 3D Images" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Use built-in Python features to create innovative graphics for data visualization and technical illustrations. This book goes beyond simple commands and libraries to explain how to not only display but also rotate, shade, and edit graphics for any purpose.

Starting with the essential Python functions to set up a plotting space and produce 2 and 3-dimensional objects, youll learn how to construct more complex objects, translate and rotate them, remove hidden lines, introduce shading to add realism, and project images to visualize any dataset. The final chapter includes several worked applications in science and engineering including planetary models, which you can adapt for your own use.

Written for developers who want to harness Pythons capabilities to fine-tune their images, Python Graphics covers the different commands for plotting dots, lines, arrows, or arcs, creating custom plotting grids, correcting distortions, adding text and labels to illustrations, manipulating arcs and circles, specify and use colors, and more. Armed with these techniques and core math skills, youll be ready to create and customize detailed technical illustrations or data visualizations.

What Youll Learn

  • Use Pythons built-in commands for plotting, removing distortions, and rotating objects

  • Create and edit 2D and 3D objects

  • Develop illustrations for scientific and engineering applications

Who This Book Is For


Python developers looking for tips on how to create illustrations and visualizations, as well as scientists, engineers, or students using Python. It assumes familiarity with vectors, matrices, geometry and trigonometry.

B. J. Korites: author's other books


Who wrote Python Graphics: A Reference for Creating 2D and 3D Images? Find out the surname, the name of the author of the book and a list of all author's works by series.

Python Graphics: A Reference for Creating 2D and 3D Images — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Python Graphics: A Reference for Creating 2D and 3D Images" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
B.J. Korites 2018
B.J. Korites Python Graphics
1. Essential Python Commands and Functions
B. J. Korites 1
(1)
Duxbury, Massachusetts, USA
In this chapter, you will learn the essential Python commands and functions you will need to produce the illustrations shown in this book. You will learn how to use Pythons basic plotting functions, set up a plotting area, create a set of two-dimensional coordinate axes, and use basic plotting primitives (the dot, the line, and the arrow), which are the building blocks you will use to construct images throughout this book. In Chapter .
Figure 1-1 Saturn 11 Programming Style First a note on the programming - photo 1
Figure 1-1
Saturn
1.1 Programming Style
First a note on the programming style used in this book. We all have preferences when it comes to style. I favor a clear, top-down, open style. Many programmers try to reduce their code to as few lines as possible. That may be fine in practice but in an instructional text, such as we have here, I believe it is better to proceed slowly in small, simple steps. The intention is to keep everything clear and understandable. Since I do not know the skill level of the readers, and since I want to make this book accessible to as wide an audience as possible, I generally start each topic from an elementary level, although I do assume some familiarity with the Python language. If you are just learning Python, you will benefit from the material in this first chapter. If you are an accomplished Pythoner, you could probably skip it and move on to Chapter .
Some Python developers advocate using long descriptive names for variables such as temperature rather than T. I find excessively long variable names make the code difficult to read. Its a matter of preference. With relatively short programs such as we have in this book, theres no need for complex programming. Try to adopt a style that is robust rather than elegant but fragile.
My programs usually have the same structure. The first few statements are generally import numpy as np , import matplotlib.pyplot as plt , and so on. Sometime I will import from the math library with from math import sin, cos, radians, sqrt . These are commonly used functions in graphics programming. Importing them separately in this way eliminates the need to use prefixes as in np .sin(); you can just use sin() . Then I most often define the plotting area with plt.axis([0,150,100,0]) . As explained in Section 1.2, these values, where the x axis is 50% wider than the y axis, produce a round circle and a square square without reducing the size of the plotting area. At this point, axes can be labelled and the plot titled if desired. Next, I usually define parameters (such as diameters, time constants, and so on) and lists. Then I define functions. Finally, in lengthy programs, at the bottom I put a control section that invokes the functions in the proper order.
Including plt.axis('on') plots the axes; plt.grid(True) plots a grid. They are very convenient options when developing graphics. However, if I do not want the axes or grid to show in the final output, I replace these commands with plt.axis('off') and plt.grid(False) . The syntax must be as shown here. See Section 1.10 to learn how to create your own grid lines if you are not satisfied with Pythons defaults.
I often begin development of graphics by using the scatter() function which produces what I call scatter dots . They are fast and easy to use and are very useful in the development stage. If kept small enough and spaced closely together, dots can produce acceptable lines and curves. However, they can sometimes appear a bit fuzzy so, after I have everything working right, I will often go back and replace the dots with short line segments using either arrows via plt.arrow() or lines via plt.plot() . There is another aspect to the choice of dots or lines: which overplots which. You dont want to create something with dots and then find lines covering it up. This is discussed in Section 1.14.
Some variants of Python require the plt.show() statement at the end to plot graphics. My setup, Anaconda with Spyder and Python 3.5 (see Appendix A for installation instructions), does not require this but I include it anyway since it serves as a marker for the end of the program. Finally, press the F5 key or click on the Run button at the top to see what you have created. After you are satisfied, you can save the plot by right-clicking it and specifying a location.
Regarding the use of lists, tuples and arrays, they can be a great help, particularly when doing graphics programming that involves a lot of data points. They are explained in Section 1.19.5. An understanding of them, together with a few basic graphics commands and techniques covered in this chapter, are all you need to create the illustrations and images you see in this book.
1.2 The Plotting Area
A computer display with a two-dimensional coordinate system is shown in Figure . In this example, the origin of the x,y coordinate axes, (x=0, y=0), is located in the center of the screen. The positive x axis runs from the origin to the right; the y axis runs from the origin vertically downward. As you will see shortly, the location of the origin can be changed as can the directions of the x and y axes. Also shown is a point p at coordinates (x,y), which are in relation to the x and y axes.
The direction of the y axis pointing down in Figure may seem a bit unusual. When plotting data or functions such as y=cos(x) or y=exp(x), we usually think of y as pointing up. But when doing technical graphics , especially in three dimensions, as you will see later, it is more intuitive to have the y axis point down. This is also consistent with older variants of BASIC where the x axis ran along the top of the screen from left to right and the y axis ran down the left side. As you will see, you can define y to point up or down, whichever best suits what you are plotting.
1.3 Establishing the Size of the Plotting Area
The plotting area contains the graphic image. It always appears the same physical size when displayed in the Spyder output pane. Spyder is the programming environment (see Appendix A). However, the numerical size of the plotting area, and of the values of the point, line, and arrow definitions within the plotting area, can be specified to be anything. Before doing any plotting, you must first establish the areas numerical size. You must also specify the location of the coordinate systems origin and the directions of the coordinate axes. As an illustration, Listing uses the plt.axis([x1,x2,y1,y2]) function in line 8 to set up an area running from x=-10 to +10; y=10 to +10. The rest of the script will be explained shortly.
Figure 1-2 A two-dimensional xy coordinate system with its origin 00 - photo 2
Figure 1-2
A two-dimensional x,y coordinate system with its origin (0,0) centered in the screen. A point p is shown at coordinates (x,y) relative to x,y.
1 import numpy as np
2 import matplotlib.pyplot as plt
4 x1=-10
5 x2=10
6 y1=-10
7 y2=10
8 plt.axis([x1,x2,y1,y2] )
10 plt.axis('on')
11 plt.grid(True)
13 plt.show()
Listing 1-1
Program PLOTTING_AREA
Listing will be explained in the following sections. These commands, or variations of them, will appear in all of our programs.
Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Python Graphics: A Reference for Creating 2D and 3D Images»

Look at similar books to Python Graphics: A Reference for Creating 2D and 3D Images. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Python Graphics: A Reference for Creating 2D and 3D Images»

Discussion, reviews of the book Python Graphics: A Reference for Creating 2D and 3D Images and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.