|
请教各位大侠如何绘制sin+sin的图?. ^5 q+ {- `, Q& {( Y' _
2 ]5 R$ F' T9 i/ O
我只找到sin的宏,现在想2个sin相加( l) U: a# x" p9 W; R+ @
: V0 T4 G' E0 [5 S这是我在网上找的,) q. w' l) T' x$ J; ~6 q) d0 I
Sub sin2()
y+ `3 L% S0 ['由正弦曲线的起点、幅度、周期、周波数、方向来画正弦曲线
; c- a7 \2 ? i* r5 P: s8 @Dim sinObj As AcadLWPolyline
4 k, ~# z: L! h6 oDim points() As Double
" I2 K* g! Q- J. u, hDim a, n, k As Integer" P, c. y# ?- T: \0 B: o. a0 j' b
Dim H, f As Double
+ [( m! Y" j0 l Q# VDim pa, pb As Variant
" s- W- i. `1 K Q) ^ ~PI = 3.1415926535
# q# F; d2 x* p: ?7 y3 u
+ K3 g8 u) X! O+ @0 e9 p' w0 E+ epa = ThisDrawing.Utility.GetPoint(, "请输入正弦曲线起点:")
) @# `' _( [6 j1 g* O [0 EH = ThisDrawing.Utility.GetDistance(pa, "请正弦曲线幅度:")) ^4 X5 g8 o) Q7 K3 C. K
f = ThisDrawing.Utility.GetDistance(pa, "请正弦曲线周期:")
! P8 A L( z2 H- O9 `n = ThisDrawing.Utility.GetReal("请输入正弦曲线周波数:")
7 x8 _6 T' n8 L5 k4 C! t# Ck = ThisDrawing.Utility.GetReal("请输入正弦曲线每周波线段数(建议不小于36):")
+ _7 j5 m; a: S! j. A. M0 Hpb = ThisDrawing.Utility.GetPoint(pa, "请输入点以确定正弦曲线的方向:")
8 b5 C8 e, Q' R8 }% z5 I. U" u4 ~* j6 p: ]8 `* I# O9 B8 T% B* `
ReDim points(0 To 2 * k * n + 1) As Double$ M4 d- W- q, V$ ^ b& W$ R
b = ThisDrawing.Utility.AngleFromXAxis(pa, pb)
4 u' R0 I2 N, p5 e' h% Q- @( Q" J, n4 j I; `) @; h* O; f" i
For a = 0 To 2 * k * n Step 2
) }2 L2 G: m' Y `5 Epoints(a) = pa(0) + f * (a / 2) / k
, D, y5 [ c8 g- ~ Qpoints(a + 1) = pa(1) + H * Sin(2 * PI * a / k / 2)
' |4 r5 O- `7 D+ l8 Q" e' c" C: ]Next
J' o* f; R" L8 j
0 R( P2 Y6 Z5 a2 ~2 F ]Set sinObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)7 N' g' K: q2 R3 l( ]2 |
sinObj.Rotate pa, b
# o/ p' W, b# Y# l% U6 h; aZoomExtents/ R( I4 L) W/ n2 d+ x3 D
End Sub. {" Y2 o! z# G7 P: w2 z
L$ m2 x/ o5 x( _5 y
5 f( x3 f( }) s! V" J: v6 ~如果可以输入2个sin各自的幅度和周期就可以知道他们相加的曲线!,谢谢 |
|