-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplane_generate.py_
65 lines (53 loc) · 1.59 KB
/
plane_generate.py_
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import numpy as np
import random
import plotly.graph_objects as go
# Reference point
ref_point = np.array([-0.1265, -0.1168, 0.5585])
circle_radius = 0.5 # Radius of the circular plane
# Parameters for data generation
num_points = 100 # Number of random points to generate
# Generate random points within the circular plane
generated_points = []
for _ in range(num_points):
# Random radius (0 to circle_radius) and angle (0 to 2*pi)
r = random.uniform(0, circle_radius)
phi = random.uniform(0, 2 * np.pi)
# Convert polar to Cartesian coordinates
x = ref_point[0] + r * np.cos(phi)
y = ref_point[1] + r * np.sin(phi)
z = ref_point[2] # Same z-plane as reference point
generated_points.append([x, y, z])
# Convert to a NumPy array
generated_points = np.array(generated_points)
# Create a scatter plot for the generated points
fig = go.Figure()
# Add the reference point
fig.add_trace(go.Scatter3d(
x=[ref_point[0]],
y=[ref_point[1]],
z=[ref_point[2]],
mode='markers',
marker=dict(size=8, color='red'),
name='Reference Point'
))
# Add the generated points
fig.add_trace(go.Scatter3d(
x=generated_points[:, 0],
y=generated_points[:, 1],
z=generated_points[:, 2],
mode='markers',
marker=dict(size=4, color='blue'),
name='Generated Points'
))
# Update layout for better interaction
fig.update_layout(
title='Interactive 3D Circular Plane',
scene=dict(
xaxis_title='X-axis',
yaxis_title='Y-axis',
zaxis_title='Z-axis',
aspectmode='cube' # Ensure equal scaling
)
)
# Show the plot
fig.show()