本文整理汇总了Python中line.Line类的典型用法代码示例。如果您正苦于以下问题:Python Line类的具体用法?Python Line怎么用?Python Line使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Line类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_date_lines
def add_date_lines(self, x_values, y_values, name='', has_dot=False, forced_selected_date=True, linestyle='-'\
,linewidth=2, markersize=3, color='', alpha=1):
line = Line(self)
now_color = self.ax._get_lines.color_cycle.next()
if color != '':
now_color = color
self.now_color = now_color
self.alpha = float(alpha)
y_values = self.change_missing_value(y_values, [np.nan, 'nan', 'Nan'], np.nan)
output_line, = line.date_plotting(x_values, y_values, name, has_dot, forced_selected_date, linestyle, linewidth, markersize, now_color, float(alpha))
self._add_legends(output_line, name)
if forced_selected_date:
self.min_date = x_values[0]
self.max_date = x_values[-1]
self.set_xaxis_limit()
valid_items = [i for i in y_values if i != 0]
if len(valid_items) > 0:
self.min_value.append(np.nanmin(valid_items))
self.max_value.append(np.nanmax(valid_items))
示例2: roadWidthArr
def roadWidthArr( roadPts ):
"points are expected to be 4 already sorted by BLBRTRRL image order"
assert len(roadPts) == 4, roadPts
bl,br,tr,tl = roadPts
lineL = Line(bl,tl)
lineR = Line(br,tr)
return abs(lineR.signedDistance(bl)),abs(lineL.signedDistance(br)),abs(lineL.signedDistance(tr)),abs(lineR.signedDistance(tl))
示例3: test_line_intersection
def test_line_intersection():
"""Test if two lines intersect"""
line1 = Line(Vector([2, 5]), 10)
line2 = Line(Vector([1, 1]), 5)
assert line1.is_parallel(line2) is False
assert line1.point_of_intersection(line2) == (Decimal(5), Decimal(0))
示例4: test_direction_vector
def test_direction_vector():
"""Test getting the direction Vector of a Line"""
line1 = Line(Vector([2, 3]), 6)
direction_vector = line1.direction_vector()
answer = Vector([3, -2])
assert direction_vector == answer
示例5: trimJoin_Coro
def trimJoin_Coro(self):
""" Yields a list of lines that have their ends properly trimmed/joined
after an offset.
When the lines are offset their endpoints are just moved away the offset
distance. If you offset a circle to the inside this would mean that
all of the lines would overlap. If the circle was offset to the outside
none of the lines would be touching. This function trims the overlapping
ends and extends/joins the non touching ends.
Yields
------
in - Lines
out - one big List of lines at the end.
"""
offsetLines = []
moveEnd = yield
moveStart = yield
while not(moveStart is None):
_, point = moveEnd.segmentsIntersect(moveStart, c.ALLOW_PROJECTION)
moveEnd = Line(moveEnd.start, point, moveEnd)
moveStart = Line(point, moveStart.end, moveStart)
offsetLines.append(moveEnd)
moveEnd = moveStart
moveStart = yield
_, point = moveEnd.segmentsIntersect(offsetLines[0], c.ALLOW_PROJECTION)
moveEnd = Line(moveEnd.start, point, moveEnd)
offsetLines.append(moveEnd)
offsetLines[0] = Line(point, offsetLines[0].end, offsetLines[0])
yield offsetLines
示例6: test_intersect_parallel
def test_intersect_parallel(self):
l1 = Line(Point([0,0]), Point([10, 0]))
l2 = Line(Point([0, 5]), Point([5, 5]))
p = l1.intersection(l2)
self.assertEqual(p, False)
示例7: test_intersect_edge
def test_intersect_edge(self):
l1 = Line(Point([0,0]), Point([10, 0]))
l2 = Line(Point([0, 0]), Point([5, 5]))
p = l1.intersection(l2)
self.assertEqual(p.vec, [0.0, 0.0, 1.0])
示例8: draw
def draw(self, *args, **kwargs):
"""
Draw both the Line and the Axis' label.
Does not draw the Ticks. See Axis.drawTicks() for that.
"""
Line.draw(self, *args, **kwargs)
self._label.draw(*args, **kwargs)
示例9: getPolygon
def getPolygon(self):
leftLine = Line(self.p(0.0, 1.0), self.p(0.0, 0.0), self.weight(), shift="right", serif=3)
topLine = Line(self.p(0.0, 1.0), self.p(1.0, 1.0), self.weight(), shift="down", serif=1)
midHeight = self.p(0.0, 0.5, xHeight=True)[1]
midLeft = leftLine.atY(midHeight)
midLine = Line((midLeft, midHeight), (midLeft + self.width() / PHI, midHeight), self.weight())
return [leftLine, topLine, midLine]
示例10: test_line_is_coincidence
def test_line_is_coincidence():
"""Test if a line is a coincidece"""
line1 = Line(Vector([2, 3]), 1)
line2 = Line(Vector([2, 3]), 1)
assert line1.is_parallel(line2) is True
assert line1.is_coincidence(line2) is True
line3 = Line(Vector([2, 3]), 6)
assert line1.is_parallel(line3) is True
assert line1.is_coincidence(line3) is False
示例11: define
def define (self, dwg):
for element in range(0,1000):
circle = Circle()
line = Line()
parabola = Parabola()
splash = Splash()
circle.define(dwg)
line.define(dwg)
parabola.define(dwg)
splash.define(dwg)
示例12: test_simpleLine
def test_simpleLine(self):
address = self.address()
accept = self.serve(address)
client=create_connection(address)
try:
data = b'sdafsf454534\n'
line = Line(client)
line.write(data)
l = line.readline(timedelta(seconds=1), b'\n')
self.assertEqual(data, l+b'\n')
finally:
client.close()
accept.close()
示例13: test_lines
def test_lines():
n1 = Vector([4.046, 2.836])
c1 = 1.21
n2 = Vector([10.115, 7.09])
c2 = 3.025
l1 = Line(n1, c1)
l2 = Line(n2,c2)
#print "l1 is parallel to l2: ", l1.is_parallel_to(l2)
print "l1 is same as l2: ", l1 ==l2
if l1.intersects(l2):
intersection = l1.intersection_with(l2)
print "intersection: ", intersection
else:
print "No intersection"
print "-"*60
n1 = Vector([7.204, 3.182])
c1 = 8.68
n2 = Vector([8.172, 4.114])
c2 = 9.883
l1 = Line(n1, c1)
l2 = Line(n2,c2)
#print "l1 is parallel to l2: ", l1.is_parallel_to(l2)
print "l1 is same as l2: ", l1 ==l2
if l1.intersects(l2):
intersection = l1.intersection_with(l2)
print "intersection: ", intersection
else:
print "No intersection"
print "-"*60
n1 = Vector([1.182, 5.562])
c1 = 6.744
n2 = Vector([1.773, 8.343])
c2 = 9.525
l1 = Line(n1, c1)
l2 = Line(n2,c2)
#print "l1 is parallel to l2: ", l1.is_parallel_to(l2)
print "l1 is same as l2: ", l1 ==l2
if l1.intersects(l2):
intersection = l1.intersection_with(l2)
print "intersection: ", intersection
else:
print "No intersection"
示例14: generate_extremas
def generate_extremas(self, polygon, y):
extremas = []
scan_line = Line(Point([self.canvas.xmin, y]), Point([self.canvas.xmax, y]))
for edge in polygon.lines:
if edge.horizontal():
continue
if y == edge.highest():
continue
if y >= edge.lowest() and y < edge.highest():
p = scan_line.intersection(edge)
if p == False:
continue # lines are parallel
extremas.append(p)
return extremas
示例15: makeVCurveL
def makeVCurveL(self):
vCurvesHeight = self.vCurvesHeight
vCurvesWidth = self.vCurvesWidth
vCurvesDepth = self.vCurvesDepth
v21 = Base.Vector(self.stopsWidth,0,self.botCurveHeight);
v11 = v21 + Base.Vector(-(1-self.stopRatio)*self.stopsWidth,0,self.stopsHeight)
v12 = v11+Base.Vector(vCurvesWidth,0,vCurvesHeight);
l = Line().fromPoints((v11.x, v11.z), (v12.x, v12.z))
c11 = l.bissection().pointAtDist(-vCurvesDepth)
cv11 = Base.Vector(c11[0],0,c11[1])
a1 = Part.Arc(v12,cv11,v11)
return a1.toShape()