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


Python Matrix.evalf方法代码示例

本文整理汇总了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()
开发者ID:AlfiyaZi,项目名称:Py3DFreeHandUS,代码行数:33,代码来源:example1.py

示例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
开发者ID:Lucaweihs,项目名称:sympy,代码行数:6,代码来源:test_matrices.py

示例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")
开发者ID:meshadaptation,项目名称:pragmatic,代码行数:33,代码来源:generate_Steiner_ellipse_3d.py


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