Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering SciPy

You're reading from   Mastering SciPy Implement state-of-the-art techniques to visualize solutions to challenging problems in scientific computing, with the use of the SciPy stack

Arrow left icon
Product type Paperback
Published in Nov 2015
Publisher
ISBN-13 9781783984749
Length 404 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Francisco Javier Blanco-Silva Francisco Javier Blanco-Silva
Author Profile Icon Francisco Javier Blanco-Silva
Francisco Javier Blanco-Silva
Francisco Javier B Silva Francisco Javier B Silva
Author Profile Icon Francisco Javier B Silva
Francisco Javier B Silva
Arrow right icon
View More author details
Toc

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:

Plane geometry
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...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image