VB Script to Divide an angle

Hey Everyone,

I am new to VB and I am trying to write something that will divide an angle in a particular way.

I have attached an image of an angle and some components that i was using to think through the problem. I have also attached the gh file.

1. I would like to have the inputs be an angle and a number of divisions.

2. Then i need to take the number of divisions and add one to it (example: # of Divisions = 4 so then the number we are actually dividing the angle by would be 5)

In this example the angle 83.53 is divided by 5 to give you a 16.706 angle.

3.Then the divided angle number gets divided by 2 (16.706/2=8.353)

4. The smaller angle number should always be the end angles and the other angles should be the larger number.

I need this to be recursive so that when the number of divisions changes you dont have to copy another rotate component.

I know this was probably a little unclear. I hope the attached file and image help.

I am not sure how to start writing this in a vb component.

If anyone could help me get started I would sincerely appreciate it.

Thanks,

Michelle

  • up

    Michelle Frantellizzi

    I could also try to do this in python. I am currently trying to start both. 

    • up

      Thomas

      Hi Michelle!

      I wrote:

      Private Sub RunScript(ByVal angle As Double, ByVal n As Integer, ByRef A As Object)

        Dim divAngle As Double = angle / (n + 1)

        Dim angles As New List(Of Double)(n)

        For i As Integer = 0 To n
          angles.Add((i + 0.5) * divAngle)
        Next

        A = angles

      End Sub

      In the attached file you will find a second component which includes the bounding angles (0 and 83.53)

      Greetings!

      4