Skip to content

feat(wave): opt-in 9-point isotropic Laplacian for super-sampled mode (refs #3073 §5) #3095

Closed

Description

@zackees

Scope from #3073 §5.

Problem

The current 5-point Laplacian in WaveSimulation2D_Real::update() is O(h²) accurate but anisotropic — waves visibly prefer the 4 cardinal directions over the 4 diagonals, producing a square-ish ripple shape (a well-known artifact of this stencil).

At LED-grid resolutions (8×8, 16×16) this is usually invisible. At SUPER_SAMPLE_4X / _8X it becomes noticeable on circular ripples — exactly the case where users opted into more CPU for better visual quality.

Proposed fix

A 9-point isotropic Laplacian — still O(h²) but with isotropic leading error:

∇²u ≈ [ 1/6 · (NW + NE + SW + SE)
      + 2/3 · ( N + S + E + W )
      - 10/3 · C ] / h²

Cost: ~2× the reads + ALU per cell vs. the 5-point stencil. Output: rounder ripples.

Implementation

  • Add a runtime switch on WaveSimulation2D_Real:
    enum class LaplacianStencil { FivePoint, NinePointIsotropic };
    void setStencil(LaplacianStencil s);
  • Default to FivePoint for backward compatibility (existing tests assume current output).
  • The super-sampled wrapper WaveSimulation2D (in src/fl/math/wave/wave_simulation.h) should default to NinePointIsotropic when SuperSample >= SUPER_SAMPLE_2X, since that's the case where the visual win is felt and the CPU cost is already higher.

Acceptance

  • New unit test verifies 9-point Laplacian at a center cell equals the analytical value for a known input (delta function, sinusoid).
  • Existing 5-point tests untouched (default behavior unchanged).
  • Visual check on examples/Fx/FxWave2d with single-point impulse — ripple should be round, not square.

Numerical accuracy implication

The 9-point form also helps §1's overflow margin (#3083) since the per-cell coefficients are fractional — the post->>15 term magnitude is smaller. Not a blocker, but a minor secondary benefit.

Refs: #3073 §5.

Activity

  1. zackees commented on Jun 15, 2026

    @zackees
    MemberAuthor

    Parent meta: #3098.

  2. added a commit that references this issue on Jun 15, 2026
    527216b
  3. moved this from Triage to Done in FastLED Trackeron Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions