concept dinosaur in category python

This is an excerpt from Manning's book Math for Programmers: 3D graphics, machine learning, and simulations with Python.
In the context of this grid, we can measure vectors in the plane. For example, in figure 2.5, the tip of the dinosaur’s tail lines up with positive 6 on the x-axis and positive 4 on the y-axis. We could think of these distances as centimeters, inches, pixels, or any other unit of length, but usually we leave the units unspecified unless we have a particular application in mind.
Figure 2.7: Plotting the dinosaur’s points with the draw function in Python
![]()
As a next step in our drawing process, we can connect some dots. A first segment might connect the point (6, 4) with the point (3, 1) on the dinosaur’s tail. We can draw the points along with this new segment using this function call, and figure 2.8 shows the results:
draw( Points(*dino_vectors), Segment((6,4),(3,1)) )Figure 2.8: The dinosaur’s points with a line segment connecting the first two points (6, 4) and (3, 1)
![]()
The line segment is actually the collection consisting of the points (6, 4) and (3, 1) as well as all of the points lying on the straight line between them. The draw function automatically colors all of the pixels at those points blue. The Segment class is a useful abstraction because we don’t have to build every segment from the points that make up our geometric object (in this case, the dinosaur). Drawing 20 more segments, we get the complete outline of the dinosaur (figure 2.9).
Figure 2.9: A total of 21 function calls give us 21 line segments, completing the outline of the dinosaur.
![]()