Line
A line is defined as a set of points that stretches in two directions indefinitely. It just has one dimension, which is length. Line() is created with the help of two points. intersection() method is used to find the point of intersection between two lines. angle_between() function is used to find angles between two lines.
Python3
# importing packages from sympy.geometry import Point, Line # creating two points p1, p2 = Point( 1 , 2 ), Point( 2 , 0 ) line1 = Line(p1, p2) print (line1) # creating two points line2 = Line(Point( 2 , 4 ), Point( 6 , 2 )) print (line2) # intersection point of two lines print (line1.intersection(line2)) # Angle between the two lines print ('Angle between two lines is : \ ' + str (line1.angle_between(line2))) |
Output:
Line2D(Point2D(1, 2), Point2D(2, 0)) Line2D(Point2D(2, 4), Point2D(6, 2)) [Point2D(-2/3, 16/3)] Angle between two lines is : acos(4/5)
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.