Skip to content

Commit

Permalink
Merge pull request #48 from mapilio/calc4alt
Browse files Browse the repository at this point in the history
fixes names and math func.
  • Loading branch information
ozcan-durak committed Aug 21, 2023
2 parents 0572d8f + 363bca3 commit 84be14a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions calculation/distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def haversine(**kwargs):
return c * RADIUS

@staticmethod
def destination_point(lat, lon, distance, bearing):
def destination_point(lat, lon, distance, theta):
"""
:lat :
:lon :
Expand All @@ -108,7 +108,7 @@ def destination_point(lat, lon, distance, bearing):
"""

δ = distance / RADIUS
θ = bearing * TO_RAD
θ = theta * TO_RAD
φ1 = radians(lat)
λ1 = radians(lon)
φ2 = asin(sin(φ1) * cos(δ) + cos(φ1) * sin(δ) * cos(θ))
Expand Down
12 changes: 7 additions & 5 deletions calculation/intersection.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def ops_detect(self, loc):
ops = []
for i in range(0, len(loc), 3):
ops.append(Distance.destination_point(lat=loc[i], lon=loc[i + 1], distance=self.intersection_lineLength,
bearing=loc[i + 2]))
theta=loc[i + 2]))
return ops[0], ops[1]

@staticmethod
Expand Down Expand Up @@ -334,18 +334,20 @@ def intersection_points_find(self, **kwargs):
distance_between_panoroma_first_and_intersected_point = Distance.haversine(
lon1=points.start_lon1, lat1=points.start_lat1,
lon2=is_intersect['y'], lat2=is_intersect['x'])
ph1 = 180 - ph1 if ph1 > 90 else ph1
ph2 = 180 - ph2 if ph2 > 90 else ph2
# it changes cos range as 0-90 and altitude always increases according this formula
# ph1 = 180 - ph1 if ph1 > 90 else ph1
# ph2 = 180 - ph2 if ph2 > 90 else ph2

center_altA = (math.tan(
#https://mathinsight.org/spherical_coordinates
center_altA = (math.cos(
math.radians(ph1)) * distance_between_panoroma_first_and_intersected_point +
float(points.start_alt1))

distance_between_panoroma_second_and_intersected_point = Distance.haversine(
lon1=points.start_lon2, lat1=points.start_lat2,
lon2=is_intersect['y'], lat2=is_intersect['x'])

center_altB = (math.tan(
center_altB = (math.cos(
math.radians(ph2)) * distance_between_panoroma_second_and_intersected_point +
float(points.start_alt2))

Expand Down

0 comments on commit 84be14a

Please sign in to comment.