本文整理汇总了Python中Vector.projectToPlane方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.projectToPlane方法的具体用法?Python Vector.projectToPlane怎么用?Python Vector.projectToPlane使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector
的用法示例。
在下文中一共展示了Vector.projectToPlane方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ClosestTimeTo
# 需要导入模块: import Vector [as 别名]
# 或者: from Vector import projectToPlane [as 别名]
def ClosestTimeTo( self, point, plane=None ):
""" Returns the closest point in this trajectory to the given point in 3d space (or 2d if plane is defined) """
if not type(point) == Vector:
point = Vector(point)
if plane:
point = point.projectToPlane(plane.normal,planePt=plane.point)
minDist = float("inf")
ft = None
camPos = Vector( mc.xform(mc.lookThru(q=True), q=True, t=True) )
for i,t in enumerate(sorted(self.points.keys())):
p = self.points[t]
if plane:
p = p.projectToPlane(plane.normal,planePt=plane.point)
dist = (point-p).mag()
else:
ray = (p-camPos).norm() # build a ray from the camera to the path point in question
dist = ray.cross(point-p).mag()
if minDist > dist:
minDist = dist
ft = t
return ft # return the key of the closest point in the points dictionary