⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 equitorialposition.java

📁 GPS Track connects to a GPS and records the path that you travel. Tracks can be uploaded to a web s
💻 JAVA
字号:
// J2ME Compass
// Copyright (C) 2006 Dana Peters
// http://www.qcontinuum.org/compass

package org.qcontinuum.astro;

import henson.midp.Float;

public class EquitorialPosition {
    
    private Float mRightAscension;
    private Float mDeclination;

    public EquitorialPosition(Float ra, Float dec) {
        mRightAscension = ra;
        mDeclination = dec;
    }
    
    public Float getRightAscension() {
        return mRightAscension;
    }
    
    public Float getDeclination() {
        return mDeclination;
    }

    public HorizontalPosition toHorizontalPosition(EarthPosition earth, Float mjd) {
        Float gmst = UtcDate.GMST(mjd);
        Float lat = Float.toRadians(earth.getLatitude());
        Float lon = Float.toRadians(earth.getLongitude());
	// tau = gmst + lon - RA;
        Float tau = gmst.Add(lon).Sub(mRightAscension);
        // x = cos(tau) * cos(Dec);
        Float x = Float.cos(tau).Mul(Float.cos(mDeclination));
        // y = sin(tau) * cos(Dec);
        Float y = Float.sin(tau).Mul(Float.cos(mDeclination));
        // z = sin(Dec);
        Float z = Float.sin(mDeclination);
        // rotate so z is the local zenith
        // xhor = x * sin(lat) - z * cos(lat);
        Float xhor = x.Mul(Float.sin(lat)).Sub(z.Mul(Float.cos(lat)));
        Float yhor = y;
        // zhor = x * cos(lat) + z * sin(lat);
        Float zhor = x.Mul(Float.cos(lat)).Add(z.Mul(Float.sin(lat)));
        HorizontalPosition skyPosition = new HorizontalPosition(0, 0);
        Float Az, h;
        // Az = atan2(yhor, xhor);
        Az = Float.atan2(yhor, xhor);
        Az = (Az.Great(Float.PI)) ? Az.Sub(Float.PI) : Az.Add(Float.PI); // so 0 degrees is north
        // h = atan2(zhor, sqrt(xhor * xhor + yhor * yhor));
        h = Float.atan2(zhor, Float.sqrt(xhor.Mul(xhor).Add(yhor.Mul(yhor))));
        return new HorizontalPosition(Float.toDegrees(Az), Float.toDegrees(h));
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -