Rs Archimedean Spiral
Last changed: -211.41.30.121

.
DeveloperRhinoScript
Version4.0
SummaryRhinoScript 를 사용하여 아르키메데스의 나선을 그리는 방법을 소개합니다.

질문

수식을 사용한 극좌표에서 아르키메테스의 나선을 정의할 수 있습니까?

답변

극좌표 (r, θ) 에서 다음과 같은 수식을 사용하여 아르키메데스의 나선을 그릴 수 있습니다:

 _a_ 와 _b_는 숫자입니다. 매개변수 _a_ 를 변경하면 나선이 회전하고, _b_ 는 계속된 회전 사이의 거리를 제어합니다.

우선 극좌표가 계산되면, RhinoScript의 Polar 메서드을 사용하여 이를 데카르트 좌표값으로 변환할 수 있으며, RhinoScript의 AddInterpCurve 메서드를 사용하여 커브를 구상할 수 있습니다.

다음은, 위의 수식을 사용하여 계산된 점들을 통해 보간하는 커브를 만드는 방법을 보여주는 샘플 스크립트 코드입니다.

  '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  ' ArchimedeanSpiral.rvb -- June 2008
  ' 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 ArchimedeanSpiral()


    Dim a_const, b_const, step_angle, num_points
    Dim curr_angle, base_point, radius, points(), i


    Rhino.Print "Archimedean Spiral (r = a + bθ)"


    a_const = Rhino.GetReal("Value of 'A' constant", 1.0, 0.01)
    If IsNull(a_const) Then Exit Sub


    b_const = Rhino.GetReal("Value of 'B' constant", 1.0, 0.01)
    If IsNull(a_const) Then Exit Sub


    num_points = Rhino.GetInteger("Number of points to calculate", 10, 2)
    If IsNull(num_points) Then Exit Sub


    step_angle = Rhino.GetReal("Angle between points", 30.0, 1.0, 45.0)
    If IsNull(step_angle) Then Exit Sub


    curr_angle = 0.0
    base_point = Array(0.0, 0.0, 0.0)
    ReDim points(num_points - 1)


    For i = 0 To UBound(points)
      radius = a_const + (b_const * curr_angle)
      points(i) = Rhino.Polar(base_point, radius, curr_angle)
      curr_angle = curr_angle + step_angle
    Next


    Rhino.AddInterpCurve points
    'Rhino.AddPoints points


  End Sub