Android 卫星通信计算方位角,仰角,极化角

需求描述: 已知手机的经纬度和高度信息,需要通过公式计算出手机收星的最优方位和仰角,用以调整UI界面显示,以便引导用户实现和当前卫星方位和仰角的对准,达到快速入网的目的。

术语说明

术语 说明
方位角 手机天线在所处位置针对北极的偏转角度,顺时针为正,逆时针为负
仰角 手机天线在所处位置针对地平面的仰角
极化角 天线馈源和电磁波的夹角,方位角和仰角的调节参数
java 复制代码
  /**
     * 计算卫星天线的方位角
     *
     * @param satelliteLongitude 卫星经度
     * @param satelliteLatitude  卫星纬度(或赤纬)
     * @param receiverLongitude  接收地经度
     * @param receiverLatitude   接收地纬度
     * @return 方位角(以弧度为单位)
     */
    public static double calculateAzimuth(double satelliteLongitude, double satelliteLatitude,
                                          double receiverLongitude, double receiverLatitude) {
        // 将角度转换为弧度
        double satLonRad = Math.toRadians(satelliteLongitude);
        double satLatRad = Math.toRadians(satelliteLatitude);
        double recLonRad = Math.toRadians(receiverLongitude);
        double recLatRad = Math.toRadians(receiverLatitude);

        // 计算经度差
        double deltaLambda = satLonRad - recLonRad;

        // 计算方位角
        double azimuthRad = Math.atan2(Math.sin(deltaLambda),
                Math.cos(recLatRad) * Math.tan(satLatRad) - Math.sin(recLatRad) * Math.cos(deltaLambda));

        // 如果需要,将方位角转换为度数
        double azimuthDeg = Math.toDegrees(azimuthRad);

        // 如果需要,将方位角调整到0-360度范围
//        if (azimuthDeg < 0) {
//            azimuthDeg += 360;
//        }

        return azimuthDeg;
    }

    /**
     * 计算卫星仰角
     *
     * @param satLat 卫星纬度(度)
     * @param satLon 卫星经度(度)
     * @param recLat 接收地纬度(度)
     * @param recLon 接收地经度(度)
     * @param satAlt 卫星高度(千米,相对于地球表面)
     * @return 仰角(度)
     */
    public static double calculateElevation(double satLat, double satLon, double recLat, double recLon, double satAlt) {
        // 将角度转换为弧度
        double satLatRad = Math.toRadians(satLat);
        double satLonRad = Math.toRadians(satLon);
        double recLatRad = Math.toRadians(recLat);
        double recLonRad = Math.toRadians(recLon);

        // 地球半径,单位:千米
        double earthRadius = 6371.0;

        // 卫星到地心的距离,单位:千米
        double satelliteToEarthCenter = earthRadius + satAlt;

        // 计算接收地与卫星之间的纬度差和经度差(以弧度为单位)
        double latDiff = satLatRad - recLatRad;
        double lonDiff = satLonRad - recLonRad;

        // 计算仰角(以弧度为单位)
        // 这里使用了一个简化的公式,实际应用中可能需要更复杂的模型
        double elevationRad = Math.asin(Math.sin(latDiff) * Math.cos(satelliteToEarthCenter / earthRadius) +
                Math.cos(recLatRad) * Math.cos(satLatRad) *
                        Math.sin(satelliteToEarthCenter / earthRadius) * Math.cos(lonDiff));

        // 将弧度转换为度数
        double elevationDeg = Math.toDegrees(elevationRad);

//        // 确保仰角在0到90度之间
//        if (elevationDeg < 0) {
//            elevationDeg = 0;
//        } else if (elevationDeg > 90) {
//            elevationDeg = 90;
//        }

        return elevationDeg;
    }

    /**
     * 计算极化角
     *
     * @param azimuth 卫星方位角(度)
     * @param elevation 卫星仰角(度)
     * @return 极化角(度)
     */
    public static double calculatePolarizationAngle(double azimuth, double elevation) {
        // 将角度转换为弧度
        double azimuthRad = Math.toRadians(azimuth);
        double elevationRad = Math.toRadians(elevation);

        // 计算极化角(弧度)
        double polarizationAngleRad = Math.atan2(Math.sin(azimuthRad), Math.tan(elevationRad));

        // 将弧度转换为角度
        double polarizationAngleDeg = Math.toDegrees(polarizationAngleRad);

        // 确保极化角在0到180度之间
//        if (polarizationAngleDeg < 0) {
//            polarizationAngleDeg += 180;
//        } else if (polarizationAngleDeg > 180) {
//            polarizationAngleDeg -= 180;
//        }

        return polarizationAngleDeg;
    }

    /**
     * 将角度转换为弧度
     *
     * @param degrees 角度值
     * @return 弧度值
     */
    public static double toRadians(double degrees) {
        return degrees * Math.PI / 180.0;
    }

    /**
     * 将弧度转换为度数
     *
     * @param radians 弧度值
     * @return 度数值
     */
    public static double toDegrees(double radians) {
        return radians * 180.0 / Math.PI;
    }
相关推荐
residual_fan16 分钟前
持续对比强化学习(Continual Contrastive Reinforcement Learning)论文分享
人工智能·算法·数据挖掘·数据分析
今天要早睡_23 分钟前
C++ 核心语法速过:命名空间、引用、函数重载与 nullptr 深度解析
android·java·c++
s_w.h33 分钟前
【 计网 】序列化与反序列化
linux·服务器·网络·算法·bash
信奥卷王1 小时前
2025年09月GESPC++五级真题解析(含视频)
算法
白狐_7981 小时前
408 数据结构|外部排序:流程与 k 路归并
数据结构·算法
闻缺陷则喜何志丹1 小时前
【动态规划】P3609 [USACO17JAN] Hoof, Paper, Scissor G
c++·算法·动态规划·洛谷
啦啦啦~~~2221 小时前
PC端+安卓端阅读器推荐!开源本地小说阅读器软件,
android·论文阅读·windows·开源软件·福昕阅读器
leihefeng1 小时前
手写数字识别:KNN vs 逻辑回归实战
python·算法·机器学习·逻辑回归·scikit-learn
我命由我123452 小时前
Android Jetpack Compose 开发问题:Unresolved reference ‘Icons‘.
android·java-ee·kotlin·android studio·android jetpack·android-studio·android runtime
爱笑鱼2 小时前
Android 系统启动机制(六):Zygote 创建 App 为什么走 Socket?哪些是源码事实,哪些是架构解释?
android·linux