Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
freem
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Openai/68f40a7c-717c-8000-8af6-a222789ef1d8
(section)
Add languages
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== User: import numpy as np === import numpy as np import matplotlib.pyplot as plt from matplotlib.widgets import Button from mpl_toolkits.mplot3d import Axes3D from mpl_toolkits.mplot3d.art3d import Poly3DCollection class GoldenEllipseSpiralCube: def __init__(self): self.fig = plt.figure(figsize=(16, 10)) # Create main 3D plot (left side) self.ax = self.fig.add_subplot(121, projection='3d') # Create info panel (right side) self.ax_info = self.fig.add_subplot(122) self.ax_info.axis('off') # Turn off axes for info panel # Golden ratio self.phi = (1 + np.sqrt(5)) / 2 # Approximately 1.618 # Great Pyramid angle (51.84 degrees) self.pyramid_angle = 51.84 # Cube vertices (cube from -1 to 1 in all dimensions) self.vertices = np.array([ [-1, -1, -1], [1, -1, -1], [1, 1, -1], [-1, 1, -1], # bottom face [-1, -1, 1], [1, -1, 1], [1, 1, 1], [-1, 1, 1] # top face ]) # Define faces (quadrilaterals) self.faces = [ [0, 1, 2, 3], # bottom [4, 5, 6, 7], # top [0, 1, 5, 4], # front [2, 3, 7, 6], # back [0, 3, 7, 4], # left [1, 2, 6, 5] # right ] # Colors for each face (RGBA with transparency) self.face_colors = [ [1, 0, 0, 0.05], # red - bottom [0, 1, 0, 0.05], # green - top [0, 0, 1, 0.05], # blue - front [1, 1, 0, 0.05], # yellow - back [1, 0, 1, 0.05], # magenta - left [0, 1, 1, 0.05] # cyan - right ] # Create spiral that projects a perfect circle self.spiral_points = self.create_circle_projection_spiral() self.circle_projection = self.create_circle_projection() # Golden ellipse parameters self.golden_ellipse_points = self.create_golden_ellipse_projection() # Rotation state self.elev = 30 self.azim = 45 self.dragging = False self.prev_mouse = None # Create buttons first self.create_buttons() self.setup_plot() self.setup_info_panel() self.connect_events() def create_circle_projection_spiral(self): """Create a spiral that projects a perfect circle matching cube dimensions""" t = np.linspace(0, 2 * np.pi, 200) spiral_points = [] for angle in t: # Circle radius = 1 to match cube dimensions circle_radius = 1.0 # X and Y coordinates form a perfect circle x = circle_radius * np.cos(angle) y = circle_radius * np.sin(angle) # Z coordinate goes linearly from bottom to top z = -1.0 + (angle / (2 '' np.pi)) '' 2.0 spiral_points.append([x, y, z]) return np.array(spiral_points) def create_circle_projection(self): """Project the spiral onto the front face (z=1)""" projection_points = [] for point in self.spiral_points: x, y, z = point projection_points.append([x, y, 1]) return np.array(projection_points) def create_golden_ellipse_projection(self): """Create the golden ellipse that appears when viewing from an angle""" t = np.linspace(0, 2 * np.pi, 100) # For golden ellipse: major_axis / minor_axis = phi (golden ratio) major_axis = 1.0 # Same as circle radius minor_axis = major_axis / self.phi # Approximately 0.618 ellipse_points = [] for angle in t: x = major_axis * np.cos(angle) y = minor_axis * np.sin(angle) z = 1.0 # On front face ellipse_points.append([x, y, z]) return np.array(ellipse_points) def calculate_perspective_ellipse(self, view_angle): """Calculate how the circle appears as an ellipse from given view angle""" t = np.linspace(0, 2 * np.pi, 100) # The perspective transformation depends on view angle # When viewed from angle theta, circle appears as ellipse with: # major_axis = 1 (unchanged in viewing plane) # minor_axis = cos(theta) (foreshortening) theta = np.radians(view_angle) perspective_minor_axis = np.cos(theta) ellipse_points = [] for angle in t: x = np.cos(angle) # Major axis remains 1 y = perspective_minor_axis * np.sin(angle) # Minor axis compressed z = 1.0 ellipse_points.append([x, y, z]) return np.array(ellipse_points) def create_buttons(self): """Create the control buttons""" # Add buttons below the 3D plot self.ax_reset = plt.axes([0.3, 0.02, 0.12, 0.04]) self.ax_golden = plt.axes([0.43, 0.02, 0.15, 0.04]) self.ax_pyramid = plt.axes([0.59, 0.02, 0.15, 0.04]) self.button_reset = Button(self.ax_reset, 'Default View') self.button_golden = Button(self.ax_golden, 'Golden Ratio View') self.button_pyramid = Button(self.ax_pyramid, 'Pyramid Angle View') self.button_reset.on_clicked(self.reset_view) self.button_golden.on_clicked(self.reset_to_golden_view) self.button_pyramid.on_clicked(self.reset_to_pyramid_view) def setup_plot(self): """Initialize the 3D plot highlighting the Golden Ellipse""" self.ax.clear() # Create the cube faces with very high transparency for i, face in enumerate(self.faces): vertices = self.vertices[face] poly = Poly3DCollection([vertices], alpha=0.03) poly.set_facecolor(self.face_colors[i]) poly.set_edgecolor('gray') poly.set_linewidth=0.5 self.ax.add_collection3d(poly) # Plot the main spiral spiral = self.spiral_points self.ax.plot3D(spiral[:, 0], spiral[:, 1], spiral[:, 2], color='black', linewidth=3, alpha=0.8) # Plot the perfect circle projection on front face circle_proj = self.circle_projection self.ax.plot3D(circle_proj[:, 0], circle_proj[:, 1], circle_proj[:, 2], color='blue', linewidth=3, alpha=0.8) # Plot the golden ellipse golden_ellipse = self.golden_ellipse_points self.ax.plot3D(golden_ellipse[:, 0], golden_ellipse[:, 1], golden_ellipse[:, 2], color='gold', linewidth=4, alpha=0.9) # Calculate and plot perspective ellipse for current view perspective_ellipse = self.calculate_perspective_ellipse(self.elev) self.ax.plot3D(perspective_ellipse[:, 0], perspective_ellipse[:, 1], perspective_ellipse[:, 2], color='red', linewidth=2, linestyle='--', alpha=0.7) # Mark the golden ratio proportions # Major axis points self.ax.plot3D([-1, 1], [0, 0], [1, 1], color='green', linewidth=2) # Minor axis points (golden ratio) minor_axis_length = 1 / self.phi self.ax.plot3D([0, 0], [-minor_axis_length, minor_axis_length], [1, 1], color='purple', linewidth=2) # Add golden ratio markers self.ax.scatter3D([1, -1], [0, 0], [1, 1], color='green', s=80, marker='o') self.ax.scatter3D([0, 0], [minor_axis_length, -minor_axis_length], [1, 1], color='purple', s=80, marker='o') # Add ratio text self.ax.text(0.6, 0, 1.1, f'1.000', color='green', fontweight='bold', fontsize=10, bbox=dict(boxstyle="round,pad=0.2", facecolor='green', alpha=0.7)) self.ax.text(0.1, minor_axis_length/2, 1.1, f'{minor_axis_length:.3f}', color='purple', fontweight='bold', fontsize=10, bbox=dict(boxstyle="round,pad=0.2", facecolor='purple', alpha=0.7)) # Set plot limits self.ax.set_xlim([-1.5, 1.5]) self.ax.set_ylim([-1.5, 1.5]) self.ax.set_zlim([-1.5, 1.5]) self.ax.set_xlabel('X Axis', fontweight='bold') self.ax.set_ylabel('Y Axis', fontweight='bold') self.ax.set_zlabel('Z Axis', fontweight='bold') self.ax.set_title('Golden Ellipse Phenomenon', fontsize=14, fontweight='bold') # Set the view self.ax.view_init(elev=self.elev, azim=self.azim) # Style the plot self.ax.xaxis.pane.fill = False self.ax.yaxis.pane.fill = False self.ax.zaxis.pane.fill = False self.ax.xaxis.pane.set_edgecolor('w') self.ax.yaxis.pane.set_edgecolor('w') self.ax.zaxis.pane.set_edgecolor('w') self.ax.grid(True, alpha=0.2) # Update the display self.fig.canvas.draw_idle() def setup_info_panel(self): """Setup the information panel on the right side""" self.ax_info.clear() self.ax_info.axis('off') # Golden ratio information minor_axis_length = 1 / self.phi # Calculate the pyramid connection pyramid_minor_axis = np.cos(np.radians(self.pyramid_angle)) pyramid_ratio = 1.0 / pyramid_minor_axis # Create legend/explanation in the info panel legend_text = ( "VISUAL ELEMENTS EXPLANATION:\n\n" "Black line: 3D Spiral inside cube\n" "Blue line: Perfect Circle (front view)\n" "Gold line: Golden Ellipse (phi=1.618)\n" "Red dashed: Current Perspective View\n" "Green line: Major Axis = 1.000\n" "Purple line: Minor Axis = 0.618\n\n" "GOLDEN RATIO & PYRAMID CONNECTION:\n\n" f"Golden Ratio (phi) = {self.phi:.6f}\n" f"Great Pyramid Angle = {self.pyramid_angle} deg\n\n" "MATHEMATICAL CONNECTION:\n" f"72 x 72 = 5184 (pyramid angle)\n" f"Pyramid slope ratio: {pyramid_ratio:.6f}\n" f"Very close to golden ratio!\n\n" "ELLIPSE PROPERTIES:\n" f"Major Axis = 1.000\n" f"Minor Axis = {minor_axis_length:.6f}\n" f"Golden Ratio = 1.000 / {minor_axis_length:.3f} = {self.phi:.6f}\n\n" "PYRAMID PERSPECTIVE:\n" f"At {self.pyramid_angle} deg elevation:\n" f"Minor Axis = {pyramid_minor_axis:.6f}\n" f"Ratio = 1.000 / {pyramid_minor_axis:.6f} = {pyramid_ratio:.6f}\n\n" "ANCIENT WISDOM:\n" "Egyptians encoded golden ratio\n" "in pyramid architecture through\n" "precise slope angles\n" "51.84 deg = 72x72/100\n\n" "CONTROLS:\n" "Click & drag to rotate\n" "Mouse wheel to zoom\n" "Buttons for special views" ) self.ax_info.text(0.05, 0.95, legend_text, transform=self.ax_info.transAxes, fontsize=9, verticalalignment='top', fontfamily='monospace', bbox=dict(boxstyle="round,pad=1", facecolor='lightblue', alpha=0.8, edgecolor='darkblue')) self.fig.canvas.draw_idle() def connect_events(self): """Connect mouse events for interactive rotation""" self.fig.canvas.mpl_connect('button_press_event', self.on_press) self.fig.canvas.mpl_connect('button_release_event', self.on_release) self.fig.canvas.mpl_connect('motion_notify_event', self.on_motion) self.fig.canvas.mpl_connect('scroll_event', self.on_scroll) def on_press(self, event): """Handle mouse button press""" if event.inaxes == self.ax: self.dragging = True self.prev_mouse = (event.x, event.y) def on_release(self, event): """Handle mouse button release""" self.dragging = False self.prev_mouse = None def on_motion(self, event): """Handle mouse motion for rotation""" if not self.dragging or event.inaxes != self.ax or self.prev_mouse is None: return dx = event.x - self.prev_mouse[0] dy = event.y - self.prev_mouse[1] # Update rotation angles self.azim += dx * 0.5 self.elev -= dy * 0.5 # Clamp elevation to avoid flipping self.elev = np.clip(self.elev, -90, 90) # Update view without recreating the entire plot self.ax.view_init(elev=self.elev, azim=self.azim) self.fig.canvas.draw_idle() self.prev_mouse = (event.x, event.y) def on_scroll(self, event): """Handle mouse scroll for zoom""" if event.inaxes == self.ax: # Get current limits xlim = self.ax.get_xlim() ylim = self.ax.get_ylim() zlim = self.ax.get_zlim() # Calculate centers x_center = np.mean(xlim) y_center = np.mean(ylim) z_center = np.mean(zlim) # Zoom factor zoom_factor = 1.1 if event.step > 0 else 0.9 # Apply zoom around center x_range = (xlim[1] - xlim[0]) * zoom_factor y_range = (ylim[1] - ylim[0]) * zoom_factor z_range = (zlim[1] - zlim[0]) * zoom_factor self.ax.set_xlim([x_center - x_range/2, x_center + x_range/2]) self.ax.set_ylim([y_center - y_range/2, y_center + y_range/2]) self.ax.set_zlim([z_center - z_range/2, z_center + z_range/2]) self.fig.canvas.draw_idle() def reset_view(self, event=None): """Reset to default view""" self.elev = 30 self.azim = 45 self.setup_plot() def reset_to_golden_view(self, event=None): """Reset to the view that shows the golden ellipse perfectly""" self.elev = 52 # Special angle that creates golden ratio self.azim = 45 self.setup_plot() def reset_to_pyramid_view(self, event=None): """Reset to the Great Pyramid angle view""" self.elev = self.pyramid_angle # 51.84 degrees self.azim = 45 self.setup_plot() def show(self): """Display the interactive cube""" print("GOLDEN ELLIPSE & GREAT PYRAMID CONNECTION") print("=" * 50) print("Amazing Discovery: 51.84 deg = Great Pyramid slope angle") print("Mathematical: 72 x 72 = 5184") print("Golden Ratio encoded in ancient architecture!") print() print("CONTROLS:") print("- Left: Clean 3D visualization (no overlapping text)") print("- Right: Complete legend and information") print("- Click and drag to rotate the 3D view") print("- Use mouse wheel to zoom") print("- Buttons: Default, Golden Ratio, Pyramid Angle views") plt.show()
Summary:
Please note that all contributions to freem are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 (see
Freem:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)