Open In App

Python | sympy Triangle() method

Last Updated : 02 Feb, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

The function Triangle() takes the given points as vertices of a triangle and computes the area of triangle with the help of area.

Syntax: Triangle(x, y, z).area

Parameters: where x, y, z are coordinates.

Return: Area of triangle.

Example #1:

Python3




# import sympy and geometry module
from sympy import * 
from sympy.geometry import * 
  
x = Point(0, 0)
y = Point(1, 1)
z = Point(1, 0)
  
# Using  Triangle(x, y, z).area
giveArea = Triangle(x, y, z).area
  
print(giveArea)



Output:

1/2

Example #2:

Python3




# import sympy and geometry module
from sympy import * 
from sympy.geometry import * 
  
x = Point(1, 2)
y = Point(2, 0)
z = Point(1, 0)
  
# Using  Triangle(x, y, z).area
giveArea = Triangle(x, y, z).area
  
print(giveArea)



Output:

1

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

Similar Reads