Skip to content

DevWonder01/Gabriel-horn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gabriel's Horn Paradox 3D Simulation

![Gabriel's Horn Paradox 3D Simulation] image

An interactive 3D visualization and simulation of the Gabriel's Horn paradox (also known as Torricelli's trumpet). The application is built in Rust using the Macroquad game engine for 3D rendering and Egui for the control panel.

Gabriel's Horn is a geometric figure that has an infinite surface area but a finite volume. It is formed by taking the curve y = 1/x for x >= 1 and rotating it in three dimensions about the x-axis.

Mathematical Background

The paradox of the horn is demonstrated through calculus:

Volume

The volume (V) of the horn from x = 1 to x = a is finite. As the cutoff limit a approaches infinity, the volume converges to pi:

V = pi * integral_1^a (1/x)^2 dx = pi * (1 - 1/a) Limit as a -> infinity of V = pi (approximately 3.14159)

Surface Area

The surface area (A) of the horn from x = 1 to x = a is infinite. As the cutoff limit a approaches infinity, the surface area diverges:

A = 2 * pi * integral_1^a (1/x) * sqrt(1 + (dy/dx)^2) dx A = 2 * pi * integral_1^a (1/x) * sqrt(1 + 1/x^4) dx

Since sqrt(1 + 1/x^4) > 1 for all x >= 1: A > 2 * pi * integral_1^a (1/x) dx = 2 * pi * ln(a) Limit as a -> infinity of A = infinity

This means the horn could be filled with a finite amount of paint (pi cubic units), yet it would require an infinite amount of paint to coat its outer surface.

Features

  • Multiple Simulation Modes:
    • Geometry: View the static/rotating mathematical wireframe, solid, or hybrid mesh.
    • Volume Fill: An animation showing the horn being filled internally with a finite amount of paint from a nozzle.
    • Surface Paint: An animation showing the outer surface of the horn being coated with paint.
  • Real-time Interactive Graph: Visualizes the volume (converging to pi) and surface area (growing infinitely) as a function of the cutoff limit.
  • Interactive 3D Camera:
    • Orbit Rotation: Left-click and drag.
    • Pan Target: Right-click and drag.
    • Zoom: Scroll wheel.
    • Auto-Rotate: Automatically spin the camera orbit with adjustable speeds.
  • Aesthetic Settings:
    • Dynamic light source tracking with manual and auto-spin controls.
    • Adjust ambient, diffuse, and specular lighting parameters.
    • Enable/disable coordinate axes and bounding envelopes.
    • Live cross-section plane cutting at any position x.
    • Multiple color palettes: Magma, Electric Purple, Cyberpunk Gold, Deep Ocean, and Curvature Spectral.

Technical Details

The simulation implements custom mesh generation algorithms in Rust:

  • Spacing along the x-axis uses logarithmic distribution to increase vertex density near the high-curvature throat (x = 1) for smoother lighting and wireframes.
  • Normal vectors are calculated analytically from the derivative of the curve equation to ensure precise lighting shading.
  • Transparent outer shells in "Volume Fill" mode leverage raw OpenGL blending via miniquad's raw GL bindings.
  • Window and rendering configurations are optimized by overriding Macroquad's draw call capacities (draw_call_vertex_capacity to 256,000 and draw_call_index_capacity to 512,000) to allow drawing dense 3D meshes without batch clamping artifacts.

How to Build and Run

Prerequisites

  • Rust compiler and Cargo toolchain.

Running the App

Run the following command in the root of the project directory:

cargo run --release

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages