本文整理汇总了Python中line.Line.angle_between方法的典型用法代码示例。如果您正苦于以下问题:Python Line.angle_between方法的具体用法?Python Line.angle_between怎么用?Python Line.angle_between使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类line.Line
的用法示例。
在下文中一共展示了Line.angle_between方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: angles
# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import angle_between [as 别名]
def angles(self):
"""
Returns a dictionary of {point: angle} entries containing the
measure of all the internal angles of this polygon formed at
each vertex.
Examples:
======
>>> from sympy.geometry import *
>>> p1,p2,p3,p4 = map(Point, [(0,0), (1,0), (5,1), (0,1)])
>>> poly = Polygon(p1, p2, p3, p4)
>>> poly.angles[p1]
pi/2
>>> poly.angles[p2]
acos(-4*17**(1/2)/17)
"""
def tarea(a, b, c):
return (b[0] - a[0])*(c[1] - a[1]) - (c[0] - a[0])*(b[1] - a[1])
def isright(a, b, c):
return bool(tarea(a, b, c) <= 0)
# Determine orientation of points
cw = isright(self.vertices[-1], self.vertices[0], self.vertices[1])
ret = {}
for i in xrange(0, len(self.vertices)):
a,b,c = self.vertices[i-2], self.vertices[i-1], self.vertices[i]
ang = Line.angle_between(Line(b, a), Line(b, c))
if cw ^ isright(a, b, c):
ret[b] = 2*S.Pi - ang
else:
ret[b] = ang
return ret
示例2: angles
# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import angle_between [as 别名]
def angles(self):
"""The internal angle at each vertex.
Returns
-------
angles : dict
A dictionary where each key is a vertex and each value is the
internal angle at that vertex. The vertices are represented as
Points.
See Also
--------
Point
Examples
--------
>>> from sympy import Point, Polygon
>>> p1, p2, p3, p4 = map(Point, [(0, 0), (1, 0), (5, 1), (0, 1)])
>>> poly = Polygon(p1, p2, p3, p4)
>>> poly.angles[p1]
pi/2
>>> poly.angles[p2]
acos(-4*17**(1/2)/17)
"""
def tarea(a, b, c):
return (b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1])
def isright(a, b, c):
return bool(tarea(a, b, c) <= 0)
# Determine orientation of points
cw = isright(self[-1], self[0], self[1])
ret = {}
for i in xrange(len(self)):
a, b, c = self[i - 2], self[i - 1], self[i]
ang = Line.angle_between(Line(b, a), Line(b, c))
if cw ^ isright(a, b, c):
ret[b] = 2 * S.Pi - ang
else:
ret[b] = ang
return ret
示例3: _do_poly_distance
# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import angle_between [as 别名]
#.........这里部分代码省略.........
for side in e1.sides:
if side.p1 in e1_connections:
e1_connections[side.p1].append(side.p2)
else:
e1_connections[side.p1] = [side.p2]
if side.p2 in e1_connections:
e1_connections[side.p2].append(side.p1)
else:
e1_connections[side.p2] = [side.p1]
for side in e2.sides:
if side.p1 in e2_connections:
e2_connections[side.p1].append(side.p2)
else:
e2_connections[side.p1] = [side.p2]
if side.p2 in e2_connections:
e2_connections[side.p2].append(side.p1)
else:
e2_connections[side.p2] = [side.p1]
e1_current = e1_ymax
e2_current = e2_ymin
support_line = Line(Point(S(0), S(0)), Point(S(1), S(0)))
'''
Determine which point in e1 and e2 will be selected after e2_ymin and e1_ymax,
this information combined with the above produced dictionaries determines the
path that will be taken around the polygons
'''
point1 = e1_connections[e1_ymax][0]
point2 = e1_connections[e1_ymax][1]
angle1 = support_line.angle_between(Line(e1_ymax, point1))
angle2 = support_line.angle_between(Line(e1_ymax, point2))
if angle1 < angle2: e1_next = point1
elif angle2 < angle1: e1_next = point2
elif Point.distance(e1_ymax, point1) > Point.distance(e1_ymax, point2):
e1_next = point2
else: e1_next = point1
point1 = e2_connections[e2_ymin][0]
point2 = e2_connections[e2_ymin][1]
angle1 = support_line.angle_between(Line(e2_ymin, point1))
angle2 = support_line.angle_between(Line(e2_ymin, point2))
if angle1 > angle2: e2_next = point1
elif angle2 > angle1: e2_next = point2
elif Point.distance(e2_ymin, point1) > Point.distance(e2_ymin, point2):
e2_next = point2
else: e2_next = point1
'''
Loop which determins the distance between anti-podal pairs and updates the
minimum distance accordingly. It repeats until it reaches the starting position.
'''
while True:
e1_angle = support_line.angle_between(Line(e1_current, e1_next))
e2_angle = pi - support_line.angle_between(Line(e2_current, e2_next))
if e1_angle < e2_angle:
support_line = Line(e1_current, e1_next)
e1_segment = Segment(e1_current, e1_next)
min_dist_current = e1_segment.distance(e2_current)
if min_dist_current.evalf() < min_dist.evalf(): min_dist = min_dist_current