Coder Social home page Coder Social logo

tmp's Introduction

tmp

import numpy as np

def los_to_earth(latitude, longitude, altitude, roll, pitch, yaw): # 座標をラジアンに変換 latitude = np.radians(latitude) longitude = np.radians(longitude) pitch = np.radians(pitch) yaw = np.radians(yaw)

# 地球楕円体のパラメータ
a = 6378137.0  # 赤道半径
c = 6356752.314245  # 極半径

# 位置ベクトルの計算
x = (a + altitude) * np.cos(latitude) * np.cos(longitude)
y = (a + altitude) * np.cos(latitude) * np.sin(longitude)
z = (c + altitude) * np.sin(latitude)

# 指向ベクトルの計算
u = np.cos(pitch) * np.sin(yaw)
v = np.cos(pitch) * np.cos(yaw)
w = -np.sin(pitch)

# 二次方程式の係数
value = -a**2*c**2*w*z - a**2*c**2*v*y - a**2*c**2*u*x
radical = a**2*c**2*(u**2 + v**2 + w**2) - (c**2*(u*x + v*y)**2 + a**2*(w*z)**2)
magnitude = a**2*c**2*(u**2 + v**2 + w**2)

if radical < 0:
    raise ValueError("The Line-of-Sight vector does not intersect with the Earth")

d = (value - np.sqrt(radical)) / magnitude
intersection_point = np.array([x + d * u, y + d * v, z + d * w])

# 交点の緯度、経度、高度を計算
lat = np.arctan2(intersection_point[2], np.sqrt(intersection_point[0]**2 + intersection_point[1]**2))
lon = np.arctan2(intersection_point[1], intersection_point[0])
h = np.sqrt(intersection_point[0]**2 + intersection_point[1]**2 + intersection_point[2]**2) - a

# 交点までの距離
distance = np.linalg.norm(intersection_point - np.array([x, y, z]))

return {
    'distance': distance,
    'latitude': np.degrees(lat),
    'longitude': np.degrees(lon),
    'altitude': h
}

使用例

result = los_to_earth(35.0, 139.0, 400000, 0, -45, 90) print(result)

tmp's People

Contributors

hiranoko avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.