Reader small image

You're reading from  Mastering SciPy

Product typeBook
Published inNov 2015
Reading LevelIntermediate
Publisher
ISBN-139781783984749
Edition1st Edition
Languages
Right arrow
Authors (2):
Francisco Javier Blanco-Silva
Francisco Javier Blanco-Silva
author image
Francisco Javier Blanco-Silva

I will always be indebted to Bradley J. Lucier and Rodrigo Bañuelos, for being a constant inspiration, for their guidance and teachings. Special thanks to my editors, Sriram Neelakantam, Bharat Patil, Nikhil Potdukhe, and Mohammad Rizvi. Many colleagues have contributed with encouragement and fruitful discussions. In particular, I would like to mention Parsa Bakhtary, Aaron Dutle, Edsel Peña, Pablo Sprechmann, Adam Taylor, and Holly Watson. But the most special thanks go without a doubt to my wife and daughter. Grace's love and smiles alone provided all the motivation, enthusiasm and skills to overcome any difficulties encountered during the pursuit of this book, and everything life threw at me ever since she was born.
Read more about Francisco Javier Blanco-Silva

View More author details
Right arrow

Plane geometry


The geometry module of the SymPy library covers basic geometry capabilities. Rather than giving an academic description of all objects and properties in that module, we discover the most useful ones through a series of small self-explanatory Python sessions.

We start with the concepts of point and segment. The aim is to illustrate how easily we can check for collinearity, compute lengths, midpoints, or slopes of segments, for example. We also show how to quickly compute the angle between two segments, as well as decide whether a given point belongs to a segment or not. The following diagram illustrates an example, which we will follow up with the code:

In [1]: from sympy.geometry import Point, Segment, Line, \
   ...:                            Circle, Triangle, Curve
In [2]: P1 = Point(0, 0); \
   ...: P2 = Point(3, 4); \
   ...: P3 = Point(2, -1); \
   ...: P4 = Point(-1, 5)
In [3]: statement = Point.is_collinear(P1, P2, P3); \
   ...: print "Are P1, P2, P3 collinear?," statement...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Mastering SciPy
Published in: Nov 2015Publisher: ISBN-13: 9781783984749

Authors (2)

author image
Francisco Javier Blanco-Silva

I will always be indebted to Bradley J. Lucier and Rodrigo Bañuelos, for being a constant inspiration, for their guidance and teachings. Special thanks to my editors, Sriram Neelakantam, Bharat Patil, Nikhil Potdukhe, and Mohammad Rizvi. Many colleagues have contributed with encouragement and fruitful discussions. In particular, I would like to mention Parsa Bakhtary, Aaron Dutle, Edsel Peña, Pablo Sprechmann, Adam Taylor, and Holly Watson. But the most special thanks go without a doubt to my wife and daughter. Grace's love and smiles alone provided all the motivation, enthusiasm and skills to overcome any difficulties encountered during the pursuit of this book, and everything life threw at me ever since she was born.
Read more about Francisco Javier Blanco-Silva