I downloaded the script from the ML and tried it out.
Now I am assuming that it works like you are standing on earth at the beginning of the script, correct?
So if I do the "enter-star name-enter-c" I should get it's RA, which i think is right. I typed in GAM Hya then "c" to center it
and it gave me a RA of 13h 18m 55.2s, looked it up on wikipedia and it said 13h 18m 55.3s, so I assume the script is right.
But the script gives a DEC of -23.17, where as wikipedia gives -23h 10m 18s.
So how do convert that -23.17 that the script gives to what Wikipedia gives?
Thanks,
Tim
Using the Azimuth Elevation script
Forum rules
Please help to make this forum more useful by checking the FAQs before posting! Keep it clean, keep it civil, keep it truthful, stay on topic, be responsible, share your knowledge.
Please help to make this forum more useful by checking the FAQs before posting! Keep it clean, keep it civil, keep it truthful, stay on topic, be responsible, share your knowledge.
-
- Developer
- Posts: 1356
- Joined: 07.01.2005
- With us: 19 years 10 months
- Location: Nancy, France
Re: Using the Azimuth Elevation script
You need a function to converts the hour decimal value to hour, min, sec:
Code: Select all
hourToHourMinSec = function(hour)
local a = math.abs(hour);
local h = math.floor(a);
local r = (a - h) * 60;
local m = math.floor(r);
local s = (r - m) * 60;
return string.format("%0.0fh %02.0fm %2.0fs", h, m, s);
end
value_hms = hourToHourMinSec(value_hour)
Last edited by Vincent on 05.04.2010, 09:24, edited 2 times in total.
@+
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
-
Topic authorfungun
- Posts: 315
- Joined: 30.07.2007
- Age: 63
- With us: 17 years 4 months
- Location: Iowa, USA
Re: Using the Azimuth Elevation script
Thanks you, but what do I do with this function? or where do I put it?
Tim
Tim
-
- Developer
- Posts: 1356
- Joined: 07.01.2005
- With us: 19 years 10 months
- Location: Nancy, France
Re: Using the Azimuth Elevation script
You can paste the hourToHourMinSec() function just below the deg2hms() function.
Then, change the following line (at the end of the script):
into:
That should do it.
Then, change the following line (at the end of the script):
Code: Select all
local radec_string = string.format("RA: %2ih %2im %2.1fs Dec: %3.2f°", h, m, s, dec)
into:
Code: Select all
local radec_string = string.format("RA: %2ih %2im %2.1fs Dec: %s", h, m, s, hourToHourMinSec(dec))
That should do it.
@+
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
-
Topic authorfungun
- Posts: 315
- Joined: 30.07.2007
- Age: 63
- With us: 17 years 4 months
- Location: Iowa, USA
Re: Using the Azimuth Elevation script
Well I must have messed it up
Get this error now (see pic)
Also attached the script with the changes I made that you gave me.
Thank you for your help,
Tim
Get this error now (see pic)
Also attached the script with the changes I made that you gave me.
Thank you for your help,
Tim
-
- Posts: 105
- Joined: 04.03.2010
- With us: 14 years 8 months
Re: Using the Azimuth Elevation script
Hi Tim,
I have seen pics of many of your Star Trek add-ons, and they are awesome. I hope to see many more to come.
Regarding the Declination issue, here are a few notes for Vincent that may help.
Hi Vincent,
1) Since it's a Declination we're talking about, it should be given in ?, arc-minutes and arc-seconds, rather than in hours, minutes and seconds. I found this Wikipedia link to confiirm that they expressed it correctly. http://en.wikipedia.org/wiki/Gamma_Hydrae If it's expressed differently in another link, it's probably a mis-type.
2) Shouldn't you use math.abs() first when a Declination is negative? Lua's math.floor() function returns the integer "less than" a value given, so—since this Declination (-23.17) is negative—it runs into problems because math.floor( -23.17 ) should return -24. I always "save" the negative sign as a boolean, then use math.abs( ) before the conversion, then add the sign back to the degrees.
Here's my function that converts Decimal Degrees to Degrees, ArcMinutes and Arc-Seconds. The logic is essentially the same as in your code, except for the missing math.abs( ) function.
Hope it helps.
--Gary
I have seen pics of many of your Star Trek add-ons, and they are awesome. I hope to see many more to come.
Regarding the Declination issue, here are a few notes for Vincent that may help.
Hi Vincent,
1) Since it's a Declination we're talking about, it should be given in ?, arc-minutes and arc-seconds, rather than in hours, minutes and seconds. I found this Wikipedia link to confiirm that they expressed it correctly. http://en.wikipedia.org/wiki/Gamma_Hydrae If it's expressed differently in another link, it's probably a mis-type.
2) Shouldn't you use math.abs() first when a Declination is negative? Lua's math.floor() function returns the integer "less than" a value given, so—since this Declination (-23.17) is negative—it runs into problems because math.floor( -23.17 ) should return -24. I always "save" the negative sign as a boolean, then use math.abs( ) before the conversion, then add the sign back to the degrees.
Here's my function that converts Decimal Degrees to Degrees, ArcMinutes and Arc-Seconds. The logic is essentially the same as in your code, except for the missing math.abs( ) function.
Code: Select all
function DecimalDegreesToDMS ( DecimalDegrees )
local Deg, DecimalMin, Min, Sec
local DegreesNegative
if DecimalDegrees < 0 then
DegreesNegative = true
else
DegreesNegative = false
end
Deg = math.floor (math.abs ( DecimalDegrees ) )
DecimalMin = math.abs ( DecimalDegrees ) - Deg
Min = math.floor ( ( DecimalMin ) * 60 )
Sec = ( ( DecimalMin * 60 ) - Min ) * 60
if DegreesNegative then Deg = -Deg end
return Deg, Min, Sec
end -- of DecimalDegreesToDMS ( )
Hope it helps.
--Gary
1.6.1, Dell Studio XPS, AMD 2.7 GHz, 8 GB RAM, Win 7 64-bit, ATI Radeon HD 5670
1.6.0, Dell Inspiron 1720, Intel Core Duo 2 Ghz, 3 GB RAM, Win Vista, NVIDIA GeForce 8600M G/GT
1.4.1, Dell Dimension 4700, Pent-4 2.8 GHz, 512 MB RAM, Win XP SP2, Radeon X300
1.6.0, Dell Inspiron 1720, Intel Core Duo 2 Ghz, 3 GB RAM, Win Vista, NVIDIA GeForce 8600M G/GT
1.4.1, Dell Dimension 4700, Pent-4 2.8 GHz, 512 MB RAM, Win XP SP2, Radeon X300
-
Topic authorfungun
- Posts: 315
- Joined: 30.07.2007
- Age: 63
- With us: 17 years 4 months
- Location: Iowa, USA
Re: Using the Azimuth Elevation script
Thank you
Now just to make sure I get this right .
I take this code-
And put in place of this code-
Thank you for help guys,
Tim
Now just to make sure I get this right .
I take this code-
Code: Select all
function DecimalDegreesToDMS ( DecimalDegrees )
local Deg, DecimalMin, Min, Sec
local DegreesNegative
if DecimalDegrees < 0 then
DegreesNegative = true
else
DegreesNegative = false
end
Deg = math.floor (math.abs ( DecimalDegrees ) )
DecimalMin = math.abs ( DecimalDegrees ) - Deg
Min = math.floor ( ( DecimalMin ) * 60 )
Sec = ( ( DecimalMin * 60 ) - Min ) * 60
if DegreesNegative then Deg = -Deg end
return Deg, Min, Sec
end -- of DecimalDegreesToDMS ( )
And put in place of this code-
Code: Select all
function deg2hms(deg)
deg_p_hour = 360/24
deg_p_minute = 360 / (24*60)
deg_p_second = 360 / (24*60*60)
hours = math.floor(deg / deg_p_hour)
deg = deg - deg_p_hour * hours
minutes = math.floor(deg / deg_p_minute )
deg = deg - deg_p_minute * minutes
seconds = deg / deg_p_second
return hours, minutes, math.floor(10*seconds)/10
end
hourToHourMinSec = function(hour)
local h = math.floor(hour);
local r = (hour - h) * 60;
local m = math.floor(r);
local s = (r - m) * 60;
return string.format("%0.0fh %02.0fm %2.0fs", h, m, s);
end
value_hms = hourToHourMinSec(value_hour)
Thank you for help guys,
Tim
-
- Developer
- Posts: 1356
- Joined: 07.01.2005
- With us: 19 years 10 months
- Location: Nancy, France
Re: Using the Azimuth Elevation script
You need to remove the following line from your code:fungun wrote:Well I must have messed it up
Get this error now (see pic)
Code: Select all
value_hms = hourToHourMinSec(value_hour)
Yes, sure. Tim should actually do the maths to convert the hour, min, sec wikipedia values into deg, arc-min, arc-sec.VikingTechJPL wrote:1) Since it's a Declination we're talking about, it should be given in ?, arc-minutes and arc-seconds, rather than in hours, minutes and seconds.
I provided the hourToHourMinSec() function because he was asking for it, though.
Right! I took the code from the degTohms function and removed math.abs(deg / 15).VikingTechJPL wrote:2) Shouldn't you use math.abs() first when a Declination is negative? Lua's math.floor() function returns the integer "less than" a value given, so—since this Declination (-23.17) is negative—it runs into problems because math.floor( -23.17 ) should return -24. I always "save" the negative sign as a boolean, then use math.abs( ) before the conversion, then add the sign back to the degrees.
Then, I just forgot to add back math.abs(). Thanks! This is fixed now.
@+
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
-
Topic authorfungun
- Posts: 315
- Joined: 30.07.2007
- Age: 63
- With us: 17 years 4 months
- Location: Iowa, USA
Re: Using the Azimuth Elevation script
Vincent, thank you.
It works perfect now
Tim
It works perfect now
Tim