Right ascension, declination, and distance in celestia?

Have a question about using Celestia? Check here first for FAQs and helpful advice.
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.
Topic author
Verz Veraldi
Posts: 55
Joined: 16.09.2010
With us: 14 years 2 months
Location: In front of my computer

Right ascension, declination, and distance in celestia?

Post #1by Verz Veraldi » 18.09.2010, 08:14

I'm just wondering, how to convert common RA like 05h35m10s and Dec like -05 : 20 : 37 to decimals in the .dsc files? And, is the radius and distance is light years? Is there any program or even math formulas to convert it?

Code: Select all

Nebula "Nebula"
{
    Mesh "Nebula.*"
    Radius               <--- Light years?
    RA                     <--- Common to decimals?
    Dec                    <--- Common to decimals?
    Distance             <--- Light years?
}
Finally figured out how to add signature...
Core 2 Duo E7500 2.93 GHz, 4GB RAM, Nvidia GeForce 9600GT 1GB DDR3 Mem, Windows 7 32bit...

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Re: Right ascension, declination, and distance in celestia?

Post #2by selden » 18.09.2010, 12:44

Verz,

The definitions of the STC fields are in the WikiBook at http://en.wikibooks.org/wiki/Celestia/STC_File
and DSC fields are defined at http://en.wikibooks.org/wiki/Celestia/DSC_File
But, yes, Distance and Radius are measured in LightYears.

There are 60 seconds in a minute, and 60 minutes in a degree or hour.
So to convert to fractional units, divide the number of minutes by 60 and the number of seconds by 3600 (which is 60x60).
So an RA of 05h35m10s = 5 + 35/60 + 10/3600 = 5 + 0.583333 + 0.002778 = 5.586111 hours
and a Declination (in degrees) of -05 : 20 : 37 = - ( 5 + 20/60 + 37/3600) = - ( 5 + 0.333333 + 0.010278) = -5.343361 degrees

Unfortunately, while DSC files want RA in hours, in STC files you need to provide RA in degrees. To convert hours to degrees, multiply by 15: 5.586111 hours = 83.791665 degrees
Selden

Reiko
Posts: 1119
Joined: 05.10.2006
Age: 41
With us: 18 years 1 month
Location: Out there...

Re: Right ascension, declination, and distance in celestia?

Post #3by Reiko » 18.09.2010, 18:40

Use these scripts in Celestia. It will convert and display them for you.

STC

Code: Select all

-- Title: Display current decimal for observer

    KM_PER_LY = 9460730472580.8;
    KM_PER_AU = 149597870.7;
    PI = math.pi
    degToRad = PI / 180;
    J2000Obliquity = 23.4392911 * degToRad

    LOOK  = celestia:newvector(0, 0, -1);
    earth = celestia:find("Sol/Earth")

    -- Convert coordinates from cartesian to polar:
    xyz2rtp = function (x, y, z)
        local r = math.sqrt(x*x + y*y + z*z)
        local phi = math.atan2(y, x)
        local theta = math.atan2(math.sqrt(x * x + y * y), z)

        return r, theta, phi
    end

    -- Return current distance of observer from Earth:
    getR = function (obs)
        local d = (earth:getposition():distanceto(obs:getposition()))
        return d
    end

    -- Return current RA, Dec for observer:
    getRADec = function (obs)
        local base_rot = celestia:newrotation(celestia:newvector(1, 0, 0), -J2000Obliquity)
        local rot = earth:getposition():orientationto(obs:getposition(), LOOK) * base_rot
        local look = rot:transform(LOOK):normalize()
        local r, theta, phi = xyz2rtp(look.x, look.z, look.y)
        local phi = math.mod(720 - math.deg(phi), 360)
        local theta = math.deg(theta)
        if theta > 0 then
            theta = 90 - theta
        else
            theta = (-90 - theta)
        end
        return phi, theta
    end

    km2Unit =
        function(km)
            local sign, value, units
            --if not (type(km) == "number") then return km end;
            if km < 0 then sign = -1 else sign = 1 end;
            km = math.abs(km);
            value = km / KM_PER_LY
            units = "ly";
            return string.format("%.5f",sign*value).." "..units;
        end


    deg2str =    function(deg)
        return string.format("%0.6f deg", deg);
    end

    while true do
        obs = celestia:getobserver()
        obsR = getR(obs)
        obsRA, obsDec = getRADec(obs)
        celestia:print(obsR..' '..obsRA..' '..obsDec)
        if obsR >= 0 then
            -- Display geocentric coordinates for observer:
            obsRStr = km2Unit(obsR);
            obsRAStr = deg2str(obsRA);
            obsDecStr = deg2str(obsDec);
            celestia:print("Geocentric coordinates for observer:\nR: "..obsRStr.."\nRA: "..obsRAStr.."\nDec: "..obsDecStr, 1, -1, -1, 1, 7);
        end
        wait(0)
    end


