parent
50b88b4e26
commit
6e98f76ce9
27
graphic.py
27
graphic.py
|
|
@ -42,7 +42,7 @@ class Line:
|
||||||
self._points = None
|
self._points = None
|
||||||
self._rotation = None
|
self._rotation = None
|
||||||
|
|
||||||
def curve(self):
|
def curve(self,draw=False)->List:
|
||||||
if self._points:
|
if self._points:
|
||||||
return self._points
|
return self._points
|
||||||
start_p = self._start_p
|
start_p = self._start_p
|
||||||
|
|
@ -53,7 +53,7 @@ class Line:
|
||||||
line = Vector3D(end_p.x, end_p.y, end_p.z) - Vector3D(
|
line = Vector3D(end_p.x, end_p.y, end_p.z) - Vector3D(
|
||||||
start_p.x, start_p.y, start_p.z
|
start_p.x, start_p.y, start_p.z
|
||||||
)
|
)
|
||||||
# 计算与X轴的角度
|
# 计算与X轴的角度,画弧垂。先沿Z轴旋转到xz平面的x正半轴上。
|
||||||
xy_project = copy.deepcopy(line) # 投影到xy平面上
|
xy_project = copy.deepcopy(line) # 投影到xy平面上
|
||||||
xy_project.z = 0
|
xy_project.z = 0
|
||||||
x_abs_angel = xy_project.angle_to(Vector3D(1, 0, 0))
|
x_abs_angel = xy_project.angle_to(Vector3D(1, 0, 0))
|
||||||
|
|
@ -72,7 +72,7 @@ class Line:
|
||||||
] = list() # 未旋转之前的伪坐标
|
] = list() # 未旋转之前的伪坐标
|
||||||
for foo in range(len(span_l)):
|
for foo in range(len(span_l)):
|
||||||
p_points.append((span_l[foo] + start_p.x, start_p.y, z_points[foo]))
|
p_points.append((span_l[foo] + start_p.x, start_p.y, z_points[foo]))
|
||||||
# 绕Z轴旋转
|
# 绕起点,在Z轴方向旋转
|
||||||
rotation = transformation.Rotation(
|
rotation = transformation.Rotation(
|
||||||
x_angel,
|
x_angel,
|
||||||
[start_p.x, start_p.y, start_p.z],
|
[start_p.x, start_p.y, start_p.z],
|
||||||
|
|
@ -83,11 +83,12 @@ class Line:
|
||||||
p_points,
|
p_points,
|
||||||
)
|
)
|
||||||
self._points = points
|
self._points = points
|
||||||
msp = self._msp
|
if draw:
|
||||||
msp.add_polyline3d(points)
|
msp = self._msp
|
||||||
|
msp.add_polyline3d(points)
|
||||||
return points
|
return points
|
||||||
|
|
||||||
def sag(self):
|
def sag(self,draw=False):
|
||||||
start_p = self._start_p
|
start_p = self._start_p
|
||||||
end_p = self._end_p
|
end_p = self._end_p
|
||||||
span = self._span
|
span = self._span
|
||||||
|
|
@ -114,12 +115,13 @@ class Line:
|
||||||
] # 旋转前的值
|
] # 旋转前的值
|
||||||
sag_points = rotation.rotate(p_sag_points)
|
sag_points = rotation.rotate(p_sag_points)
|
||||||
sag_value = start_p.z + middle_span * height / span - middle_z
|
sag_value = start_p.z + middle_span * height / span - middle_z
|
||||||
msp = self._msp
|
if draw:
|
||||||
msp.add_polyline3d(sag_points)
|
msp = self._msp
|
||||||
draw_text(msp, f'sag {sag_value}', sag_points[1])
|
msp.add_polyline3d(sag_points)
|
||||||
|
draw_text(msp, f'sag {sag_value}', sag_points[1])
|
||||||
return sag_points
|
return sag_points
|
||||||
|
|
||||||
def swing(self, angel):
|
def swing(self, angel,draw=False)->List:
|
||||||
if not self._points:
|
if not self._points:
|
||||||
self.curve()
|
self.curve()
|
||||||
points = self._points
|
points = self._points
|
||||||
|
|
@ -131,8 +133,9 @@ class Line:
|
||||||
[end_p.x, end_p.y, end_p.z],
|
[end_p.x, end_p.y, end_p.z],
|
||||||
)
|
)
|
||||||
swing_point = swing_rotation.rotate(points)
|
swing_point = swing_rotation.rotate(points)
|
||||||
msp = self._msp
|
if draw:
|
||||||
msp.add_polyline3d(swing_point)
|
msp = self._msp
|
||||||
|
msp.add_polyline3d(swing_point)
|
||||||
return swing_point
|
return swing_point
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue