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;
    }
相关推荐
计算机安禾22 分钟前
【算法分析与设计】第46篇:近似难度与不可近似性理论
网络协议·算法·ssl
小bo波41 分钟前
Java Swing 可视化素数筛:动态演示 1~120 质数筛选【附完整源码】
java·算法·可视化·swing·素数
杉氧1 小时前
100% Kotlin:基于 KMP + Compose Multiplatform 的全栈架构实战(Clean Architecture + MVI)
android·架构
imDwAaY1 小时前
贝叶斯网络到粒子滤波Python算法实现 CS188 Proj4 学习笔记
网络·人工智能·笔记·python·学习·算法
sleven fung1 小时前
Whisper库
开发语言·人工智能·python·算法·ai·whisper
小仙女喂得猪1 小时前
AI 写 Android 代码老翻车?我把移动端的 Harness 系统开源了
android·github·ai编程
Black蜡笔小新1 小时前
自动化AI算法训练服务器DLTM零代码私有化一站式AI训练平台技术解析
人工智能·算法·自动化
杉氧1 小时前
第一篇:从一个 Dagger 报错开始:手把手带你搭建 Hilt 依赖注入的护城河
android·架构
咋吃都不胖lyh1 小时前
短期记忆和长期记忆都存 MySQL
android·java·开发语言
Mumu12181 小时前
P3212 [HNOI2011] 任务调度
算法