-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinfo.py
More file actions
42 lines (32 loc) · 1.12 KB
/
Copy pathinfo.py
File metadata and controls
42 lines (32 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 09 13:30:00 2016
@author: Leonardo Nascimento
"""
import math
import numpy as np
import pyproj
def distance(lat1, lon1, lat2, lon2):
geod = pyproj.Geod(ellps="WGS84")
angle1, angle2, distance = geod.inv(lon1, lat1, lon2, lat2)
return distance
class Info():
def __init__(self, filename, x, y, z, yaw, pitch, roll):
self.filename = filename
self.longitude = float(x)
self.latitude = float(y)
self.z = float(z)
self.yaw = -1.0 * float(yaw)
self.pitch = -1.0 * float(pitch)
self.roll = -1.0 * float(roll)
def relativeXYZ(self, latitude, longitude):
XYZ = np.zeros(3)
XYZ[2] = self.z
dY = distance(latitude, longitude, self.latitude, longitude)
XYZ[1] = dY if self.latitude > latitude else -dY
dX = distance(latitude, longitude, latitude, self.longitude)
XYZ[0] = dX if self.longitude > longitude else -dX
return XYZ
def distance(self, latitude, longitude):
return distance(latitude, longitude, self.latitude, self.longitude)