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!
=== Assistant: Perfect choice — the pure positional morph keeps the geometry clean and elegant especially for something golden-ratio t… === Perfect choice — the pure positional morph keeps the geometry clean and elegant (especially for something golden-ratio themed ✨). Here’s the final, Windows-safe version of your script — including the new morph animation (no opacity fade, just shape transition). You can copy–paste this entire version and run it directly with: <syntaxhighlight lang="bash">py GoldenEllipseSpiralCubeSLIDER_SINE_MORPH_SAFE.py </syntaxhighlight> <syntaxhighlight lang="python"># -''- coding: utf-8 -''- === GoldenEllipseSpiralCubeSLIDER_SINE_MORPH_SAFE.py === === Windows-safe version with smooth spiral → sine morph === import numpy as np import matplotlib.pyplot as plt from matplotlib.widgets import Button from mpl_toolkits.mplot3d.art3d import Poly3DCollection import matplotlib.animation as animation class GoldenEllipseSpiralCube: def __init__(self): self.fig = plt.figure(figsize=(12, 8)) self.ax = self.fig.add_subplot(121, projection="3d") self.ax_info = self.fig.add_subplot(122) self.ax_info.axis("off") self.phi = (1 + np.sqrt(5)) / 2 self.pyramid_angle = 51.84 self.vertices = np.array([ [-1, -1, -1], [1, -1, -1], [1, 1, -1], [-1, 1, -1], [-1, -1, 1], [1, -1, 1], [1, 1, 1], [-1, 1, 1] ]) self.faces = [ [0, 1, 2, 3], [4, 5, 6, 7], [0, 1, 5, 4], [2, 3, 7, 6], [0, 3, 7, 4], [1, 2, 6, 5] ] self.face_colors = [ [1, 0, 0, 0.05], [0, 1, 0, 0.05], [0, 0, 1, 0.05], [1, 1, 0, 0.05], [1, 0, 1, 0.05], [0, 1, 1, 0.05] ] # Geometry self.spiral_points = self.create_circle_projection_spiral() self.circle_projection = self.create_circle_projection() self.golden_ellipse_points = self.create_golden_ellipse_projection() self.sine_projection_points = self.create_sine_projection() # State self.sine_visible = False self.elev = 30 self.azim = 45 # UI setup self.create_buttons() self.setup_plot() self.setup_info_panel() # ------------------------------------------------------------ # Geometry generation # ------------------------------------------------------------ def create_circle_projection_spiral(self): t = np.linspace(0, 2 * np.pi, 200) spiral = [] for a in t: x = np.cos(a) y = np.sin(a) z = -1.0 + (a / (2 '' np.pi)) '' 2.0 spiral.append([x, y, z]) return np.array(spiral) def create_circle_projection(self): proj = [] for p in self.spiral_points: proj.append([p[0], p[1], 1]) return np.array(proj) def create_golden_ellipse_projection(self): t = np.linspace(0, 2 * np.pi, 200) major = 1.0 minor = major / self.phi ell = [] for a in t: x = major * np.cos(a) y = minor * np.sin(a) z = 1 ell.append([x, y, z]) return np.array(ell) def create_sine_projection(self): """Smooth continuation of the spiral into a vertical sinusoidal pattern inside the cube""" start = self.spiral_points[-1] x0, y0, z0 = start z = np.linspace(z0, -1, 400) theta_start = np.arctan2(y0, x0) theta = np.linspace(theta_start, theta_start + 4 * np.pi, 400) r_base = np.sqrt(x0 ''' 2 + y0 ''' 2) r = r_base '' (1 - 0.2 '' np.sin(4 '' np.pi '' (z - z0) / 2)) x = r * np.cos(theta) y = r * np.sin(theta) return np.column_stack((x, y, z)) # ------------------------------------------------------------ # Buttons and event handlers # ------------------------------------------------------------ def create_buttons(self): self.ax_reset = plt.axes([0.25, 0.02, 0.12, 0.05]) self.ax_golden = plt.axes([0.38, 0.02, 0.15, 0.05]) self.ax_pyramid = plt.axes([0.54, 0.02, 0.15, 0.05]) self.ax_sine = plt.axes([0.70, 0.02, 0.18, 0.05]) self.btn_reset = Button(self.ax_reset, "Default View") self.btn_golden = Button(self.ax_golden, "Golden Ratio View") self.btn_pyramid = Button(self.ax_pyramid, "Pyramid Angle View") self.btn_sine = Button(self.ax_sine, "Toggle Sine Projection") self.btn_reset.on_clicked(self.reset_view) self.btn_golden.on_clicked(self.reset_golden_view) self.btn_pyramid.on_clicked(self.reset_pyramid_view) self.btn_sine.on_clicked(self.toggle_sine_projection) # ------------------------------------------------------------ # Plot setup and drawing # ------------------------------------------------------------ def setup_plot(self, alpha=1.0): self.ax.clear() # Draw cube for i, face in enumerate(self.faces): verts = self.vertices[face] poly = Poly3DCollection([verts], alpha=0.03) poly.set_facecolor(self.face_colors[i]) poly.set_edgecolor("gray") self.ax.add_collection3d(poly) # Spiral, ellipse, etc. s = self.spiral_points self.ax.plot3D(s[:, 0], s[:, 1], s[:, 2], color="black", linewidth=3) c = self.circle_projection self.ax.plot3D(c[:, 0], c[:, 1], c[:, 2], color="blue", linewidth=2) g = self.golden_ellipse_points self.ax.plot3D(g[:, 0], g[:, 1], g[:, 2], color="gold", linewidth=3) # Morph transition if self.sine_visible or alpha < 1.0: s_len = min(len(self.spiral_points), len(self.sine_projection_points)) blended = (1 - alpha) '' self.spiral_points[:s_len] + alpha '' self.sine_projection_points[:s_len] self.ax.plot3D(blended[:, 0], blended[:, 1], blended[:, 2], color="orange", linewidth=3) # Axes, 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", fontweight="bold") self.ax.view_init(elev=self.elev, azim=self.azim) self.fig.canvas.draw_idle() def setup_info_panel(self): self.ax_info.clear() self.ax_info.axis("off") text = ( "Golden Ellipse and Spiral Cube\n\n" "Controls:\n" "- Default View\n" "- Golden Ratio View\n" "- Pyramid Angle View\n" "- Toggle Sine Projection\n\n" "Morph Transition:\n" "Smooth positional morph between spiral and sine projection." ) self.ax_info.text(0.05, 0.95, text, transform=self.ax_info.transAxes, va="top", ha="left", fontsize=9, family="monospace", bbox=dict(boxstyle="round,pad=1", facecolor="lightblue", alpha=0.7)) self.fig.canvas.draw_idle() # ------------------------------------------------------------ # View and interaction # ------------------------------------------------------------ def reset_view(self, event=None): self.elev = 30 self.azim = 45 self.setup_plot() def reset_golden_view(self, event=None): self.elev = 52 self.azim = 45 self.setup_plot() def reset_pyramid_view(self, event=None): self.elev = self.pyramid_angle self.azim = 45 self.setup_plot() # ------------------------------------------------------------ # Morph Animation # ------------------------------------------------------------ def animate_transition(self, direction): frames = 50 alpha_values = np.linspace(0, 1, frames) if direction == "on" else np.linspace(1, 0, frames) def update(frame): self.setup_plot(alpha=frame) return [] self.anim = animation.FuncAnimation(self.fig, update, frames=alpha_values, interval=30, blit=False, repeat=False) self.fig.canvas.draw_idle() def toggle_sine_projection(self, event=None): if not self.sine_visible: self.animate_transition("on") self.sine_visible = True else: self.animate_transition("off") self.sine_visible = False # ------------------------------------------------------------ # Show # ------------------------------------------------------------ def show(self): print("GOLDEN ELLIPSE & CONTINUOUS SINE MORPH") print("=========================================") print("Left: 3D view | Right: info panel") print("Use mouse drag to rotate, wheel to zoom.") plt.show() if __name__ == "__main__": cube = GoldenEllipseSpiralCube() cube.show() </syntaxhighlight> ===== - Clicking Toggle Sine Projection morphs the black spiral into the orange sine path smoothly (no fade). ===== * Clicking again morphs it back. * The animation is continuous and stays inside the cube. Would you like the morph to pause briefly at mid-transition (alpha = 0.5) before continuing — to make it feel like a “breathing” organic transformation?
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)