forked from mcneel/MOVED-rhinoscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArcPointDistribution.rvb
52 lines (39 loc) · 1.28 KB
/
ArcPointDistribution.rvb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ArcPointDistribution.rvb -- February 2009
' If this code works, it was written by Dale Fugier.
' If not, I don't know who wrote it.
' Works with Rhino 4.0.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
Sub ArcPointDistribution
' Local variables
Dim arc, cnt, rads
Dim n_t(), n, i, a0, a1
Dim line, dom, t
' Select arc curve
arc = Rhino.GetObject("Select arc", 4)
If IsNull(arc) Then Exit Sub
If Not Rhino.IsArc(arc) Then Exit Sub
' Get number of points to calculate
cnt = Rhino.GetInteger("Number of points", 2)
If IsNull(cnt) Then Exit Sub
rads = Rhino.ToRadians(Rhino.ArcAngle(arc))
n = cnt - 1
ReDim n_t(n)
' Calculate normalized parameters
For i = 0 To n
a0 = Sin(rads/2)
a1 = Sin(i*rads/n - rads/2)
n_t(i) = (a0+a1)/(2*a0)
Next
Rhino.EnableRedraw False
line = Rhino.AddLine(Rhino.CurveStartPoint(arc), Rhino.CurveEndPoint(arc))
dom = Rhino.CurveDomain(line)
For i = 0 To n
' Convert normalized parameter to domain value
t = (1.0 - n_t(i)) * dom(0) + n_t(i) * dom(1)
Rhino.AddPoint Rhino.EvaluateCurve(line, t)
Next
'Rhino.DeleteObject line
Rhino.EnableRedraw True
End Sub