예제 #1
0
if __name__ == '__main__':

    #f = Function('f')(x, y)
    #g1 = Function('g')(x, y)
    a1, a2, a3, ao1, ao2, theta1, theta2, theta3, theta4 = symbols(
        'a1,a2,a3,ao1,ao2,theta1,theta2,theta3,theta4')
    m = Manifold('M', 4)
    patch = Patch('P', m)
    rect = CoordSystem('rect', patch)
    polar = CoordSystem('polar', patch)
    rect in patch.coord_systems
    polar.connect_to(rect, [theta1, theta2, theta3, theta4], [
        a1 * theta1 + a2 * theta2 + a3 * theta3 +
        (theta1 * ao1 + theta2 * ao2) * theta4
    ])
    print(polar.jacobian(rect, [theta1, theta2, theta3, theta4]))
    g = polar.jacobian(rect, [theta1, theta2, theta3, theta4])

    patch2 = Patch('P', m)
    rect2 = CoordSystem('rect2', patch2)
    polar2 = CoordSystem('polar2', patch2)
    rect2 in patch2.coord_systems
    polar2.connect_to(rect2, [theta1, theta2, theta3, theta4], g)
    print(polar2.jacobian(rect2, [theta1, theta2, theta3, theta4]))
    H = polar2.jacobian(rect2, [theta1, theta2, theta3, theta4])
'''
    n = Manifold('M', 1)
    patch3 = Patch('P', n)
    rect3 = CoordSystem('rect3', patch3)
    polar3 = CoordSystem('polar3', patch3)
    rect3 in patch3.coord_systems
예제 #2
0
m = Manifold('M', 2)
patch = Patch('P', m)

rect = CoordSystem('rect', patch)
polar = CoordSystem('polar', patch)

print(rect in patch.coord_systems)

polar.connect_to(rect, [r, theta], [r*cos(theta), r*sin(theta)])

print(polar.coord_tuple_transform_to(rect, [0, 2]))
print(polar.coord_tuple_transform_to(rect, [2, pi/2]))
print(rect.coord_tuple_transform_to(polar, [1, 1]).applyfunc(simplify))

print(polar.jacobian(rect, [r, theta]))

p = polar.point([1, 3*pi/4])
print(rect.point_to_coords(p))
print(rect.coord_function(0)(p))
print(rect.coord_function(1)(p))

v_x = rect.base_vector(0)
x = rect.coord_function(0)
print(v_x(x))
print(v_x(v_x(x)))

v_r = polar.base_vector(0)
print(v_r(x))
# ^ ????
예제 #3
0
파일: coord.py 프로젝트: baijianhua/pymath
# 建立两个坐标系之间的转换关系,逆变换是自动的。
# 这个地方,如果笛卡尔是3维,另一个是2维曲面(但是也用u,v,不用极坐标,那会怎么样呢?)
polar.connect_to(rect, [r, theta], [r * cos(theta), r * sin(theta)])
# t = polar.coord_tuple_transform_to(rect, [1, pi])
# 极坐标存在奇点,r = 0时,其他怎么取都是0

t = polar.coord_tuple_transform_to(rect, [0, pi])
print(t)
t = polar.coord_tuple_transform_to(rect, [2, pi / 2])
print(t)
t = rect.coord_tuple_transform_to(polar, [0, 2])
print(t)

# 雅克比矩阵。极坐标到笛卡尔坐标系的变换矩阵函数,在每个点,是可以求出一个具体的矩阵的
# 但整体来说是一个函数。
m = polar.jacobian(rect, [r, theta])
print(m)
plot_latex(latex(m))
# 笛卡尔坐标系到笛卡尔坐标系的雅克比矩阵是单位矩阵
m = rect.jacobian(rect, [x, y])
# plot_latex(latex(m))

p = rect.point([3, 2])
# base_vector返回一个向量场。给定一个点,会返回一个向量?
# v_x = rect.base_vector(0)
# v_y = rect.base_vector(1)
# pprint(v_x(p), v_y(p))

# 返回标量场。标量场的意思是取一个点,返回一个标量值。x y轴可以视为两个天然的标量场,但应该开可以返回其他标量场
x_scalar_field = rect.coord_function(0)