Book Image

Mastering Python Scientific Computing

Book Image

Mastering Python Scientific Computing

Overview of this book

Table of Contents (17 chapters)
Mastering Python Scientific Computing
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The geometry module


The geometry module allows creation, manipulation, and computations on two-dimensional shapes, including points, lines, circles, ellipses, polygons, triangles, and others. The next program demonstrates the creation of these shapes and some operations on the collinear function. This function tests whether a given set of points is collinear, and it returns true if they are collinear. Points are called collinear if they lie on a single straight line. The medians function returns a dictionary with a vertex as the key, and the value is the median at that vertex. The intersection function finds the intersection points of two or more geometrical entities. Whether a given line is a tangent to a circle or not is determined by the is_tangent method.

The circumference function returns the circumference of a circle, and the equation function returns the circle in its equation form:

from sympy import *
from sympy.geometry import *

x = Point(0, 0)
y = Point(1, 1)
z = Point(2, 2)
zp...