-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathDistance_between_Tree_and_Tower:_51.95_meters.py
More file actions
37 lines (28 loc) · 1.13 KB
/
Distance_between_Tree_and_Tower:_51.95_meters.py
File metadata and controls
37 lines (28 loc) · 1.13 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
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
# Define the tower height and angle of depression
tower_height = 30
angle_of_depression = 30 # in degrees
# Calculate the distance between the tree and the tower
distance_bc = tower_height / np.tan(np.radians(angle_of_depression))
# Create a 3D plot to visualize the tower, tree, and distance
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# Define the tower and tree points
tower_point = (0, 0, 0)
tree_point = (0, distance_bc, -tower_height)
# Plot the tower and tree
ax.scatter(*tower_point, c='r', label='Tower', s=100)
ax.scatter(*tree_point, c='g', label='Tree', s=100)
# Draw a line connecting the tower and tree
ax.plot([tower_point[0], tree_point[0]], [tower_point[1], tree_point[1]], [tower_point[2], tree_point[2]], 'b--', label='Distance')
# Set labels and legend
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.legend()
# Show the plot
plt.title(f'Distance between Tree and Tower: {distance_bc:.2f} meters')
plt.show()
print(f"The distance between the tree and the tower is approximately {distance_bc:.2f} meters.")