本文整理汇总了Python中Math.Matrix.invert方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.invert方法的具体用法?Python Matrix.invert怎么用?Python Matrix.invert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Math.Matrix
的用法示例。
在下文中一共展示了Matrix.invert方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __update
# 需要导入模块: from Math import Matrix [as 别名]
# 或者: from Math.Matrix import invert [as 别名]
def __update(self, dx, dy, dz, rotateMode = True, zoomMode = True, isCallback = False):
prevPos = self.__inputInertia.calcWorldPos(self.__aimingSystem.matrix)
distChanged = False
if zoomMode and dz != 0:
prevDist = self.__aimingSystem.distanceFromFocus
distDelta = dz * float(self.__curScrollSense)
distMinMax = self.__cfg['distRange']
newDist = mathUtils.clamp(distMinMax.min, distMinMax.max, prevDist - distDelta)
if abs(newDist - prevDist) > 0.001:
self.__aimingSystem.distanceFromFocus = newDist
self.__userCfg['startDist'] = newDist
self.__inputInertia.glideFov(self.__calcRelativeDist())
self.__aimingSystem.aimMatrix = self.__calcAimMatrix()
distChanged = True
changeControlMode = prevDist == newDist and mathUtils.almostZero(newDist - distMinMax.min)
if changeControlMode and self.__onChangeControlMode is not None:
self.__onChangeControlMode()
return
if rotateMode:
self.__updateAngles(dx, dy)
if ENABLE_INPUT_ROTATION_INERTIA and not distChanged:
self.__aimingSystem.update(0.0)
if ENABLE_INPUT_ROTATION_INERTIA or distChanged:
worldDeltaPos = prevPos - self.__aimingSystem.matrix.translation
matInv = Matrix(self.__aimingSystem.matrix)
matInv.invert()
self.__inputInertia.glide(matInv.applyVector(worldDeltaPos))
return
示例2: __cameraUpdate
# 需要导入模块: from Math import Matrix [as 别名]
# 或者: from Math.Matrix import invert [as 别名]
def __cameraUpdate(self, allowModeChange = True):
curTime = BigWorld.time()
deltaTime = curTime - self.__prevTime
self.__prevTime = curTime
if not self.__autoUpdateDxDyDz.x == self.__autoUpdateDxDyDz.y == self.__autoUpdateDxDyDz.z == 0.0:
self.__rotateAndZoom(self.__autoUpdateDxDyDz.x, self.__autoUpdateDxDyDz.y, self.__autoUpdateDxDyDz.z)
self.__aimingSystem.update(deltaTime)
localTransform, impulseTransform = self.__updateOscillators(deltaTime)
aimMatrix = cameras.getAimMatrix(*self.__defaultAimOffset)
camMat = Matrix(aimMatrix)
rodMat = mathUtils.createTranslationMatrix(-self.__dynamicCfg['pivotShift'])
antiRodMat = mathUtils.createTranslationMatrix(self.__dynamicCfg['pivotShift'])
camMat.postMultiply(rodMat)
camMat.postMultiply(localTransform)
camMat.postMultiply(antiRodMat)
camMat.postMultiply(self.__aimingSystem.matrix)
camMat.invert()
self.__cam.set(camMat)
replayCtrl = BattleReplay.g_replayCtrl
if replayCtrl.isPlaying and replayCtrl.isControllingCamera:
aimOffset = replayCtrl.getAimClipPosition()
binocularsOffset = aimOffset
else:
aimOffset = self.__calcAimOffset(impulseTransform)
binocularsOffset = self.__calcAimOffset()
if replayCtrl.isRecording:
replayCtrl.setAimClipPosition(aimOffset)
self.__aim.offset(aimOffset)
self.__binoculars.setMaskCenter(binocularsOffset.x, binocularsOffset.y)
player = BigWorld.player()
if allowModeChange and (self.__isPositionUnderwater(self.__aimingSystem.matrix.translation) or player.isGunLocked):
self.__onChangeControlMode(False)
return -1
return 0.0
示例3: __cameraUpdate
# 需要导入模块: from Math import Matrix [as 别名]
# 或者: from Math.Matrix import invert [as 别名]
def __cameraUpdate(self):
curTime = BigWorld.time()
deltaTime = curTime - self.__prevTime
self.__prevTime = curTime
if not self.__autoUpdateDxDyDz.x == self.__autoUpdateDxDyDz.y == self.__autoUpdateDxDyDz.z == 0.0:
self.__rotateAndZoom(self.__autoUpdateDxDyDz.x, self.__autoUpdateDxDyDz.y, self.__autoUpdateDxDyDz.z)
self.__aimingSystem.update(deltaTime)
localTransform, impulseTransform = self.__updateOscillators(deltaTime)
ownVehicle = BigWorld.entity(BigWorld.player().playerVehicleID)
if ownVehicle is not None and ownVehicle.isStarted and ownVehicle.appearance.isUnderwater:
self.__onChangeControlMode()
return 0.0
else:
aimMatrix = cameras.getAimMatrix(*self.__defaultAimOffset)
camMat = Matrix(aimMatrix)
rodMat = mathUtils.createTranslationMatrix(-self.__dynamicCfg['pivotShift'])
antiRodMat = mathUtils.createTranslationMatrix(self.__dynamicCfg['pivotShift'])
camMat.postMultiply(rodMat)
camMat.postMultiply(localTransform)
camMat.postMultiply(antiRodMat)
camMat.postMultiply(self.__aimingSystem.matrix)
camMat.invert()
self.__cam.set(camMat)
replayCtrl = BattleReplay.g_replayCtrl
if replayCtrl.isPlaying and replayCtrl.isControllingCamera:
aimOffset = replayCtrl.getAimClipPosition()
binocularsOffset = aimOffset
else:
aimOffset = self.__calcAimOffset(impulseTransform)
binocularsOffset = self.__calcAimOffset()
if replayCtrl.isRecording:
replayCtrl.setAimClipPosition(aimOffset)
self.__aim.offset((aimOffset.x, aimOffset.y))
self.__binoculars.setMaskCenter(binocularsOffset.x, binocularsOffset.y)
return 0.0
示例4: __pickVehicle
# 需要导入模块: from Math import Matrix [as 别名]
# 或者: from Math.Matrix import invert [as 别名]
def __pickVehicle(self):
if self.__boundVehicleMProv is not None:
return
else:
x, y = GUI.mcursor().position
from AvatarInputHandler import cameras
dir, start = cameras.getWorldRayAndPoint(x, y)
end = start + dir.scale(100000.0)
pos, colldata = collideDynamicAndStatic(start, end, (), 0)
vehicle = None
if colldata is not None:
entity = colldata[0]
from Vehicle import Vehicle
if isinstance(entity, Vehicle):
vehMatProv = entity.matrix
vehMatInv = Matrix(vehMatProv)
vehMatInv.invert()
localPos = vehMatInv.applyPoint(pos)
result = Math.MatrixProduct()
localTransMat = Matrix()
localTransMat.translation = localPos
result.a = localTransMat
result.b = vehMatProv
return result
return
示例5: __getLookAtYPR
# 需要导入模块: from Math import Matrix [as 别名]
# 或者: from Math.Matrix import invert [as 别名]
def __getLookAtYPR(self, lookAtPosition):
lookDir = lookAtPosition - self.__position
camMat = Matrix()
camMat.lookAt(self.__position, lookDir, Vector3(0, 1, 0))
camMat.invert()
yaw = camMat.yaw
pitch = camMat.pitch
return Vector3(yaw, pitch, self.__ypr.z)
示例6: bind
# 需要导入模块: from Math import Matrix [as 别名]
# 或者: from Math.Matrix import invert [as 别名]
def bind(self, vehicle, bindWorldPos = None):
self.__vehicle = vehicle
if vehicle is None:
self.matrix = mathUtils.createIdentityMatrix()
self.__lookAtProvider = None
return
toLocalMat = Matrix(vehicle.matrix)
toLocalMat.invert()
self.__boundLocalPos = None if bindWorldPos is None else toLocalMat.applyPoint(bindWorldPos)
self.selectPlacement(_VehicleBounder.SELECT_CHASSIS)
示例7: __switchBind
# 需要导入模块: from Math import Matrix [as 别名]
# 或者: from Math.Matrix import invert [as 别名]
def __switchBind(self):
if self.__basisMProv.isBound:
self.__basisMProv.bind(None)
else:
self.__basisMProv.bind(*self.__entityPicker.pick())
localMat = Matrix(self.__cam.invViewMatrix)
basisInv = Matrix(self.__basisMProv.matrix)
basisInv.invert()
localMat.postMultiply(basisInv)
self.__position = localMat.translation
self.__ypr.set(localMat.yaw, localMat.pitch, localMat.roll)
示例8: __processBindToVehicleKey
# 需要导入模块: from Math import Matrix [as 别名]
# 或者: from Math.Matrix import invert [as 别名]
def __processBindToVehicleKey(self):
if BigWorld.isKeyDown(Keys.KEY_LSHIFT) or BigWorld.isKeyDown(Keys.KEY_RSHIFT):
self.__toggleView()
elif BigWorld.isKeyDown(Keys.KEY_LALT) or BigWorld.isKeyDown(Keys.KEY_RALT):
worldMat = Math.Matrix(self.__cam.invViewProvider)
self.__basisMProv.selectNextPlacement()
boundMatrixInv = Matrix(self.__basisMProv.matrix)
boundMatrixInv.invert()
worldMat.postMultiply(boundMatrixInv)
self.__position = worldMat.translation
self.__ypr = Vector3(worldMat.yaw, worldMat.pitch, worldMat.roll)
else:
self.__switchBind()
示例9: worldHitTest
# 需要导入模块: from Math import Matrix [as 别名]
# 或者: from Math.Matrix import invert [as 别名]
def worldHitTest(self, start, stop, worldMatrix):
worldToLocal = Matrix(worldMatrix)
worldToLocal.invert()
testRes = self.__bspModel.collideSegment(worldToLocal.applyPoint(start), worldToLocal.applyPoint(stop))
if testRes is None:
return
res = []
for dist, normal, hitAngleCos, matKind in testRes:
res.append((dist,
worldMatrix.applyVector(normal),
hitAngleCos,
matKind))
return res
示例10: collideSegment
# 需要导入模块: from Math import Matrix [as 别名]
# 或者: from Math.Matrix import invert [as 别名]
def collideSegment(self, startPoint, endPoint, skipGun = False):
res = None
filterMethod = getattr(self.filter, 'segmentMayHitEntity', lambda : True)
if not filterMethod(startPoint, endPoint, 0):
return res
modelsToCheck = (self.model,) if skipGun else (self.model, self.__gunModel)
for model, desc in zip(modelsToCheck, self.__componentsDesc):
toModel = Matrix(model.matrix)
toModel.invert()
collisions = desc['hitTester'].localHitTest(toModel.applyPoint(startPoint), toModel.applyPoint(endPoint))
if collisions is None:
continue
for dist, _, hitAngleCos, matKind in collisions:
if res is None or res.dist >= dist:
matInfo = desc['materials'].get(matKind)
res = SegmentCollisionResult(dist, hitAngleCos, matInfo.armor if matInfo is not None else 0)
return res
示例11: checkTurretDetachment
# 需要导入模块: from Math import Matrix [as 别名]
# 或者: from Math.Matrix import invert [as 别名]
def checkTurretDetachment(self, worldPos):
if self.__vehicle is None:
return
if self.__vehicle.isTurretDetached and not self.__placement == _VehicleBounder.SELECT_DETACHED_TURRET:
turretFound = None
for turret in DetachedTurret.allTurrets:
if turret.vehicleID == self.__vehicle.id and turret.model.visible:
turretFound = turret
break
if turretFound is None:
return
turretToGoalShift = worldPos - turretFound.position
toTurretMat = Matrix(turretFound.matrix)
toTurretMat.invert()
turretToGoalShift = toTurretMat.applyVector(turretToGoalShift)
self.matrix = turretFound.matrix
self.__lookAtProvider = None
self.__placement = _VehicleBounder.SELECT_DETACHED_TURRET
return turretToGoalShift
示例12: update
# 需要导入模块: from Math import Matrix [as 别名]
# 或者: from Math.Matrix import invert [as 别名]
def update(self, vehicle, deltaTime):
curVelocity = vehicle.filter.velocity
acceleration = vehicle.filter.acceleration
acceleration = self.__accelerationFilter.add(acceleration)
movementFlags = vehicle.engineMode[1]
moveMask = 3
self.__hasChangedDirection = movementFlags & moveMask ^ self.__prevMovementFlags & moveMask or curVelocity.dot(self.__prevVelocity) <= 0.01
self.__prevMovementFlags = movementFlags
self.__prevVelocity = curVelocity
self.__timeLapsedSinceDirChange += deltaTime
if self.__hasChangedDirection:
self.__timeLapsedSinceDirChange = 0.0
elif self.__timeLapsedSinceDirChange > self.__maxAccelerationDuration:
invVehMat = Matrix(vehicle.matrix)
invVehMat.invert()
accelerationRelativeToVehicle = invVehMat.applyVector(acceleration)
accelerationRelativeToVehicle.x = 0.0
accelerationRelativeToVehicle.z = 0.0
acceleration = Matrix(vehicle.matrix).applyVector(accelerationRelativeToVehicle)
self.__acceleration = acceleration
return acceleration
示例13: __worldYawPitchToTurret
# 需要导入模块: from Math import Matrix [as 别名]
# 或者: from Math.Matrix import invert [as 别名]
def __worldYawPitchToTurret(self, worldYaw, worldPitch):
worldToTurret = Matrix(self.__vehicleMProv)
worldToTurret.invert()
worldToTurret.preMultiply(mathUtils.createRotationMatrix((worldYaw, worldPitch, 0.0)))
return (worldToTurret.yaw, worldToTurret.pitch)
示例14: setViewMatrix
# 需要导入模块: from Math import Matrix [as 别名]
# 或者: from Math.Matrix import invert [as 别名]
def setViewMatrix(self, matrix):
invMatrix = Matrix(matrix)
invMatrix.invert()
self.__position = invMatrix.translation
self.__ypr = Vector3(invMatrix.yaw, invMatrix.pitch, invMatrix.roll)