Points
A location is a point in geometry. It has no dimensions, i.e. no width, length, or depth. A dot represents a point. Collinearity is the property of a set of points lying on a single line in geometry. Collinearity refers to a group of points that have this property. Point() function is used to create a point in space. Point class contains the distance() method to find the distance between two points.
Python3
# import packages from sympy.geometry import Point # create points x = Point( 1 , 1 ) y = Point( 2 , 2 ) z = Point( 3 , 3 ) w = Point( 5 , 2 ) # checking if points are collinear. print (Point.is_collinear(x, y, z)) print (Point.is_collinear(y, z, w)) # calculating distance between two points print ( 'Distance between x and y points is ' + str (x.distance(y))) |
Output:
True False Distance between x and y points is sqrt(2)
The formula for distance of a point from origin:
Python3
# importing packages from sympy.geometry import Point from sympy.abc import a, b # defining a point p = Point(a, b) # distance of the point from the origin print (p.distance(Point( 0 , 0 ))) |
Output:
sqrt(a**2 + b**2)
What are Entities in SymPy?
The geometry module in SymPy is the foundation class for all geometrical entities Python, allowing you to create two-dimensional objects like lines and circles, polygons, etc. Then we may find out more about it by looking for collinearity or detecting intersections. Any object with particular geometric qualities is referred to as a GeometryEntity.
class sympy.geometry.entity.GeometryEntity(*args, **kwargs)
All geometrical entities inherit from this basic class. This class does not represent any specific geometric entity; instead, it implements several methods that are shared by all subclasses.