本文整理汇总了Python中solver.Solver.select_legal_root方法的典型用法代码示例。如果您正苦于以下问题:Python Solver.select_legal_root方法的具体用法?Python Solver.select_legal_root怎么用?Python Solver.select_legal_root使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类solver.Solver
的用法示例。
在下文中一共展示了Solver.select_legal_root方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: solve_bilinear_case2
# 需要导入模块: from solver import Solver [as 别名]
# 或者: from solver.Solver import select_legal_root [as 别名]
def solve_bilinear_case2(self):
print 'I am in case2.'
x32 = self.vertex_rect[2][0] - self.vertex_rect[1][0]
y32 = self.vertex_rect[2][1] - self.vertex_rect[1][1]
x41 = self.vertex_rect[3][0] - self.vertex_rect[0][0]
y41 = self.vertex_rect[3][1] - self.vertex_rect[0][1]
x21 = self.vertex_rect[1][0] - self.vertex_rect[0][0]
y21 = self.vertex_rect[1][1] - self.vertex_rect[0][1]
a = x32 * y41 - x41 * y32
b = self.dst_point[0] * (y32 - y41) + self.dst_point[1] * (x41 - x32) + self.vertex_rect[0][1] * x32 - self.vertex_rect[0][0] * y32 + self.vertex_rect[1][0] * y41 - self.vertex_rect[1][1]* x41
c = self.dst_point[0] * y21 - self.dst_point[1] * x21 + self.vertex_rect[1][0] * self.vertex_rect[0][1] - self.vertex_rect[0][0] * self.vertex_rect[1][1]
s1, s2 = Solver.solve_quadratics(self, a, b, c)
s = Solver.select_legal_root(self, s1, s2)
t = (self.dst_point[1] - self.vertex_rect[0][1] - y41 * s) / (self.vertex_rect[1][1] + y32 * s - self.vertex_rect[0][1] - y41 * s)
self.wgt_lst[0] = (1 - s) * (1 - t)
self.wgt_lst[1] = (1 - s) * t
self.wgt_lst[2] = s * t
self.wgt_lst[3] = s * (1 - t)
示例2: solve_bilinear_case1
# 需要导入模块: from solver import Solver [as 别名]
# 或者: from solver.Solver import select_legal_root [as 别名]
def solve_bilinear_case1(self):
print 'I am in case1.'
x34 = self.vertex_rect[2][0] - self.vertex_rect[3][0]
y34 = self.vertex_rect[2][1] - self.vertex_rect[3][1]
x21 = self.vertex_rect[1][0] - self.vertex_rect[0][0]
y21 = self.vertex_rect[1][1] - self.vertex_rect[0][1]
x41 = self.vertex_rect[3][0] - self.vertex_rect[0][0]
y41 = self.vertex_rect[3][1] - self.vertex_rect[0][1]
a = x34 * y21 - x21 * y34
b = self.dst_point[0] * (y34 - y21) + self.dst_point[1] * (x21 - x34) - y34 * self.vertex_rect[0][0] + x34 * self.vertex_rect[0][1] + self.vertex_rect[3][0] * y21 - self.vertex_rect[3][1] * x21
c = self.dst_point[0] * y41 - self.dst_point[1] * x41 + self.vertex_rect[3][0] * self.vertex_rect[0][1] - self.vertex_rect[0][0] * self.vertex_rect[3][1]
print a
print b
print c
t1, t2 = Solver.solve_quadratics(self, a, b, c)
t = Solver.select_legal_root(self, t1, t2)
s = (self.dst_point[0] - self.vertex_rect[0][0] - x21 * t) / (self.vertex_rect[3][0] + x34 * t - self.vertex_rect[0][0] - x21 * t)
self.wgt_lst[0] = (1 - s) * (1 - t)
self.wgt_lst[1] = (1 - s) * t
self.wgt_lst[2] = s * t
self.wgt_lst[3] = s * (1 - t)