|
请教各位大侠如何绘制sin+sin的图?; ^& Q! |8 i& y9 `6 o9 \
; d+ m; A* H: o A! Z: T) L我只找到sin的宏,现在想2个sin相加7 ]- K! h8 ~7 k2 [3 n1 a
! a* J; J3 G1 l5 P! R+ }& [
这是我在网上找的,
& U) m- l4 D' a" a3 @) M% K; ]Sub sin2()
+ K5 |/ X* c0 ]+ ^1 ]" D4 h'由正弦曲线的起点、幅度、周期、周波数、方向来画正弦曲线
) K9 I& f/ y4 ^Dim sinObj As AcadLWPolyline
& V4 S' f* U; K( [Dim points() As Double+ b8 S O& i: K: B1 B7 A: @
Dim a, n, k As Integer& \$ h0 i: b& M3 I
Dim H, f As Double
]# f8 f$ N8 d" o, m. }5 y* s" EDim pa, pb As Variant" V7 l- B) L+ m5 H8 N
PI = 3.1415926535
6 l& c8 Z: E1 [& O! c6 V/ X! e6 z4 Q
pa = ThisDrawing.Utility.GetPoint(, "请输入正弦曲线起点:")
0 s# N# Z# ]- mH = ThisDrawing.Utility.GetDistance(pa, "请正弦曲线幅度:")
8 z) T+ g5 W- b7 Ef = ThisDrawing.Utility.GetDistance(pa, "请正弦曲线周期:")
; \ }5 ?6 Y2 D! ]: rn = ThisDrawing.Utility.GetReal("请输入正弦曲线周波数:")
# ?! v# ^1 k6 O8 Q( S8 dk = ThisDrawing.Utility.GetReal("请输入正弦曲线每周波线段数(建议不小于36):") x: i `4 S" e$ Q) ?2 X
pb = ThisDrawing.Utility.GetPoint(pa, "请输入点以确定正弦曲线的方向:")" x0 G, n) I3 `' V" a/ Z \
6 C# d4 o( P& n, `2 u6 B
ReDim points(0 To 2 * k * n + 1) As Double4 {- w* Z% B5 y9 _
b = ThisDrawing.Utility.AngleFromXAxis(pa, pb)
# }0 i. }- D1 } L' ]% H& w
0 G+ S6 f* {2 aFor a = 0 To 2 * k * n Step 2* Q: P2 b' ^; [/ {# ]
points(a) = pa(0) + f * (a / 2) / k4 \9 J* ]2 _6 O @/ e
points(a + 1) = pa(1) + H * Sin(2 * PI * a / k / 2)
/ i$ |# A, @9 x- {, MNext* p+ ~6 g0 F% ?3 K1 B
/ U! R; ^: c; V; j" g& p/ uSet sinObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points). k1 W7 L, a& v9 @4 `
sinObj.Rotate pa, b3 ~: T7 u# E' |8 M
ZoomExtents* ]& v9 h( e) C' ~+ s3 w/ X
End Sub
( B) o4 D: z. s Q& y) d
0 q2 \4 v6 z. S [" t
$ K4 i5 R7 D' u2 V+ f/ Q如果可以输入2个sin各自的幅度和周期就可以知道他们相加的曲线!,谢谢 |
|