當前位置: 首頁>>代碼示例>>Python>>正文


Python Quaternion.rotate方法代碼示例

本文整理匯總了Python中SofaPython.Quaternion.rotate方法的典型用法代碼示例。如果您正苦於以下問題:Python Quaternion.rotate方法的具體用法?Python Quaternion.rotate怎麽用?Python Quaternion.rotate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SofaPython.Quaternion的用法示例。


在下文中一共展示了Quaternion.rotate方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: inv

# 需要導入模塊: from SofaPython import Quaternion [as 別名]
# 或者: from SofaPython.Quaternion import rotate [as 別名]
def inv(x):
    res = np.zeros(7)

    res[3:] = quat.conj(x[3:])
    res[:3] = -quat.rotate(res[3:], x[:3])
    
    return res
開發者ID:151706061,項目名稱:sofa,代碼行數:9,代碼來源:rigid.py

示例2: prod

# 需要導入模塊: from SofaPython import Quaternion [as 別名]
# 或者: from SofaPython.Quaternion import rotate [as 別名]
def prod(x, y):
    print x.inv()
    res = np.zeros(7)

    res[:3] = x[:3] + quat.rotate(x[3:], y[:3])
    res[3:] = quat.prod(x[3:], y[3:])

    return res
開發者ID:151706061,項目名稱:sofa,代碼行數:10,代碼來源:rigid.py

示例3: onBeginAnimationStep

# 需要導入模塊: from SofaPython import Quaternion [as 別名]
# 或者: from SofaPython.Quaternion import rotate [as 別名]
    def onBeginAnimationStep(self, dt):

        # current mu from current plane angle
        currentMu = math.tan( self.currentAngle )
        
        if self.counter < 100 : # does not rotate the plane for 100 time steps
            self.counter += 1
            return 0
            
        # is it a mu we want to test?
        if numpy.allclose( self.muToTest, currentMu, 1e-3, 1e-3 ) :
            
            # at the end of 100 time steps, check if the box was sticking or sliding
            self.counter = 0
            self.muToTest += 0.1
            
            # look at the box velocity along its x-axis
            localbox = Quaternion.rotate(Quaternion.conj( Frame.Frame( shared.plane.position[0] ).rotation ),
                                shared.box.velocity[0][:3])
            vel = localbox[0]

            #print 'plane/ground angle:', self.currentAngle
            #print 'velocity:',vel

            #print shared.box.position[0], shared.box.velocity[0][:3]

            #print vel, currentMu, shared.mu
            
            
            testVel = (vel > 1e-1)            
            if testVel:
                testMu = (currentMu>=shared.mu-1e-2)
            else:
                testMu = (currentMu>=shared.mu)
                
            
           
            
            EXPECT_FALSE( testVel ^ testMu, str(vel)+' '+str(currentMu)+'mu='+str(shared.mu) ) # xor
            
            
            #print testVel, testMu
            #sys.stdout.flush()
        
        # all finished
        if currentMu >= shared.mu + .1:
            self.sendSuccess()
        
        
        # update plane orientation
        self.currentAngle += 0.001
        q = Quaternion.from_euler( [0,0,-self.currentAngle] )
        p = shared.plane.position
        p[0] = [0,0,0,q[3],q[2],q[1],q[0]]
        shared.plane.position = p
               
        return 0
開發者ID:151706061,項目名稱:sofa,代碼行數:59,代碼來源:friction.py

示例4: __mul__

# 需要導入模塊: from SofaPython import Quaternion [as 別名]
# 或者: from SofaPython.Quaternion import rotate [as 別名]
	def __mul__(self, other):
		res = Frame()
		res.translation = vec.sum(self.translation,
					  quat.rotate(self.rotation,
						      other.translation))
		res.rotation = quat.prod( self.rotation,
					  other.rotation)

		return res
開發者ID:fdervaux,項目名稱:sofa-framework,代碼行數:11,代碼來源:Rigid.py

示例5: apply

# 需要導入模塊: from SofaPython import Quaternion [as 別名]
# 或者: from SofaPython.Quaternion import rotate [as 別名]
 def apply(self, vec):
     """ apply transformation to vec (a [x,y,z] vector)
     return the result
     """
     return array(quat.rotate(self.rotation, vec) + asarray(self.translation))
開發者ID:fredroy,項目名稱:sofa,代碼行數:7,代碼來源:Frame.py

示例6: inv

# 需要導入模塊: from SofaPython import Quaternion [as 別名]
# 或者: from SofaPython.Quaternion import rotate [as 別名]
 def inv(self):
     res = Frame()
     res.rotation = quat.conj( self.rotation )
     res.translation = - quat.rotate(res.rotation, self.translation)
     return res
開發者ID:fredroy,項目名稱:sofa,代碼行數:7,代碼來源:Frame.py

示例7: createScene

# 需要導入模塊: from SofaPython import Quaternion [as 別名]
# 或者: from SofaPython.Quaternion import rotate [as 別名]
def createScene(node):

    node.createObject('RequiredPlugin',
                      pluginName = 'Compliant')


    ode = node.createObject('CompliantImplicitSolver')
    num = node.createObject('SequentialSolver')

    # ode.debug = 1
    node.dt = 0.01

    pos = np.zeros(7)
    vel = np.zeros(6)
    force = np.zeros(6)

    alpha = math.pi / 4.0
    
    q = quat.exp([0, 0, alpha])

    pos[:3] = [-0.5, 0, 0]
    pos[3:] = q

    mass = 1.0

    # change this for more fun
    dim = np.array([1, 2, 1])

    dim2 = dim * dim
    
    
    inertia = mass / 12.0 * (dim2[ [1, 2, 0] ] + dim2[ [2, 0, 1] ])
    volume = 1.0
    
    force[3:] = quat.rotate(q, [0, 1, 0])

    scene = node.createChild('scene')
    
    good = scene.createChild('good')
    
    dofs = good.createObject('MechanicalObject',
                             template = 'Rigid',
                             name = 'dofs',
                             position = pos,
                             velocity = vel,
                             showObject = 1)

    good.createObject('RigidMass',
                      template = 'Rigid',
                      name = 'mass',
                      mass = mass,
                      inertia = inertia)

    good.createObject('ConstantForceField',
                      template = 'Rigid',
                      name = 'ff',
                      forces = force)

    bad = scene.createChild('bad')

    pos[:3] = [0.5, 0, 0]
    dofs = bad.createObject('MechanicalObject',
                            template = 'Rigid',
                            name = 'dofs',
                            position = pos,
                            velocity = vel,
                            showObject = 1)

    inertia_matrix = np.diag(inertia)
    
    def cat(x): return ' '.join( map(str, x))

    def print_matrix(x):
        return '[' + ','.join(map(str, x)) + ']'

    
    bad.createObject('UniformMass',
                     template = 'Rigid',
                     name = 'mass',
                     mass = cat([mass, volume, print_matrix(inertia_matrix / mass)]))
    
    bad.createObject('ConstantForceField',
                      template = 'Rigid',
                      name = 'ff',
                      forces = force)

                
    node.gravity = '0 0 0'
開發者ID:151706061,項目名稱:sofa,代碼行數:90,代碼來源:angular.py


注:本文中的SofaPython.Quaternion.rotate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。