bulldog91
bulldog91

Reputation: 133

Function for Creating Spiral Stripes with Orientation 45 Degrees to Radial?

I am trying to reconstruct the spiral pattern in the depicted image for a neuroscience experiment. Basically, the pattern has the properties that:

1) Every part of the spiral has local orientation 45 degrees to radial 2) The thickness of each arm of the spiral increases in direct proportion with the radius.

Ideally I would like to be able to parametrically vary the number of arms of the spiral as needed. You can ignore the blank circle in the middle and the circular boundaries, those are very easy to add.

Does anybody know if there is a function in terms of the number of spiral arms and local orientation that would be able to reconstruct this spiral pattern? For what it's worth I'm coding in Matlab, although if someone has the mathematical formula I can implement it myself no problem.

Red Spiral

Upvotes: 0

Views: 345

Answers (1)

Claude
Claude

Reputation: 1014

Your spiral image does not satisfy your property 1, as can be seen by overlaying the spiral with a flipped copy (the angles at the outer edge are more perpendicular to the radial direction than 45deg, and more parallel at the inner edge):

spiral not satisfying properties

As I commented, a logarithmic spiral can satisfy both properties. I implemented it in GLSL using Fragmentarium, here is the code:

#include "Progressive2D.frag"

#group Spiral
uniform int Stripes; slider[1,20,100]

const float pi = 3.141592653589793;

vec2 cLog(vec2 z)
{
  return vec2(log(length(z)), atan(z.y, z.x));
}

vec3 color(vec2 p)
{
  float t = radians(45.0);
  float c = cos(t);
  float s = sin(t);
  mat2 m = mat2(c, -s, s, c);
  vec2 q = m * cLog(p);
  return vec3(float
    (  mod(float(Stripes) * q.y / (sqrt(2.0) * pi), 1.0) < 0.5
    || length(p) < 0.125
    || length(p) > 0.875
    ));
}

And the output:

spiral satisfying properties

Upvotes: 1

Related Questions