Skip to content

Unusual principal value for cLog #13

@pjt33

Description

@pjt33

cLog is implemented as

vec2 cLog(vec2 a) {
    float b =  atan(a.y,a.x);
    if (b>0.0) b-=2.0*3.1415;
    return vec2(log(length(a)),b);
}

The resulting imaginary part is rather unexpected: the two main conventions for the principal value of arctan are that it runs from -pi to pi or from 0 to 2pi, not (as here) from -2pi to 0.

I presume that it's implemented as present because the Ducks fractal requires an unusual branch cut, but I question whether the implementation with that branch cut should be the "default" one, the only one provided in Complex.frag.

I have three suggestions, and I'll happily write a patch if one of them is acceptable:

  1. Provide three different log methods with different names and branch cuts: cLogPos (0 to 2pi), cLog (-pi to pi), cLogNeg (-2pi to 0).
  2. Provide an overload which takes an int parameter and switches on it.
  3. Add a control uniform int logBranchCut; slider [-1,0,1] and switch on its value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions