两个圆柱形管的相贯存在4种形式,正交、偏置、斜交和偏置斜交。
本文仅讨论偏置情况下的计算方法。
建立如下坐标系,圆柱1的轴线为Z轴,圆柱2的轴线与Y轴平行,通过右手法则确定X轴,圆柱2的轴线在XOY平面上。圆柱1半径为a
,圆柱2半径为b
,圆柱2的轴线相较于Y轴偏移距离为ΔX
,其中b > a
。
采用极坐标系表示两个圆柱面和法线矢量:
∑ 1 \sum_1 ∑1: x 1 = a cos θ x_1 = a\cos \theta x1=acosθ, y 1 = a sin θ y_1 = a\sin \theta y1=asinθ, z 1 = u z_1 = u z1=u;
法向量: n x 1 = cos θ , n y 1 = sin θ , n z 1 = 0 n_{x1} = \cos \theta, n_{y1} = \sin \theta, n_{z1}=0 nx1=cosθ,ny1=sinθ,nz1=0
∑ 2 \sum_2 ∑2: x 2 = Δ x + b cos φ x_2 = \Delta x +b\cos \varphi x2=Δx+bcosφ, y 2 = v y_2 = v y2=v, z 2 = b sin φ z_2 = b \sin \varphi z2=bsinφ
法向量: n x 2 = cos φ , n y 2 = 0 , n z 2 = sin φ n_{x2} = \cos \varphi, n_{y2} =0, n_{z2}= \sin \varphi nx2=cosφ,ny2=0,nz2=sinφ
相贯线同时位于两个圆柱面上,即满足
x 1 = x 2 , y 1 = y 2 , z 1 = z 2 x_1=x_2, y_1=y_2, z_1=z_2 x1=x2,y1=y2,z1=z2
由于a, b, Δ x \Delta x Δx为已知,且a < b
,则 θ \theta θ的取值范围为( 0 − 2 π 0-2\pi 0−2π),根据需要的点距可以选择不同的步长。
可解出相贯线的空间坐标关于 θ \theta θ的方程如下:
x = a cos θ x = a \cos \theta x=acosθ
y = a sin θ y = a \sin \theta y=asinθ
z = b 2 − ( x − Δ x ) 2 z = \sqrt{b^2-(x-\Delta x)^2} z=b2−(x−Δx)2
用python
实现如下:
import math
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
# 圆柱1半径:radius_1; 偏置距离:offset
# 圆柱2半径:rasius_2; (直径大)
# 点距: theta;(按弧度)
class IntersectingLine():
def __init__(self):
self.radius_1 = 8.0
self.radius_2 = 30.0
self.center_offset = 10.0
self.step_theta = 0.04
# 计算空间坐标,保存在 ndarray中
def calculate_coordinates(self, r1, r2, offset, theta):
shape = ((int)(math.pi * 2 / theta), 3)
coords = np.zeros(shape, dtype=float)
for i in range(shape[0]):
coords[i][0] = r1 * math.cos(i*theta)
coords[i][1] = r1 * math.sin(i*theta)
coords[i][2] = math.sqrt(r2*r2 - math.pow((coords[i][0] - offset), 2))
return coords
# 根据坐标点绘制三维散点图
def plot_coordinates(self, coordinates):
fig = plt.figure()
ax = Axes3D(fig)
ax.view_init(elev=45, azim=135)
ax.scatter3D(coordinates[:,0], coordinates[:,1], coordinates[:,2], cmap='Blues')
plt.show()