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


Python Quaternion.slerp方法代码示例

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


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

示例1: get

# 需要导入模块: from quaternion import Quaternion [as 别名]
# 或者: from quaternion.Quaternion import slerp [as 别名]
    def get(self, requested_timestamp):
        if len(self.history) == 0:
            return None

        if requested_timestamp in self.history:
            match = self.history[requested_timestamp]
            return TimestampedQuaternion(match.w, match.x, match.y, match.z, requested_timestamp)
        else:

            keys = list(self.history.keys())
            keys.sort()

            if keys[0] > requested_timestamp or keys[-1] < requested_timestamp:
                return None

            for i, key in enumerate(keys):
                if key > requested_timestamp:
                    previous_timestamp = keys[i - 1]
                    next_timestamp = key
                    timestamp_delta = next_timestamp - previous_timestamp
                    requested_timestamp_offset = requested_timestamp - previous_timestamp
                    requested_timestamp_ratio = requested_timestamp_offset / timestamp_delta
                    interpolated_quaternion = Quaternion.slerp(self.history[previous_timestamp],
                                                               self.history[next_timestamp],
                                                               requested_timestamp_ratio)

                    match = TimestampedQuaternion(interpolated_quaternion.w,
                                                  interpolated_quaternion.x,
                                                  interpolated_quaternion.y,
                                                  interpolated_quaternion.z, requested_timestamp)
                    match.setInterpolated(True)
                    return match
            return None
开发者ID:utk-robotics-2017,项目名称:navX-Python,代码行数:35,代码来源:timestamped_quaternion_history.py

示例2: Quaternion

# 需要导入模块: from quaternion import Quaternion [as 别名]
# 或者: from quaternion.Quaternion import slerp [as 别名]
  print q.inverse()
  print q.toAxisAngle()
  q2 = Quaternion(1.,.01,0.,0.)
  q2.normalize()
  print q2
  print q2.inverse()
  print q2.inverse().dot(q2)
  print q2.dot(q2.inverse())
  print q.dot(q2)
  print q.angleTo(q2)
  raw_input()

  q2 = Quaternion(1.,1.,0.,0.)
  q2.fromAxisAngle(np.pi/2.0,np.array([0.,1.,1.]))

  q3 = q.slerp(q2,0.5)
  print q
  print q3
  print q2  
  for t in np.linspace(0.,1.,100):
    qi=q.slerp(q2,t)
    print "--------------------------------------------------------"
    print qi
    print np.sqrt((qi.q**2).sum())
    print 'det: {}'.format( det(qi.toRot().R))
    print "--------------------------------------------------------"
    #print qi.toRot().R


  dq = Quaternion()                                                                                                               
  q0 = Quaternion()                                                                                                               
开发者ID:jstraub,项目名称:bbTrans,代码行数:33,代码来源:rotations.py

示例3: test_slerp

# 需要导入模块: from quaternion import Quaternion [as 别名]
# 或者: from quaternion.Quaternion import slerp [as 别名]
 def test_slerp(self):
     q1 = Quaternion(axis=[1, 0, 0], angle=0.0)
     q2 = Quaternion(axis=[1, 0, 0], angle=pi/2)
     q3 = Quaternion.slerp(q1, q2, 0.5)
     self.assertEqual(q3, Quaternion(axis=[1,0,0], angle=pi/4))
开发者ID:timdelbruegger,项目名称:pyquaternion,代码行数:7,代码来源:test_quaternion.py


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