python符号计算
# # 需要两个映射对
x1 = 1.23
y1 = 4.56
x2 = 0.34586196581172324
y2 = -2.6774569407134363
x3 = 0.12
y3 = 6.123
x4 = 1.6413879324508256
y4 = -4.0904967383708914
# 需要两个映射对
# x1 = Symbol('x1')
# y1 = Symbol('y1')
# x2 = Symbol('x2')
# y2 = Symbol('y2')
# x3 = Symbol('x3')
# y3 = Symbol('y3')
# x4 = Symbol('x4')
# y4 = Symbol('y4')
# 参数
th = Symbol('th')
cos_th = Symbol('cos_th')
sin_th = Symbol('sin_th')
a = Symbol('a')
b = Symbol('b')
# solved_value = solve([
# x1 * np.cos(th) - y1 * np.sin(th) + a - x2,
# x1 * np.sin(th) + y1 * np.cos(th) + b - y2,
# x3 * np.cos(th) - y3 * np.sin(th) + a - x4,
# x3 * np.sin(th) + y3 * np.cos(th) + b - y4
# ], [th, a, b])
solved_value = solve([
x1 * cos_th - y1 * sin_th + a - x2,
x1 * sin_th + y1 * cos_th + b - y2,
x3 * cos_th - y3 * sin_th + a - x4,
x3 * sin_th + y3 * cos_th + b - y4
], [cos_th, sin_th, a, b])
solved_value
|