当前位置: 首页>>代码示例>>Python>>正文


Python Vector.inner方法代码示例

本文整理汇总了Python中Vector.Vector.inner方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.inner方法的具体用法?Python Vector.inner怎么用?Python Vector.inner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vector.Vector的用法示例。


在下文中一共展示了Vector.inner方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: contains

# 需要导入模块: from Vector import Vector [as 别名]
# 或者: from Vector.Vector import inner [as 别名]
 def contains(self, point):
     if not self.bounding_box.contains(point):
         return False
     length = len(self.vector_list)
     # magic for loop: A point is inside the polygon when it's on the same side of an edge as an other vertex.
     # the following for loop checks this for every edge. This works, don't change unless
     # the implementation of a point changes.
     # Dependent on this function: Unit.check_collision
     for i in range(length):
         a = self.vector_list[i]
         b = self.vector_list[(i+1) % length]
         c = self.vector_list[(i+2) % length]
         vector1 = Vector([a.values[1] - b.values[1], b.values[0] - a.values[0]])
         vector2 = point - a
         vector3 = c - a
         if vector1.inner(vector2) * vector1.inner(vector3) < 0:
             return False
     return True
开发者ID:TimdeJonge,项目名称:RaceGame,代码行数:20,代码来源:Polygon.py

示例2: handle_collision

# 需要导入模块: from Vector import Vector [as 别名]
# 或者: from Vector.Vector import inner [as 别名]
 def handle_collision(self, player):
     new_position = player.position + player.speed
     length = len(self.vector_list)
     point1, point2 = 0, 0
     for i in range(length):
         a = self.vector_list[i]
         b = self.vector_list[(i+1) % length]
         vector1 = Vector([a.values[1] - b.values[1], b.values[0] - a.values[0]])
         vector2 = player.position - a
         vector3 = new_position - a
         if vector1.inner(vector2) * vector1.inner(vector3) < 0:
             point1 = a
             point2 = b
     if point1 == 0 and point2 == 0:
         print("TIME TO TURN ON THE DEBUGGER")
         player.speed = player.speed.scalar(-1)
     parallel, perpendicular = player.speed.split(point1 - point2)
     new_speed = (parallel - perpendicular).scalar(.5)
     player.set_speed(new_speed.values[0], new_speed.values[1])
开发者ID:TimdeJonge,项目名称:RaceGame,代码行数:21,代码来源:Polygon.py

示例3: Vector

# 需要导入模块: from Vector import Vector [as 别名]
# 或者: from Vector.Vector import inner [as 别名]
import math
from Vector import Vector

u =Vector ( 3, [1,2,3])
v = Vector (3,3.5)
w = u.lincomb(v,10,1)
print(math.sqrt(u.inner(u)))
print(u.norm())

print(w)
开发者ID:RubenMeijs,项目名称:WISB256,代码行数:12,代码来源:test.py


注:本文中的Vector.Vector.inner方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。