本文整理汇总了Python中sympy.geometry.Triangle.is_right方法的典型用法代码示例。如果您正苦于以下问题:Python Triangle.is_right方法的具体用法?Python Triangle.is_right怎么用?Python Triangle.is_right使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.geometry.Triangle
的用法示例。
在下文中一共展示了Triangle.is_right方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_polygon
# 需要导入模块: from sympy.geometry import Triangle [as 别名]
# 或者: from sympy.geometry.Triangle import is_right [as 别名]
#.........这里部分代码省略.........
#
# Angles
#
angles = p4.angles
assert feq(angles[Point(0, 0)].evalf(), Float("0.7853981633974483"))
assert feq(angles[Point(4, 4)].evalf(), Float("1.2490457723982544"))
assert feq(angles[Point(5, 2)].evalf(), Float("1.8925468811915388"))
assert feq(angles[Point(3, 0)].evalf(), Float("2.3561944901923449"))
angles = p3.angles
assert feq(angles[Point(0, 0)].evalf(), Float("0.7853981633974483"))
assert feq(angles[Point(4, 4)].evalf(), Float("1.2490457723982544"))
assert feq(angles[Point(5, 2)].evalf(), Float("1.8925468811915388"))
assert feq(angles[Point(3, 0)].evalf(), Float("2.3561944901923449"))
#
# Triangle
#
p1 = Point(0, 0)
p2 = Point(5, 0)
p3 = Point(0, 5)
t1 = Triangle(p1, p2, p3)
t2 = Triangle(p1, p2, Point(Rational(5, 2), sqrt(Rational(75, 4))))
t3 = Triangle(p1, Point(x1, 0), Point(0, x1))
s1 = t1.sides
assert Triangle(p1, p2, p1) == Polygon(p1, p2, p1) == Segment(p1, p2)
raises(GeometryError, lambda: Triangle(Point(0, 0)))
# Basic stuff
assert Triangle(p1, p1, p1) == p1
assert Triangle(p2, p2 * 2, p2 * 3) == Segment(p2, p2 * 3)
assert t1.area == Rational(25, 2)
assert t1.is_right()
assert t2.is_right() == False
assert t3.is_right()
assert p1 in t1
assert t1.sides[0] in t1
assert Segment((0, 0), (1, 0)) in t1
assert Point(5, 5) not in t2
assert t1.is_convex()
assert feq(t1.angles[p1].evalf(), pi.evalf() / 2)
assert t1.is_equilateral() == False
assert t2.is_equilateral()
assert t3.is_equilateral() == False
assert are_similar(t1, t2) == False
assert are_similar(t1, t3)
assert are_similar(t2, t3) == False
assert t1.is_similar(Point(0, 0)) == False
# Bisectors
bisectors = t1.bisectors()
assert bisectors[p1] == Segment(p1, Point(Rational(5, 2), Rational(5, 2)))
ic = (250 - 125 * sqrt(2)) / 50
assert t1.incenter == Point(ic, ic)
# Inradius
assert t1.inradius == t1.incircle.radius == 5 - 5 * sqrt(2) / 2
assert t2.inradius == t2.incircle.radius == 5 * sqrt(3) / 6
assert t3.inradius == t3.incircle.radius == x1 ** 2 / ((2 + sqrt(2)) * Abs(x1))
# Circumcircle
assert t1.circumcircle.center == Point(2.5, 2.5)
# Medians + Centroid
示例2: test_polygon
# 需要导入模块: from sympy.geometry import Triangle [as 别名]
# 或者: from sympy.geometry.Triangle import is_right [as 别名]
def test_polygon():
p1 = Polygon(
Point(0, 0), Point(3,-1),
Point(6, 0), Point(4, 5),
Point(2, 3), Point(0, 3))
p2 = Polygon(
Point(6, 0), Point(3,-1),
Point(0, 0), Point(0, 3),
Point(2, 3), Point(4, 5))
p3 = Polygon(
Point(0, 0), Point(3, 0),
Point(5, 2), Point(4, 4))
p4 = Polygon(
Point(0, 0), Point(4, 4),
Point(5, 2), Point(3, 0))
#
# General polygon
#
assert p1 == p2
assert len(p1) == Rational(6)
assert len(p1.sides) == 6
assert p1.perimeter == 5+2*sqrt(10)+sqrt(29)+sqrt(8)
assert p1.area == 22
assert not p1.is_convex()
assert p3.is_convex()
assert p4.is_convex() # ensure convex for both CW and CCW point specification
#
# Regular polygon
#
p1 = RegularPolygon(Point(0, 0), 10, 5)
p2 = RegularPolygon(Point(0, 0), 5, 5)
assert p1 != p2
assert p1.interior_angle == 3*pi/5
assert p1.exterior_angle == 2*pi/5
assert p2.apothem == 5*cos(pi/5)
assert p2.circumcircle == Circle(Point(0, 0), 5)
assert p2.incircle == Circle(Point(0, 0), p2.apothem)
assert p1.is_convex()
#
# Angles
#
angles = p4.angles
assert feq(angles[Point(0, 0)].evalf(), Real("0.7853981633974483"))
assert feq(angles[Point(4, 4)].evalf(), Real("1.2490457723982544"))
assert feq(angles[Point(5, 2)].evalf(), Real("1.8925468811915388"))
assert feq(angles[Point(3, 0)].evalf(), Real("2.3561944901923449"))
angles = p3.angles
assert feq(angles[Point(0, 0)].evalf(), Real("0.7853981633974483"))
assert feq(angles[Point(4, 4)].evalf(), Real("1.2490457723982544"))
assert feq(angles[Point(5, 2)].evalf(), Real("1.8925468811915388"))
assert feq(angles[Point(3, 0)].evalf(), Real("2.3561944901923449"))
#
# Triangle
#
p1 = Point(0, 0)
p2 = Point(5, 0)
p3 = Point(0, 5)
t1 = Triangle(p1, p2, p3)
t2 = Triangle(p1, p2, Point(Rational(5,2), sqrt(Rational(75,4))))
t3 = Triangle(p1, Point(x1, 0), Point(0, x1))
s1 = t1.sides
s2 = t2.sides
s3 = t3.sides
# Basic stuff
assert t1.area == Rational(25,2)
assert t1.is_right()
assert t2.is_right() == False
assert t3.is_right()
assert p1 in t1
assert Point(5, 5) not in t2
assert t1.is_convex()
assert feq(t1.angles[p1].evalf(), pi.evalf()/2)
assert t1.is_equilateral() == False
assert t2.is_equilateral()
assert t3.is_equilateral() == False
assert are_similar(t1, t2) == False
assert are_similar(t1, t3)
assert are_similar(t2, t3) == False
# Bisectors
bisectors = t1.bisectors
assert bisectors[p1] == Segment(p1, Point(Rational(5,2), Rational(5,2)))
ic = (250 - 125*sqrt(2)) / 50
assert t1.incenter == Point(ic, ic)
# Inradius
assert t1.inradius == 5 - 5*2**(S(1)/2)/2
assert t2.inradius == 5*3**(S(1)/2)/6
assert t3.inradius == (2*x1**2*Abs(x1) - 2**(S(1)/2)*x1**2*Abs(x1))/(2*x1**2)
# Medians + Centroid
m = t1.medians
#.........这里部分代码省略.........
示例3: test_polygon
# 需要导入模块: from sympy.geometry import Triangle [as 别名]
# 或者: from sympy.geometry.Triangle import is_right [as 别名]
#.........这里部分代码省略.........
#
# Angles
#
angles = p4.angles
assert feq(angles[Point(0, 0)].evalf(), Float("0.7853981633974483"))
assert feq(angles[Point(4, 4)].evalf(), Float("1.2490457723982544"))
assert feq(angles[Point(5, 2)].evalf(), Float("1.8925468811915388"))
assert feq(angles[Point(3, 0)].evalf(), Float("2.3561944901923449"))
angles = p3.angles
assert feq(angles[Point(0, 0)].evalf(), Float("0.7853981633974483"))
assert feq(angles[Point(4, 4)].evalf(), Float("1.2490457723982544"))
assert feq(angles[Point(5, 2)].evalf(), Float("1.8925468811915388"))
assert feq(angles[Point(3, 0)].evalf(), Float("2.3561944901923449"))
#
# Triangle
#
p1 = Point(0, 0)
p2 = Point(5, 0)
p3 = Point(0, 5)
t1 = Triangle(p1, p2, p3)
t2 = Triangle(p1, p2, Point(Rational(5,2), sqrt(Rational(75,4))))
t3 = Triangle(p1, Point(x1, 0), Point(0, x1))
s1 = t1.sides
assert Triangle(p1, p2, p1) == Polygon(p1, p2, p1) == Segment(p1, p2)
raises(GeometryError, 'Triangle(Point(0, 0))')
# Basic stuff
assert Triangle(p1, p1, p1) == p1
assert Triangle(p2, p2*2, p2*3) == Segment(p2, p2*3)
assert t1.area == Rational(25,2)
assert t1.is_right()
assert t2.is_right() == False
assert t3.is_right()
assert p1 in t1
assert t1.sides[0] in t1
assert Segment((0, 0), (1, 0)) in t1
assert Point(5, 5) not in t2
assert t1.is_convex()
assert feq(t1.angles[p1].evalf(), pi.evalf()/2)
assert t1.is_equilateral() == False
assert t2.is_equilateral()
assert t3.is_equilateral() == False
assert are_similar(t1, t2) == False
assert are_similar(t1, t3)
assert are_similar(t2, t3) == False
assert t1.is_similar(Point(0, 0)) == False
# Bisectors
bisectors = t1.bisectors()
assert bisectors[p1] == Segment(p1, Point(Rational(5,2), Rational(5,2)))
ic = (250 - 125*sqrt(2)) / 50
assert t1.incenter == Point(ic, ic)
# Inradius
assert t1.inradius == t1.incircle.radius == 5 - 5*sqrt(2)/2
assert t2.inradius == t2.incircle.radius == 5*sqrt(3)/6
assert t3.inradius == t3.incircle.radius == x1**2/((2 + sqrt(2))*Abs(x1))
# Circumcircle
assert t1.circumcircle.center == Point(2.5, 2.5)
# Medians + Centroid
示例4: test_polygon
# 需要导入模块: from sympy.geometry import Triangle [as 别名]
# 或者: from sympy.geometry.Triangle import is_right [as 别名]
def test_polygon():
t = Triangle(Point(0, 0), Point(2, 0), Point(3, 3))
assert Polygon(Point(0, 0), Point(1, 0), Point(2, 0), Point(3, 3)) == t
assert Polygon(Point(1, 0), Point(2, 0), Point(3, 3), Point(0, 0)) == t
assert Polygon(Point(2, 0), Point(3, 3), Point(0, 0), Point(1, 0)) == t
p1 = Polygon(Point(0, 0), Point(3, -1), Point(6, 0), Point(4, 5), Point(2, 3), Point(0, 3))
p2 = Polygon(Point(6, 0), Point(3, -1), Point(0, 0), Point(0, 3), Point(2, 3), Point(4, 5))
p3 = Polygon(Point(0, 0), Point(3, 0), Point(5, 2), Point(4, 4))
p4 = Polygon(Point(0, 0), Point(4, 4), Point(5, 2), Point(3, 0))
#
# General polygon
#
assert p1 == p2
assert len(p1) == 6
assert len(p1.sides) == 6
assert p1.perimeter == 5 + 2 * sqrt(10) + sqrt(29) + sqrt(8)
assert p1.area == 22
assert not p1.is_convex()
assert p3.is_convex()
assert p4.is_convex() # ensure convex for both CW and CCW point specification
#
# Regular polygon
#
p1 = RegularPolygon(Point(0, 0), 10, 5)
p2 = RegularPolygon(Point(0, 0), 5, 5)
assert p1 != p2
assert p1.interior_angle == 3 * pi / 5
assert p1.exterior_angle == 2 * pi / 5
assert p2.apothem == 5 * cos(pi / 5)
assert p2.circumcircle == Circle(Point(0, 0), 5)
assert p2.incircle == Circle(Point(0, 0), p2.apothem)
assert p1.is_convex()
#
# Angles
#
angles = p4.angles
assert feq(angles[Point(0, 0)].evalf(), Real("0.7853981633974483"))
assert feq(angles[Point(4, 4)].evalf(), Real("1.2490457723982544"))
assert feq(angles[Point(5, 2)].evalf(), Real("1.8925468811915388"))
assert feq(angles[Point(3, 0)].evalf(), Real("2.3561944901923449"))
angles = p3.angles
assert feq(angles[Point(0, 0)].evalf(), Real("0.7853981633974483"))
assert feq(angles[Point(4, 4)].evalf(), Real("1.2490457723982544"))
assert feq(angles[Point(5, 2)].evalf(), Real("1.8925468811915388"))
assert feq(angles[Point(3, 0)].evalf(), Real("2.3561944901923449"))
#
# Triangle
#
p1 = Point(0, 0)
p2 = Point(5, 0)
p3 = Point(0, 5)
t1 = Triangle(p1, p2, p3)
t2 = Triangle(p1, p2, Point(Rational(5, 2), sqrt(Rational(75, 4))))
t3 = Triangle(p1, Point(x1, 0), Point(0, x1))
s1 = t1.sides
s2 = t2.sides
s3 = t3.sides
# Basic stuff
assert Triangle(p1, p1, p1) == p1
assert Triangle(p2, p2 * 2, p2 * 3) == Segment(p2, p2 * 3)
assert t1.area == Rational(25, 2)
assert t1.is_right()
assert t2.is_right() == False
assert t3.is_right()
assert p1 in t1
assert Point(5, 5) not in t2
assert t1.is_convex()
assert feq(t1.angles[p1].evalf(), pi.evalf() / 2)
assert t1.is_equilateral() == False
assert t2.is_equilateral()
assert t3.is_equilateral() == False
assert are_similar(t1, t2) == False
assert are_similar(t1, t3)
assert are_similar(t2, t3) == False
# Bisectors
bisectors = t1.bisectors()
assert bisectors[p1] == Segment(p1, Point(Rational(5, 2), Rational(5, 2)))
ic = (250 - 125 * sqrt(2)) / 50
assert t1.incenter == Point(ic, ic)
# Inradius
assert t1.inradius == 5 - 5 * sqrt(2) / 2
assert t2.inradius == 5 * sqrt(3) / 6
assert t3.inradius == x1 ** 2 / ((2 + sqrt(2)) * Abs(x1))
# Medians + Centroid
m = t1.medians
assert t1.centroid == Point(Rational(5, 3), Rational(5, 3))
assert m[p1] == Segment(p1, Point(Rational(5, 2), Rational(5, 2)))
assert t3.medians[p1] == Segment(p1, Point(x1 / 2, x1 / 2))
#.........这里部分代码省略.........
示例5: test_polygon
# 需要导入模块: from sympy.geometry import Triangle [as 别名]
# 或者: from sympy.geometry.Triangle import is_right [as 别名]
#.........这里部分代码省略.........
#
# Angles
#
angles = p4.angles
assert feq(angles[Point(0, 0)].evalf(), Float("0.7853981633974483"))
assert feq(angles[Point(4, 4)].evalf(), Float("1.2490457723982544"))
assert feq(angles[Point(5, 2)].evalf(), Float("1.8925468811915388"))
assert feq(angles[Point(3, 0)].evalf(), Float("2.3561944901923449"))
angles = p3.angles
assert feq(angles[Point(0, 0)].evalf(), Float("0.7853981633974483"))
assert feq(angles[Point(4, 4)].evalf(), Float("1.2490457723982544"))
assert feq(angles[Point(5, 2)].evalf(), Float("1.8925468811915388"))
assert feq(angles[Point(3, 0)].evalf(), Float("2.3561944901923449"))
#
# Triangle
#
p1 = Point(0, 0)
p2 = Point(5, 0)
p3 = Point(0, 5)
t1 = Triangle(p1, p2, p3)
t2 = Triangle(p1, p2, Point(Rational(5, 2), sqrt(Rational(75, 4))))
t3 = Triangle(p1, Point(x1, 0), Point(0, x1))
s1 = t1.sides
assert Triangle(p1, p2, p1) == Polygon(p1, p2, p1) == Segment(p1, p2)
raises(GeometryError, lambda: Triangle(Point(0, 0)))
# Basic stuff
assert Triangle(p1, p1, p1) == p1
assert Triangle(p2, p2*2, p2*3) == Segment(p2, p2*3)
assert t1.area == Rational(25, 2)
assert t1.is_right()
assert t2.is_right() is False
assert t3.is_right()
assert p1 in t1
assert t1.sides[0] in t1
assert Segment((0, 0), (1, 0)) in t1
assert Point(5, 5) not in t2
assert t1.is_convex()
assert feq(t1.angles[p1].evalf(), pi.evalf()/2)
assert t1.is_equilateral() is False
assert t2.is_equilateral()
assert t3.is_equilateral() is False
assert are_similar(t1, t2) is False
assert are_similar(t1, t3)
assert are_similar(t2, t3) is False
assert t1.is_similar(Point(0, 0)) is False
# Bisectors
bisectors = t1.bisectors()
assert bisectors[p1] == Segment(p1, Point(Rational(5, 2), Rational(5, 2)))
ic = (250 - 125*sqrt(2)) / 50
assert t1.incenter == Point(ic, ic)
# Inradius
assert t1.inradius == t1.incircle.radius == 5 - 5*sqrt(2)/2
assert t2.inradius == t2.incircle.radius == 5*sqrt(3)/6
assert t3.inradius == t3.incircle.radius == x1**2/((2 + sqrt(2))*Abs(x1))
# Circumcircle
assert t1.circumcircle.center == Point(2.5, 2.5)
# Medians + Centroid
示例6: test_polygon
# 需要导入模块: from sympy.geometry import Triangle [as 别名]
# 或者: from sympy.geometry.Triangle import is_right [as 别名]
def test_polygon():
t = Triangle(Point(0, 0), Point(2, 0), Point(3, 3))
assert Polygon(Point(0, 0), Point(1, 0), Point(2, 0), Point(3, 3)) == t
assert Polygon(Point(1, 0), Point(2, 0), Point(3, 3), Point(0, 0)) == t
assert Polygon(Point(2, 0), Point(3, 3), Point(0, 0), Point(1, 0)) == t
p1 = Polygon(
Point(0, 0), Point(3,-1),
Point(6, 0), Point(4, 5),
Point(2, 3), Point(0, 3))
p2 = Polygon(
Point(6, 0), Point(3,-1),
Point(0, 0), Point(0, 3),
Point(2, 3), Point(4, 5))
p3 = Polygon(
Point(0, 0), Point(3, 0),
Point(5, 2), Point(4, 4))
p4 = Polygon(
Point(0, 0), Point(4, 4),
Point(5, 2), Point(3, 0))
#
# General polygon
#
assert p1 == p2
assert len(p1) == 6
assert len(p1.sides) == 6
assert p1.perimeter == 5+2*sqrt(10)+sqrt(29)+sqrt(8)
assert p1.area == 22
assert not p1.is_convex()
assert p3.is_convex()
assert p4.is_convex() # ensure convex for both CW and CCW point specification
#
# Regular polygon
#
p1 = RegularPolygon(Point(0, 0), 10, 5)
p2 = RegularPolygon(Point(0, 0), 5, 5)
assert p1 != p2
assert p1.interior_angle == 3*pi/5
assert p1.exterior_angle == 2*pi/5
assert p2.apothem == 5*cos(pi/5)
assert p2.circumcircle == Circle(Point(0, 0), 5)
assert p2.incircle == Circle(Point(0, 0), p2.apothem)
assert p1.is_convex()
assert p1.rotation == 0
p1.spin(pi/3)
assert p1.rotation == pi/3
assert p1[0] == Point(5, 5*sqrt(3))
# while spin works in place (notice that rotation is 2pi/3 below)
# rotate returns a new object
p1_old = p1
assert p1.rotate(pi/3) == RegularPolygon(Point(0, 0), 10, 5, 2*pi/3)
assert p1 == p1_old
#
# Angles
#
angles = p4.angles
assert feq(angles[Point(0, 0)].evalf(), Float("0.7853981633974483"))
assert feq(angles[Point(4, 4)].evalf(), Float("1.2490457723982544"))
assert feq(angles[Point(5, 2)].evalf(), Float("1.8925468811915388"))
assert feq(angles[Point(3, 0)].evalf(), Float("2.3561944901923449"))
angles = p3.angles
assert feq(angles[Point(0, 0)].evalf(), Float("0.7853981633974483"))
assert feq(angles[Point(4, 4)].evalf(), Float("1.2490457723982544"))
assert feq(angles[Point(5, 2)].evalf(), Float("1.8925468811915388"))
assert feq(angles[Point(3, 0)].evalf(), Float("2.3561944901923449"))
#
# Triangle
#
p1 = Point(0, 0)
p2 = Point(5, 0)
p3 = Point(0, 5)
t1 = Triangle(p1, p2, p3)
t2 = Triangle(p1, p2, Point(Rational(5,2), sqrt(Rational(75,4))))
t3 = Triangle(p1, Point(x1, 0), Point(0, x1))
s1 = t1.sides
# Basic stuff
assert Triangle(p1, p1, p1) == p1
assert Triangle(p2, p2*2, p2*3) == Segment(p2, p2*3)
assert t1.area == Rational(25,2)
assert t1.is_right()
assert t2.is_right() == False
assert t3.is_right()
assert p1 in t1
assert t1.sides[0] in t1
assert Segment((0, 0), (1, 0)) in t1
assert Point(5, 5) not in t2
assert t1.is_convex()
assert feq(t1.angles[p1].evalf(), pi.evalf()/2)
assert t1.is_equilateral() == False
assert t2.is_equilateral()
assert t3.is_equilateral() == False
assert are_similar(t1, t2) == False
#.........这里部分代码省略.........