Open In App

Python | Sympy Line.is_perpendicular method

Last Updated : 30 Jan, 2020
Improve
Improve
Like Article
Like
Save
Share
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:




# 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:




# 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

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads