# Wolfram Function Repository

Instant-use add-on functions for the Wolfram Language

Function Repository Resource:

Find the number of times the domain coloring of a function wraps around the color wheel along a given curve

Contributed by:
Garrett Dubofsky, Wolfram|Alpha Math Team

ResourceFunction["ColorWinding"][{ finds the winding number of the 2D transformation { | |

ResourceFunction["ColorWinding"][{ finds the winding number over a collection of curves. | |

ResourceFunction["ColorWinding"][{ specifies the output type using | |

ResourceFunction["ColorWinding"][{ outputs the domain coloring of the transformation. |

A domain coloring pairs every transformed point’s angle around the origin to a specific hue. This is a method used to visualize 2D transformations. The red hue lies along the negative y-axis and the color wheel is oriented counterclockwise around the origin.

The winding number of a 2D function along a curve is the number of times the domain coloring of the function winds around the color wheel as the curve is transversed.

Wrapping in the order of red → green → blue represents a positive winding number, whereas blue → green → red is negative.

The winding number is an integer.

Both functions *f*_{1} and *f*_{2} should depend on the independent variables *x* and *y* and output a single numeric value.

The value of *output* can be a single item or a list containing any of "Number", "HuePlot", "PolygonPlot", "DomainColor", or All.

ResourceFunction["ColorWinding"] takes all the options for ParametricPlot with the following additions:

After the identity mapping is applied, the domain coloring of the unit square centered at the origin winds around the color wheel once:

In[1]:= |

Out[1]= |

The domain coloring along this curve can be visualized:

In[2]:= |

Out[2]= |

The "HuePlot" output plots the domain coloring Hue value along the curve:

In[3]:= |

Out[3]= |

Over the entire plane, the domain coloring of the identity mapping preserves the color wheel centered at the origin:

In[4]:= |

Out[4]= |

If the order of the points is reversed, the winding number is negated:

In[5]:= |

Out[5]= |

Each 2D transformation produces its own domain coloring:

In[6]:= |

Out[6]= |

Specify a collection of curves:

In[7]:= |

Out[7]= |

All forms of Rectangle are recognized as valid lists of points:

In[8]:= |

Out[8]= |

All forms of Triangle are also supported:

In[9]:= |

Out[9]= |

The heads Polygon and Line are supported:

In[10]:= |

Out[10]= |

In[11]:= |

Out[11]= |

Multiple output types can be selected in a list and their input order is reflected in the output:

In[12]:= |

Out[12]= |

If All is used as the output type, the function returns an Association:

In[13]:= |

Out[13]= |

Determine if the list of points defines a closed curve:

In[14]:= |

Out[14]= |

The "IterationLength" option determines how frequently the Hue value is sampled along the curve, which produces more accurate results:

In[15]:= |

Out[15]= |

The actual winding number is -1, as seen by inspecting the jumps in the below plot:

In[16]:= |

Out[16]= |

The color wheel can be shifted by a selected amount:

In[17]:= |

Out[17]= |

Only the decimal value affects the hue shift:

In[18]:= |

Out[18]= |

The value of "IterationLength" determines how frequently the Hue value is sampled, as visualized below:

In[19]:= |

Out[19]= |

The options for ParametricPlot are also supported:

In[20]:= |

Out[20]= |

For continuous transformations, any closed curve with a nonzero winding number contains a zero of the transformation:

In[21]:= |

Out[21]= |

If a boundary with nonzero winding number is halved, one half must also have a nonzero winding number:

In[22]:= |

Out[22]= |

Locate the zero by repeatedly decreasing the boundary size, ignoring areas where the winding number is zero:

In[23]:= |

Out[23]= |

In[24]:= |

Out[24]= |

In[25]:= |

Out[25]= |

The resulting boundary after repeating for a total of 10 times:

In[26]:= |

Out[26]= |

The midpoints of the boundaries approach a zero of the transformation:

In[27]:= |

Out[27]= |

Vector plots provide another visualization of 2D transformations:

In[28]:= |

Out[28]= |

Shown together, the similarities between vector plots and domain coloring become apparent:

In[29]:= |

Out[29]= |

Discontinuities may occur in the color winding of a curve passing through a zero of the transformation:

In[30]:= |

Out[30]= |

A similar effect occurs for a curve passing though any asymptotes of the transformation:

In[31]:= |

Out[31]= |

Low values of the "IterationLength" option may produce inaccurate results:

In[32]:= |

Out[32]= |

Increasing the value of PlotPoints improves the resolution of the domain coloring:

In[33]:= |

Out[33]= |

Create neat shapes by overlapping several domain coloring curves:

In[34]:= |

Out[34]= |

Visualize how changing the transformation alters the domain coloring:

In[35]:= |

Out[35]= |

Draw the domain coloring using a collection of triangular boundaries:

In[36]:= |

Out[36]= |

Find the winding number along famous curves:

In[37]:= |

Out[37]= |

In[38]:= |

Out[38]= |

- 2.0.0 – 23 March 2023
- 1.0.0 – 29 August 2022

This work is licensed under a Creative Commons Attribution 4.0 International License