Skip to content

Repository files navigation

Fractal Yin-Yang

An interactive visualization exploring the mathematical beauty of recursive yin-yang patterns in both 2D and 3D space.

Fractal Yin-Yang Preview
Fractal Yin-Yang Preview

About

The "Yin-Yang fractal" is a modern mathematical and artistic construct that emerged from the fractal art community in the late 20th/early 21st century. While the traditional yin-yang symbol dates back to ancient Chinese philosophy, this fractal interpretation is a contemporary creation—its exact origin remains undocumented, existing as what might be called a "secret artist's symbol" within mathematical art circles.

This project provides an interactive exploration of this fascinating pattern, allowing you to observe its recursive self-similar structure through both 2D canvas rendering and 3D Three.js visualization.

Features

  • 2D Canvas Rendering: Classic flat visualization with smooth rotation animation
  • 3D Three.js Visualization: Interactive 3D representation with mouse controls
    • Click and drag to rotate the structure
    • Scroll to zoom in/out
    • Wireframe rendering for visual clarity through recursive layers
  • Adjustable Rotation Speed: Control the animation speed with a slider
  • Deep Recursion: Explores up to 7-8 levels of self-similar nesting

Mathematical Significance

This fractal demonstrates several key mathematical concepts:

  • Self-similarity: Each small circle contains a complete yin-yang pattern, recurring infinitely
  • Recursive geometry: The pattern is defined by a simple recursive rule applied at multiple scales
  • Circular symmetry: The construction maintains rotational properties throughout its recursive depth
  • Complementary duality: The black/white (or opaque/transparent) relationship preserves philosophical balance at every scale

For a detailed mathematical analysis, see MATHEMATICAL_ANALYSIS.md.

Live Demo

Open fractal_yin_yang.html in any modern web browser to run the visualization locally.

Fractal Yin-Yang Preview

Technical Details

Dependencies

  • Three.js r128 (loaded via CDN)
  • Modern browser with Canvas and WebGL support

Structure

  • 2D Implementation: Uses HTML5 Canvas 2D context with recursive drawing functions
  • 3D Implementation: Three.js with hemisphere geometries and recursive group hierarchies
  • Recursion Depth: Configurable, currently set to 7-8 levels
  • Materials: Wireframe rendering in 3D for transparency and visual depth

Usage

  1. Clone the repository:
git clone https://github.com/BlueberryMathematics/fractal-yin-yang.git
cd fractal-yin-yang
  1. Open the HTML file:
open fractal_yin_yang.html
# or simply open it in your browser
  1. Interact with the visualization:
    • Click the "2D Canvas" or "3D Three.js" buttons to switch modes
    • Adjust the rotation speed slider
    • In 3D mode: drag to rotate, scroll to zoom

Implementation Notes

2D Canvas

The 2D version uses a recursive function that:

  1. Draws a circle split into black and white halves
  2. Draws two smaller circles (upper and lower) of complementary colors
  3. Recursively calls itself within each smaller circle

3D Three.js

The 3D version creates:

  1. Black and transparent hemispheres forming the main sphere
  2. Upper and lower smaller spheres with the same hemisphere pattern
  3. Recursive nested groups positioned at each smaller sphere's location
  4. Each nested level rotates independently (except the root)

Contributing

Contributions are welcome! Whether it's:

  • Mathematical analysis and improvements
  • Performance optimizations
  • Additional visualization modes
  • Documentation of the historical origins of this pattern

Please feel free to open issues or submit pull requests.

References

License

MIT License - See LICENSE file for details

Acknowledgments

This project explores a pattern that emerged from the fractal art community. While the exact discoverer remains unknown, it represents a beautiful intersection of ancient symbolism, modern mathematics, and computational art.


Note: If you have information about the origin or early history of the yin-yang fractal pattern, please consider contributing to the documentation or opening an issue to share your knowledge.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages