การคำนวณและพล็อต Curl ของ Vector Field 3D
ใช้ quiver() แสดง vector field 3D คำนวณ curl components
ขั้นตอนหลัก
- ตั้งค่าขนาดรูปและ padding
- สร้าง figure และ 3D axes
- สร้าง meshgrid x, y, z
- กำหนด vector components u, v, w (curl field)
- ใช้ ax.quiver() แสดง vectors
- ปิด axes ด้วย ax.axis('off')
- แสดงผลด้วย show()
ตัวอย่างโค้ด
import matplotlib.pyplot as plt
import numpy as np
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
fig = plt.figure()
ax = fig.add_subplot(projection='3d')
x, y, z = np.meshgrid(np.arange(-0.8, 1, 0.2),
np.arange(-0.8, 1, 0.2),
np.arange(-0.8, 1, 0.8))
u = 0
v = y**2
w = -2*y*z - y
ax.quiver(x, y, z, u, v, w, length=0.1)
ax.axis('off')
plt.show()
คำอธิบาย
Vector field: F = (0, y², -2yz - y) Curl F = (∂w/∂y - ∂v/∂z, ∂u/∂z - ∂w/∂x, ∂v/∂x - ∂u/∂y) = (-2z - 1, 0, 0)