本文整理汇总了Python中vector.Vector.project方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.project方法的具体用法?Python Vector.project怎么用?Python Vector.project使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vector.Vector
的用法示例。
在下文中一共展示了Vector.project方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getValue
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import project [as 别名]
def getValue(self, x, y):
# project point (x, y) onto vector
v1 = Vector(x - self.centerX, y - self.centerY)
# vector
p = v1.project(self.direction);
# adjust so the point is correct
p.x += self.centerX
p.y += self.centerY
# get the vector from the point to (x, y)
d = Vector(x - p.x, y - p.y)
l = d.length()
# normal of current vector
n = Vector(self.direction.y, -self.direction.x)
# adjust for sign on each side of the vector
p = v1.dot(n)
sign = 1.0
if p > 0:
sign = -1.0
#print self.waveLength
#print math.sin(self.theta + sign * l / self.waveLength)
return math.sin(self.theta + sign * l / self.waveLength);
示例2: test_projection
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import project [as 别名]
def test_projection(self):
v1 = Vector(1, 2)
v2 = Vector(3, 4)
#result = 9 / 5 * Vector(3, 4)
result = Vector(33.0 / 25, 44.0 / 25)
self.assertEqual(v1.project(v2), result)