本文整理汇总了Python中sympy.Matrix.evalf方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.evalf方法的具体用法?Python Matrix.evalf怎么用?Python Matrix.evalf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.Matrix
的用法示例。
在下文中一共展示了Matrix.evalf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Symbol
# 需要导入模块: from sympy import Matrix [as 别名]
# 或者: from sympy.Matrix import evalf [as 别名]
# Calculate pose from US probe to laboratory reference frame
p.calculatePoseForUSProbe(mkrList=('Rigid_Body_1-Marker_1','Rigid_Body_1-Marker_2','Rigid_Body_1-Marker_3','Rigid_Body_1-Marker_4'))
# Calculate pose from US images to laboratory reference frame
p.calculatePoseForUSImages()
# Reorient global reference frame to be approximately aligned with US scans direction
from sympy import Matrix, Symbol, cos as c, sin as s
alpha = Symbol('alpha')
beta = Symbol('beta')
T1 = Matrix(([1,0,0,0],
[0,c(alpha),s(alpha),0],
[0,-s(alpha),c(alpha),0],
[0,0,0,1]
))
T = T1.evalf(subs={'alpha':np.deg2rad(-10.)})
T = np.array(T).astype(np.float)
# Set time frames for images that can be cointaned in the voxel array
p.setValidFramesForVoxelArray(voxFrames='auto')
# Calculate convenient pose for the voxel array
p.calculateConvPose(T)
# Calculate scale factors
#fxyz = 'auto_bounded_parallel_scans'
fxyz = (1,10,1)
p.setScaleFactors(fxyz)
# Calculate voxel array dimensions
p.calculateVoxelArrayDimensions()
示例2: test_evalf
# 需要导入模块: from sympy import Matrix [as 别名]
# 或者: from sympy.Matrix import evalf [as 别名]
def test_evalf():
a = Matrix([sqrt(5), 6])
assert abs(a.evalf()[0] - a[0].evalf()) < 1e-10
assert abs(a.evalf()[1] - a[1].evalf()) < 1e-10
示例3: Matrix
# 需要导入模块: from sympy import Matrix [as 别名]
# 或者: from sympy.Matrix import evalf [as 别名]
[(x1[0] - x2[0])**2, (x1[1] - x2[1])**2, (x1[2] - x2[2])**2, (x1[1] - x2[1])*(x1[2] - x2[2]), (x1[0] - x2[0])*(x1[2] - x2[2]), (x1[0] - x2[0])*(x1[1] - x2[1])],
[(x2[0] - x3[0])**2, (x2[1] - x3[1])**2, (x2[2] - x3[2])**2, (x2[1] - x3[1])*(x2[2] - x3[2]), (x2[0] - x3[0])*(x2[2] - x3[2]), (x2[0] - x3[0])*(x2[1] - x3[1])],
[(x3[0] - x1[0])**2, (x3[1] - x1[1])**2, (x3[2] - x1[2])**2, (x3[1] - x1[1])*(x3[2] - x1[2]), (x3[0] - x1[0])*(x3[2] - x1[2]), (x3[0] - x1[0])*(x3[1] - x1[1])],
[(x1[0] - x4[0])**2, (x1[1] - x4[1])**2, (x1[2] - x4[2])**2, (x1[1] - x4[1])*(x1[2] - x4[2]), (x1[0] - x4[0])*(x1[2] - x4[2]), (x1[0] - x4[0])*(x1[1] - x4[1])],
[(x2[0] - x4[0])**2, (x2[1] - x4[1])**2, (x2[2] - x4[2])**2, (x2[1] - x4[1])*(x2[2] - x4[2]), (x2[0] - x4[0])*(x2[2] - x4[2]), (x2[0] - x4[0])*(x2[1] - x4[1])],
[(x3[0] - x4[0])**2, (x3[1] - x4[1])**2, (x3[2] - x4[2])**2, (x3[1] - x4[1])*(x3[2] - x4[2]), (x3[0] - x4[0])*(x3[2] - x4[2]), (x3[0] - x4[0])*(x3[1] - x4[1])]])
R = Matrix([[1], [1], [1], [1], [1], [1]])
# http://en.wikipedia.org/wiki/Tetrahedron#Formulas_for_a_regular_tetrahedron
tetrahedron = {x1[0]:1, x1[1]:0, x1[2]:-4/sqrt(2),
x2[0]:-1, x2[1]:0, x2[2]:-4/sqrt(2),
x3[0]:0, x3[1]:2, x3[2]:4/sqrt(2),
x4[0]:0, x4[1]:-2, x4[2]:4/sqrt(2)}
Mi = M.evalf(subs=tetrahedron)
Sxx, Syy, Szz, Syz, Sxz, Sxy = Mi.inv()*R
SteinerEllipse = Matrix([
[Sxx, Sxy, Sxz],
[Sxy, Syy, Syz],
[Sxz, Syz, Szz]])
print("SteinerEllipse = ")
pprint(SteinerEllipse)
if Sxx==1./2**2 and Syy==1./4**2 and Szz==1./8**2 and Syz==0.0 and Sxz==0.0 and Sxy==0.0:
print("pass")
else:
print("fail")