📜  Python| sympy Triangle() 方法

📅  最后修改于: 2022-05-13 01:54:44.363000             🧑  作者: Mango

Python| sympy Triangle() 方法

函数Triangle()将给定的点作为三角形的顶点,并在面积的帮助下计算三角形的面积。
Syntax: Triangle(x, y, z).area

Parameters: where x, y, z are coordinates.

Return: Area of triangle.

示例 #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)


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)



输出:
1/2

示例 #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)


输出:
1