Results 1 to 10 of 10

Thread: Calculate angle between points

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2015
    Posts
    174

    Calculate angle between points

    I've an array with values, I need to calculate the angle between them, like in picture, assuming the increment of x is always 1
    Name:  Untitled.jpg
Views: 450
Size:  10.6 KB
    So i tryed:
    Code:
     Const Rad2Deg As Double = 180.0 / Math.PI
       Const Deg2Rad As Double = Math.PI / 180.0
       Dim newlist As New List(Of UShort)
     
            For i = 0 To MySourceArray.Length - 1 Step 1
              Dim first As UShort = MySourceArray(i)
              Dim second As UShort = MySourceArray(i + 1)
                Dim angle = Math.Atan2(first - second, 1) * Rad2Deg
                newlist.Add(angle)
            Next
    Some data for the arrays:
    Code:
      &H2020,&H 4544,&H4331,&H372E,&H434F,&H4D20,&H2020,&H2020
    but I get overflow exception at the line where Atan2 is calculated. But if I try to do the the calc manually the result seem ok.
    What am I missing?
    Last edited by hannibal smith; Dec 14th, 2021 at 05:41 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width