Decimal Degrees to Degrees, Minutes and Seconds

Hello GH Community,

I am hoping the community can help and provide some direction. I would like to achieve this without any other plugins by using standard GH math functions so I can see what is happening.

I have a circle divided into 196 points and I would like to:

A) tag each point with a reference 0 thru 195 (already done)
B) tag each reference point (0-195) with another tag showing the decimal degree as measured from 0 -1, 0-2, 0-3 and so on thru to 0-195 in a clockwise direction - is there a quick to do this instead of isolating the two points each time as I have attempted in the definition?
C) tag each reference point (0-195) with the corresponding degree, minute and second.

So far I have measured the decimal angle between points 0 and 1 which is 1.836733 degrees.

Question part 1: Is there a way to split the decimal “1.836733” into two parts. One part would be the integer number, in this case “1” and the second part would be the fractional number, in this case “0.836733”.

From there I can then calculate for “minutes” by multiplying the fractional number (0.836733) by 60.
This would result in “50.203956” minutes.

I would then split the number again into the integer and fractional remainder of “0.203956” to solve for seconds by multiplying “0.203956” by 60.

I would like to get all that info above (decimal degree, degree minutes and seconds) tagged to the relevant point.

thanks in advance for any help.

degrees minutes seconds.gh (12.6 KB)

Here’s one way to split the number:

Regards
Jeremy

1 Like

Or another:

2 Likes

By using the method provided by Jeremy, the rest part(marking angle)will not be difficult.


degrees minutes seconds_re.gh (21.8 KB)

2 Likes

Since this is a circle, why bother measuring Vec2Pt angles? You know that each angle will be the same (360 / number of points). Like this:

angles_2019Jun21a

Converting these fractional degrees to minutes and seconds is simple math… Padding single digit numbers with a leading zero and displaying the tags in a radial pattern is extra work. This can probably be simplified.

DMS_2019Jun21a.gh (20.5 KB) (deprecated)

P.S. It’s best to avoid running data through text panels. Hook them up so they can be deleted without affecting the results.

P.P.S. Take two, that was a mess. Didn’t even look at the output, which was clearly wrong. Doh!

So I lifted a couple of bits from @HS_Kim (thank you for Range and the DMS symbols in the formatting) and implemented these instructions verbatim, from here:
https://www.rapidtables.com/convert/number/degrees-to-degrees-minutes-seconds.html

How to convert decimal degrees to degrees,minutes,seconds

One degree (°) is equal to 60 minutes (’) and equal to 3600 seconds ("):

1° = 60’ = 3600"

The integer degrees (d) are equal to the integer part of the decimal degrees (dd):

d = integer(dd)

The minutes (m) are equal to the integer part of the decimal degrees (dd) minus integer degrees (d) times 60:

m = integer((dd - d) Ă— 60)

The seconds (s) are equal to the decimal degrees (dd) minus integer degrees (d) minus minutes (m) divided by 60 times 3600:

s = (dd - d - m/60) Ă— 3600

The result is much better:

DMS_2019Jun21b.gh (21.4 KB)

Didn’t mean to use both floor and fix, but they do the same thing…

One more… DMS_2019Jun21c.gh (20.5 KB)

4 Likes

Thank you kindly Joseph. This helps a lot.