惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

有赞技术团队
有赞技术团队
H
Hackread – Cybersecurity News, Data Breaches, AI and More
I
InfoQ
J
Java Code Geeks
Microsoft Security Blog
Microsoft Security Blog
G
Google Developers Blog
D
DataBreaches.Net
Recent Announcements
Recent Announcements
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
Y
Y Combinator Blog
博客园 - 【当耐特】
博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
P
Proofpoint News Feed
量子位
C
Check Point Blog
F
Fortinet All Blogs
罗磊的独立博客
Last Week in AI
Last Week in AI
GbyAI
GbyAI
L
LangChain Blog
博客园 - 司徒正美

博客园 - Angry_Panda

军事防务 —— 城市反无 —— 无线电侦测设备需要进行攻击目标分配吗?无线电侦测设备的调度在应用中是需要在部署时进行考虑还是在攻击时进行考虑 从一张AI合成的无人机救援图说起 —— 多人机协作的可行性 985大学不相信眼泪,信奉丛林法则;211大学更讲人情味 军事防务 —— 反无激光武器攻后的冷却和充能时间与其攻击的持续时长是否有关系 军事防务 —— 北京顺义李桥镇 (AI大模型生成答案)—— 反无激光武器攻后的冷却和充能时间与其攻击的持续时长是否有关系 军事防务:激光武器的参数 武器装备参数介绍 军事防务:城市反无 —— 无线电干扰设备的攻击范围 百家讲坛 —— 再度翻红 —— 长大后才发现最好的教育早已播下种子,只等阅历浇灌才真正发芽 军事防务 —— AFSim雷达传感器仿真技术 防务 —— 军事建模AFSIM —— 电磁波 为什么倒卖 军火最赚钱 —— 从防务公司的业务发展来看待军费问题 防务:防务业务 —— 武器开火后的返回结果 —— 武器结果:0=开火, 1=命中, 2=未命中 豆包AI回答 —— 为什么城市反无场景下无线电干扰设备即使击中目标也会一直攻击呢 防务:雷达和光电探测设备 —— 无人机的轨迹信息与真实位置信息的差异性,是根据随机函数来实现的吗,比如在真实位置上加一点的随机扰动吗 —— AFsim的手册 北京市顺义区李桥镇 —— 中科星图公司 —— 出行路线交通 —— “东方通勤车”(误区,“东方通勤车”的站点根本就找不到,如果不坐地铁,那么就坐850号公交) 北京市顺义区李桥镇(首都机场附件)—— 中科星图(星图防务) 公司宿舍 【转载】cessium python部署离线版本 ———— 如何使用Python操作三维地图 cessium —— cessium python部署离线版本 如何使用uv安装pytorch 基于GA-BP神经网络的防空导弹实时目标分配方法 【人生哲理】【视频】为什么说该花的钱不花,就会变成灾难呢? 随身移动WiFi ——50元级别的(三网 4G移动网络)—— 网速测试 豆包AI —— 为什么不把离散的状态空间属性用one-shot方式编码而是直接归一化为0到1范围的属性值 dogfight问题中(UAV 无人机空战——狗斗)—— 状态空间设计 为ubuntu系统安装samba网络磁盘,实现局域网中的共享网络磁盘 —— 跨系统文件共享的完整方案 sudo fwupdmgr get-upgrades —— 在 Linux 系统中,用 fwupd 工具查看当前机器所有可升级固件(BIOS/UEFI、SSD、雷电、外设等) git免密认证同步仓库代码报错——git@github.com: Permission denied (publickey) —— 所需的ssh-add加载加密私钥 —— 指定加密私钥存储位置 【转载】 执行 ssh-add 报错 Could not open a connection to your authentication agent —— git免密认证同步仓库代码,所需的ssh-add加载加密私钥 uv python环境管理工具 ubuntu系统python安装pycairo报错:Run-time dependency python found: NO (tried pkgconfig and sysconfig)
无人机 —— dogfight —— 经纬度与笛卡尔坐标系的相互转换、方...
Angry_Panda · 2026-06-25 · via 博客园 - Angry_Panda

给出代码:

import math

def latlon_to_xy(lat, lon, lat0, lon0, radius=6371000.0):
    """
    将经纬度坐标转换为局部平面笛卡尔坐标 (ENU 东北天坐标系)
    
    参数:
        lat, lon: 目标点的纬度、经度 (度)
        lat0, lon0: 原点经纬度 (度)
        radius: 地球半径,默认 6371000 米
    
    返回:
        x: 东方向 (East)  坐标,米
        y: 北方向 (North) 坐标,米
    """
    # 角度转弧度
    lat_rad = math.radians(lat)
    lon_rad = math.radians(lon)
    lat0_rad = math.radians(lat0)
    lon0_rad = math.radians(lon0)

    dlat = lat_rad - lat0_rad
    dlon = lon_rad - lon0_rad

    # 局部平面近似(小范围非常准)
    x = radius * dlon * math.cos(lat0_rad)   # 东
    y = radius * dlat                        # 北

    return x, y

