我想知道为什么绿色曲线下的面积(面向x或红色曲线)与蓝色曲线下的面积不同?当一个区域在 2D 中推理时,无论 z 轴是什么,我们应该有类似的东西?
如何正确计算 3D 中蓝色和红色曲线之间的面积? :
这里有一个片段示例:
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
import math
%matplotlib widget
x_max = [ 0 ,0.30473705, 0.61084798, 0.92107771 ,1.23816188, 1.56481854 ,1.90373634, 2.25755771 ,2.62885515, 3.02009822 ,3.43360879 ,3.87150099, 4.33560211, 4.82734953 ,5.34765826 ,
5.8967524, 6.4739534 ,7.07741748, 7.70381481, 8.34794525, 9.0022899, 9.65650683 ,10.29689661, 10.63238871, 10.96583401, 11.29574022 ,11.62058439, 11.93898196, 12.24985216, 12.55250925, 12.84666547 ,
13.13237121 ,13.40992797 ,13.67980107, 13.94254652 ,14.19875635, 14.44902132 ,14.69390756, 14.93394339 ,15.16961312 ,15.40135543 ,15.62956446 ,15.85459244]
y_max = [0 , 0.58066397, 1.16060483, 1.7383529 ,2.31236765 ,2.88098944 ,3.4423895 ,3.99451788 ,4.53504866 ,5.06132252, 5.57028649, 6.05843167 ,6.52173013 ,6.95557317,
7.35471492 ,7.71322704 ,8.02447342, 8.28111796, 8.47518419 ,8.59819344 ,8.64141831, 8.59630147, 8.45510575, 8.37804206, 8.29255528, 8.19429211, 8.0804061 ,7.94957511 ,
7.8017459, 7.63775674 ,7.45896669 ,7.26696151 ,7.06335404 ,6.84966673 ,6.62727386 ,6.39738196, 6.16103222, 5.91911387 ,5.67238211 ,5.42147667 ,5.16693933 ,4.90922942 ,4.64873726]
x_max = np.array(x_max)
y_max = np.array(y_max)
DIR = 0
xs = (x_max * math.cos(np.radians(DIR)))
ys = (x_max * math.sin(np.radians(DIR)))
zs = y_max
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.scatter(xs, ys, zs, c='r')
r = [0.00514934, 0.00562866 ,0.00608251, 0.0065109 , 0.00691381 ,0.00729126,
0.00764323 ,0.00796974, 0.00827078 ,0.00854635, 0.00879645, 0.00902109,
0.00922025, 0.00939395 ,0.00954217 ,0.00966493 ,0.00976222 ,0.00983404,
0.0098804 , 0.00990128, 0.00989368, 0.00984825 ,0.00976431 ,0.00964188,
0.00948093 ,0.00928149 ,0.00904354 ,0.00876709 ,0.00845214 ,0.00809868,
0.00770672 ,0.00727626, 0.0068073 , 0.00629983 ,0.00575386 ,0.00516939,
0.00454641, 0.00388493 ,0.00318495, 0.00244647 ,0.00166948 ,0.00085399,
0 ]
r = np.array(r) * 90
px_p, py_p = [], []
for idx in range(len(xs)-1):
x0, y0, xa, ya = xs[idx], ys[idx], xs[idx+1], ys[idx+1]
dx_p, dy_p = xa-x0, ya-y0
norm_p = math.hypot(dx_p, dy_p) * 1/r[idx]
dx_p /= norm_p
dy_p /= norm_p
px_p.append(x0-dy_p)
py_p.append(y0+dx_p)
px_p = np.insert(px_p, 0, px_p[0])
py_p = np.insert(py_p, 0, py_p[0])
ax.scatter(px_p, py_p, zs, c='b')
print('area red-blue', np.trapz(px_p, py_p))
ax.scatter(px_p, r, 0, c='g')
print('area red-green', np.trapz(px_p, r))
plt.show()