For DSC

Code: Select all

-- Title: Display current position for observer nebulas

    KM_PER_LY = 9460730472580.8;
    KM_PER_AU = 149597870.7;
    PI = math.pi
    degToRad = PI / 180;
    J2000Obliquity = 23.4392911 * degToRad

    LOOK  = celestia:newvector(0, 0, -1);
    earth = celestia:find("Sol/Earth")

    -- Convert coordinates from cartesian to polar:
    xyz2rtp = function (x, y, z)
        local r = math.sqrt(x*x + y*y + z*z)
        local phi = math.atan2(y, x)
        local theta = math.atan2(math.sqrt(x * x + y * y), z)

        return r, theta, phi
    end

    -- Return current distance of observer from Earth:
    getR = function (obs)
        local d = (earth:getposition():distanceto(obs:getposition()))
        return d
    end

    -- Return current RA, Dec for observer:
    getRADec = function (obs)
        local base_rot = celestia:newrotation(celestia:newvector(1, 0, 0), -J2000Obliquity)
        local rot = earth:getposition():orientationto(obs:getposition(), LOOK) * base_rot
        local look = rot:transform(LOOK):normalize()
        local r, theta, phi = xyz2rtp(look.x, look.z, look.y)
        local phi = math.mod(720 - math.deg(phi), 360)
        local theta = math.deg(theta)
        if theta > 0 then
            theta = 90 - theta
        else
            theta = (-90 - theta)
        end
        return phi, theta
    end

    km2Unit =
        function(km)
            local sign, value, units
            --if not (type(km) == "number") then return km end;
            if km < 0 then sign = -1 else sign = 1 end;
            km = math.abs(km);
            value = km / KM_PER_LY
            units = "ly";
            return string.format("%.5f",sign*value).." "..units;
        end


    deg2str =    function(deg)
        return string.format("%0.6f deg", deg);
    end

    while true do
        obs = celestia:getobserver()
        obsR = getR(obs)
        obsRA, obsDec = getRADec(obs)
        celestia:print(obsR..' '..obsRA..' '..obsDec)
        if obsR >= 0 then
            -- Display geocentric coordinates for observer:
            obsRStr = km2Unit(obsR);
            obsRAStr = deg2str(obsRA / 15);
            obsDecStr = deg2str(obsDec);
            celestia:print("Geocentric coordinates for observer:\nR: "..obsRStr.."\nRA: "..obsRAStr.."\nDec: "..obsDecStr, 1, -1, -1, 1, 7);
        end
        wait(0)
    end


viewtopic.php?f=15&t=16119

Topic author
Verz Veraldi
Posts: 55
Joined: 16.09.2010
With us: 14 years 2 months
Location: In front of my computer

Re: Right ascension, declination, and distance in celestia?

Post #4by Verz Veraldi » 19.09.2010, 04:34

Selden,
thanks alot! I could use that for measuring..

Reiko,
You mean if i open those script in celestia, when i go to a star or something i can see the location in the info text in the upper left?
Finally figured out how to add signature...
Core 2 Duo E7500 2.93 GHz, 4GB RAM, Nvidia GeForce 9600GT 1GB DDR3 Mem, Windows 7 32bit...

Topic author
Verz Veraldi
Posts: 55
Joined: 16.09.2010
With us: 14 years 2 months
Location: In front of my computer

Re: Right ascension, declination, and distance in celestia?

Post #5by Verz Veraldi » 19.09.2010, 04:44

Verz Veraldi wrote:Reiko,
You mean if i open those script in celestia, when i go to a star or something i can see the location in the info text in the upper left?

oh, i've test that script, it works! thanks alot!
Finally figured out how to add signature...
Core 2 Duo E7500 2.93 GHz, 4GB RAM, Nvidia GeForce 9600GT 1GB DDR3 Mem, Windows 7 32bit...


Return to “Help Central”