Open In App

Python | Sympy Line.is_perpendicular method

Last Updated : 25 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report
In Sympy, the function is_perpendicular() is used to check whether the two linear entities are perpendicular or not.
Syntax: Line.is_perpendicular(l2)

Parameters:
 l1: LinearEntity
 l2: LinearEntity

Returns:
 True: if l1 and l2 are perpendicular,
 False: otherwise.
Example #1: Python3 1==
# import sympy and Point, Line
from sympy import Point, Line
 
p1, p2, p3 = Point(0, 0), Point(1, 1), Point(-1, 1)

l1, l2 = Line(p1, p2), Line(p1, p3)

# using is_perpendicular() method
isPerpendicular = l1.is_perpendicular(l2)

print(isPerpendicular)
Output:
True
Example #2: Python3 1==
# import sympy and Point, Line
from sympy import Point, Line
 
p1, p2, p3 = Point(0, 0), Point(1, 1), Point(5, 3)

l1, l2 = Line(p1, p2), Line(p1, p3)

# using is_perpendicular() method
isPerpendicular = l1.is_perpendicular(l2)

print(isPerpendicular)
Output:
False

Next Article
Article Tags :
Practice Tags :

Similar Reads