本文整理汇总了Python中mathutils.Matrix.dot方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.dot方法的具体用法?Python Matrix.dot怎么用?Python Matrix.dot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mathutils.Matrix
的用法示例。
在下文中一共展示了Matrix.dot方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Line
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import dot [as 别名]
#.........这里部分代码省略.........
p1
|--x
p0
"""
return Line(self.lerp(t), self.cross_z)
def sized_normal(self, t, size):
"""
2d Line perpendicular on plane xy
at position t in current segment
and of given length
lie on the right side when size > 0
p1
|--x
p0
"""
return Line(self.lerp(t), size * self.cross_z.normalized())
def lerp(self, t):
"""
3d interpolation
"""
return self.p + self.v * t
def intersect(self, line):
"""
2d intersection on plane xy
return
True if intersect
p: point of intersection
t: param t of intersection on current line
"""
c = line.cross_z
d = self.v.dot(c)
if d == 0:
return False, 0, 0
t = c.dot(line.p - self.p) / d
return True, self.lerp(t), t
def intersect_ext(self, line):
"""
same as intersect, but return param t on both lines
"""
c = line.cross_z
d = self.v.dot(c)
if d == 0:
return False, 0, 0, 0
dp = line.p - self.p
c2 = self.cross_z
u = c.dot(dp) / d
v = c2.dot(dp) / d
return u > 0 and v > 0 and u < 1 and v < 1, self.lerp(u), u, v
def point_sur_segment(self, pt):
""" _point_sur_segment
point: Vector 2d
t: param t de l'intersection sur le segment courant
d: distance laterale perpendiculaire positif a droite
"""
dp = pt - self.p
dl = self.length
if dl == 0:
return dp.length < 0.00001, 0, 0
d = (self.v.x * dp.y - self.v.y * dp.x) / dl
t = self.v.dot(dp) / (dl * dl)
return t > 0 and t < 1, d, t