off
ikonic>
OUT 0 B

Glass

GLSL 3D Fractals - Quaternion Julia Sets

Quaternion Julia sets extend the classic 2D Julia sets into 4D space using quaternion algebra, then project them back into 3D for visualization. The result is stunning organic, swirling forms with complex rotational symmetries that would be impossible in 2D.

Interactive Demo

Move your mouse to rotate the camera and control the Julia parameter. The fractal animates automatically, creating mesmerizing morphing patterns:

Mathematical Foundation

Quaternions

Quaternions extend complex numbers to 4D:

$$q = w + xi + yj + zk$$

Where $i^2 = j^2 = k^2 = ijk = -1$ and $ij = k$, $jk = i$, $ki = j$.

Quaternion Multiplication

vec4 qmul(vec4 q1, vec4 q2) {
    return vec4(
        q1.x * q2.x - q1.y * q2.y - q1.z * q2.z - q1.w * q2.w,
        q1.x * q2.y + q1.y * q2.x + q1.z * q2.w - q1.w * q2.z,
        q1.x * q2.z - q1.y * q2.w + q1.z * q2.x + q1.w * q2.y,
        q1.x * q2.w + q1.y * q2.z - q1.z * q2.y + q1.w * q2.x
    );
}

Quaternion Julia Iteration

The Julia set iteration in quaternion space:

$$z_{n+1} = z_n^2 + c$$

Where both $z$ and $c$ are quaternions. The quaternion square $q^2$ is computed using quaternion multiplication.

Distance Estimation

Similar to the Mandelbulb, we use:

$$d \approx \frac{|z| \cdot \log(|z|)}{|z'|}$$

Where $z'$ is the derivative of the iteration. For $z_{n+1} = z_n^2 + c$, the derivative is $z'_{n+1} = 2z_n \cdot z'_n$.

Visual Characteristics

Quaternion Julia sets exhibit:

  • Rotational symmetry: Complex 3D rotational patterns
  • Organic forms: Swirling, tentacle-like structures
  • Parameter sensitivity: Small changes in c create dramatically different shapes
  • 4D projection: The 3D slice reveals hidden 4D structure

Parameter Space

The Julia parameter c controls the shape:

  • Real components (c.x, c.y, c.z): Control the 3D structure
  • Imaginary component (c.w): Adds 4D rotation, creating more complex forms
  • Magnitude: Larger |c| creates more chaotic, fragmented structures

Applications

  • Digital art: Stunning abstract visualizations
  • Scientific visualization: Exploring 4D mathematical structures
  • Game assets: Procedural alien environments
  • Educational: Teaching quaternion algebra and 4D geometry

References

Related Articles