|
Post by angelo2449 on Oct 29, 2018 2:05:56 GMT -5
Hi guys,
someone knows where to find the code for the conversion of decimal angles into sexagesimal. Thank You
|
|
|
Post by tenochtitlanuk on Oct 29, 2018 4:52:13 GMT -5
Google says... How do you convert decimals to Sexagesimal? Here's How: The whole units of degrees will remain the same (i.e. in 121.135° longitude, start with 121°). Multiply the decimal by 60 (i.e. .135 * 60 = 8.1). The whole number becomes the minutes (8'). Take the remaining decimal and multiply by 60. ... The resulting number becomes the seconds (6").
You'll find int() helpful to code this..
|
|
|
Post by Brandon Parker on Oct 29, 2018 10:54:13 GMT -5
Indeed Int() is super helpful with this one .....
Let us know if you get stuck or need assistance. I have something coded for this already, but try it on your own first and see where you get to.
{:0)
Brandon R. Parker
|
|
|
Post by steve999 on Jun 6, 2019 19:55:12 GMT -5
I have been trying to find code to change decimal degrees to DMS. So far, nothing works for negative degrees, especially, for example -0.25 Can anyone help???
|
|
|
Post by metro on Jun 7, 2019 1:53:22 GMT -5
I have been trying to find code to change decimal degrees to DMS. So far, nothing works for negative degrees, especially, for example -0.25 Can anyone help??? I believe what John has posted will help also stated here
|
|
|
Post by tsh73 on Jun 7, 2019 3:36:04 GMT -5
nothing works for negative degrees, Post your example - code and number what doesn't work.
|
|
|
Post by steve999 on Jun 7, 2019 14:13:35 GMT -5
mainwin 40 30
print "input dec degree"
[qqq]
print "===================="
input num
if num=0 then [quit]
print "method 1"
deg=int(num)
xx=abs(num-deg)
yy=xx*60
min=int(yy)
sec=(yy-min)*60
print using ("######",deg);":";
print using ("###",min);":";
print using ("###.##",sec)
print "---------------------------"
print "method 2"
Q=num*3600
deg=int(Q/3600)
min=int((Q-deg*3600)/60)
sec=int(Q-deg*3600-min*60)
print using ("######",deg);":";
print using ("###",min);":";
print using ("###.##",sec)
print "--------------------------"
print "method 3"
deg=int (num)
min=int((num-deg)*60)
sec=(((num-deg)*60)-min)
print using ("######",deg);":";
print using ("###",min);":";
print using ("###.##",sec)
goto [qqq]
[quit]
print
print "FINISHED"
end
THIS IS A SAMPLE RUN. NOTICE THAT -.258 IS NOT CORRECT.
input dec degree
====================
?258.258
method 1
258: 15: 28.80
---------------------------
method 2
258: 15: 28.00
--------------------------
method 3
258: 15: 0.48
====================
?-258.258
method 1
-258: 15: 28.80
---------------------------
method 2
-258:-15:-28.00
--------------------------
method 3
-258:-15: -0.48
====================
?-.258
method 1
0: 15: 28.80
---------------------------
method 2
0:-15:-28.00
--------------------------
method 3
0:-15: -0.48
====================
?0
FINISHED
|
|
|
Post by tsh73 on Jun 7, 2019 16:47:22 GMT -5
So your method 3 has last number - seconds - waiting to be multiplied by 60 After that it'll show seconds number as method 1.
But you have problems with negative small numbers (actually because "-0" prints as 0)
You can save sign - work on positive numbers (with any method really) - then append sign. Something like this (have to drop first USING so '-' get close to DEG number)
'mainwin 40 30 'do you know it stores mainwin settings so later programs will work 40x30? print "input dec degree" [qqq] print "====================" input num if num=0 then [quit] if num <0 then sgn$="-": num =abs(num) print "method 1" deg=int(num) xx=abs(num-deg) yy=xx*60 min=int(yy) sec=(yy-min)*60 print sgn$; print deg;":"; 'print using ("######",deg);":"; sign too far with using print using ("###",min);":"; print using ("###.##",sec) print "---------------------------" goto [qqq] [quit] print print "FINISHED" end
input dec degree ==================== ?258.258 method 1 258: 15: 28.80 --------------------------- ==================== ?-258.258 method 1 -258: 15: 28.80 --------------------------- ==================== ?-0.258 method 1 -0: 15: 28.80 --------------------------- ==================== ?
FINISHED
|
|
|
Post by tenochtitlanuk on Jun 7, 2019 16:49:00 GMT -5
Try www.rapidtables.com/convert/number/degrees-to-degrees-minutes-seconds.html to check your working- and results. ' change decimal degrees eg 150.456 to Degrees/Minutes/Seconds 150° 27' 21.6" ' d = int( 150.456°) = 150° ' m = int( ( 150.456° - 150°) × 60) = 27' ' s = ( 150.456° - 150° - 27' /60) × 3600 = 21.6" ' Thus 150.456° = 150° 27' 21.6" 'SIMILARY 258.258 is 258° 15' 28.8" ' -258.258 is -258° 15' 28.8" ' and -0.258 is 0° 15' 28.8" EDIT And yes, as Anatoly says, formatted printing of '-0.nn' is problematic..
|
|
|
Post by metro on Jun 7, 2019 19:08:41 GMT -5
am I correct that the use of abs() will negate the negative?
|
|
|
Post by tsh73 on Jun 10, 2019 3:59:21 GMT -5
yes
|
|
|
Post by metro on Jun 10, 2019 5:25:03 GMT -5
Thanks Anatoly, хорошо быть правым время от времени
|
|