# 原点(比如你的起飞点/仿真原点)
lat0 = 39.9139
lon0 = 116.3588

# 目标点经纬度
lat = 39.9145
lon = 116.3593

# 转换为平面坐标 (x东, y北)
# 目标点:(lat, lon)           原点:(lat0, lon0)
# 以(lat0, lon0)为原点,给出目标点(lat, lon)转换为笛卡尔坐标系下的坐标
x, y = latlon_to_xy(lat, lon, lat0, lon0)

print(f"经纬度({lat}, {lon})转换后的平面坐标 x={x:.2f} m, y={y:.2f} m")




import math

def xy_to_latlon(x, y, lat0, lon0, earth_radius=6371000.0):
    """
    局部平面坐标 (相对笛卡尔坐标) (东北天坐标系 ENU) 转回经纬度
    
    参数:
        x: 东向距离(米)
        y: 北向距离(米)
        lat0, lon0: 原点经纬度(度)
    返回:
        lat, lon: 目标点经纬度(度)
    """
    lat0_rad = math.radians(lat0)
    lon0_rad = math.radians(lon0)

    # 纬度变化 = 北向距离 / 地球半径
    dlat = y / earth_radius
    lat_rad = lat0_rad + dlat

    # 经度变化 = 东向距离 / (地球半径 * cos(纬度))
    dlon = x / (earth_radius * math.cos(lat0_rad))
    lon_rad = lon0_rad + dlon

    lat = math.degrees(lat_rad)
    lon = math.degrees(lon_rad)

    return lat, lon


lat, lon = xy_to_latlon(x, y, lat0, lon0)

print(f"平面坐标 x={x:.2f} m, y={y:.2f} m 转换后的经纬度({lat}, {lon})")



def calculate_bearing(lat1, lon1, lat2, lon2):
    """
    计算(lat1,lon1)到(lat2,lon2)的方位角并归一化到[-180,180)

    参数:
        lat1,lon1: 点1的经纬度
        lat2,lon2: 点2的经纬度
    返回:
        点1到点2的方位角,0表示点2在点1正北方,90正东,-90正西,-180正南

    
    输入:起点经纬度、目标点经纬度(度)
    输出:从起点指向目标的方位角,单位度
    0° = 正北
    90° = 正东
    -90° = 正西
    180° /-180° = 正南
    范围严格:[-180, 180),非常适合做强化学习的角度差奖励
    """
    # 转弧度
    lat1 = math.radians(lat1)
    lon1 = math.radians(lon1)
    lat2 = math.radians(lat2)
    lon2 = math.radians(lon2)

    delta_lon = lon2 - lon1

    x = math.sin(delta_lon) * math.cos(lat2)
    y = (math.cos(lat1) * math.sin(lat2) -
            math.sin(lat1) * math.cos(lat2) * math.cos(delta_lon))

    bearing = math.degrees(math.atan2(x, y))
    bearing = (bearing + 180) % 360 - 180
    return bearing


import math

def bearing_from_latlon(lat1, lon1, lat2, lon2):
    """
    计算从点1 (lat1, lon1) 指向 点2 (lat2, lon2) 的方位角(真北顺时针)
    返回角度已归一化到 [-180, 180) 度

    输入:起点经纬度、目标点经纬度(度)
    输出:从起点指向目标的方位角,单位度
    0° = 正北
    90° = 正东
    -90° = 正西
    180° /-180° = 正南
    范围严格:[-180, 180),非常适合做强化学习的角度差奖励
    """
    lat1 = math.radians(lat1)
    lon1 = math.radians(lon1)
    lat2 = math.radians(lat2)
    lon2 = math.radians(lon2)

    dlon = lon2 - lon1

    # 方位角公式
    y = math.sin(dlon) * math.cos(lat2)
    x = math.cos(lat1) * math.sin(lat2) - math.sin(lat1) * math.cos(lat2) * math.cos(dlon)
    theta = math.atan2(y, x)

    # 弧度转度,并转到 [0, 360)
    bearing = math.degrees(theta)
    bearing = bearing % 360.0

    # 归一化到 [-180, 180)
    if bearing > 180.0:
        bearing -= 360.0

    return bearing

# 起点
lat1, lon1 = 30.0, 120.0
# 终点
lat2, lon2 = 30.001, 120.001

angle = calculate_bearing(lat1, lon1, lat2, lon2)
print(f"方位角: {angle:.2f} °")

angle = bearing_from_latlon(lat1, lon1, lat2, lon2)
print(f"方位角: {angle:.2f} °")

image

经纬度(39.9145, 116.3593)转换后的平面坐标 x=42.64 m, y=66.72 m
平面坐标 x=42.64 m, y=66.72 m 转换后的经纬度(39.9145, 116.35929999999999)
方位角: 40.89 °
方位角: 40.89 °

本博客是博主个人学习时的一些记录,不保证是为原创,个别文章加入了转载的源地址,还有个别文章是汇总网上多份资料所成,在这之中也必有疏漏未加标注处,如有侵权请与博主联系。 如果未特殊标注则为原创,遵循 CC 4.0 BY-SA 版权协议。