Specify the Polar

Only numbers without units are allowed, list items are to be separated with exactly ',' just for the PHP script. In general there is no good check for nonsense values, take care yourself!

Center:
cx (number):
cy (number):
Corner number, turns and offset, closed?:
n (integer >0):
turns (number):
offset (1-3 numbers):
z (0|1):
radii:
r (list of number):
r1 (list of number):
r2 (list of number):
fractions:
fractions (list of number):
f1 (list of number):
f2 (list of number):
invertor:
i (integer):
ir (number):
painting:
do it!

Polar Element

Describes a graphical element or a symmetry group in polar coordinates, in the following called polar. Simplest useful application is a regular polygon or in general to explore two dimensional discrete rotation groups. Another application is to create a hole inside a regular polygon. Due to the choice of attribute value semantics and the interpretation of not specified attributes, it is possible to create simple objects with only a few attributes or items in an attribute value. More complex objects can be defined using the complete set of attributes and attribute value semantics by advanced authors.

Examples:

 an equilateral triangle with a distance of 100
                 between the center at 0 and the corners of 100.

  simple triangle.

 or

          an equilateral triangle with a distance of 100 between 
          the center at (100,200) and the corners.

 a pentagon.

 a pentagram.

 
          a square hole in a square.

 a simple star.

 or
 a more complex star with intersections.

 or
 or
 
   a simple symmetrical cubic curve.

 or 
 
            a simple flower like symmetrical cubic curves.

 
            a more complex symmetrical cubic curve

]]>

Technical details, attributes:

cx = "<coordinate>"
The x-axis coordinate of the center of the polar. If the attribute is not specified, the effect is as if a value of "0" were specified.

Animatable: yes.

cy = "<coordinate>"
The y-axis coordinate of the center of the polar. If the attribute is not specified, the effect is as if a value of "0" were specified.

Animatable: yes.

n = "<integer>"
The number of corners of the polar. For a negative or zero n the polar is not displayed. For n="1" the polar might degenerate to a point, for n="2" the polar might degenerates to a line with too trivial values for other attributes. If the attribute is not specified, the effect is as if a value of "3" is specified. If accidently not an integer is specified, ceil(n) is taken as value.

Animatable: yes, only discrete animation, not additive.

turns = "<number>"
The number of turns used to arrange the corners. For details see description below. If the attribute is not specified, the effect is as if a value of "1" were specified. Note that for turns="0" the polar degenerates to a line or a point. The sign determines the direction of progress from one corner to the next.

Animatable: yes, not additive or paced.

offset = "<number>"
Angular Offset for rendering. The offset turn relative to the x-axis of the current user coordinate system for the points. One unit of a number equals to a rotation of 360/n degrees. For details see description below. If the attribute is not specified, the effect is as if a value of "0" were specified.

Animatable: yes, not additive or paced.

z = 0|1
Path closed or not. 0 not closed, else closed. If the attribute is not specified, the effect is as if a value of "1" were specified. If something different from 0 or 1 is specified, 1 is assumed.

Animatable: yes, only discrete, not additive or paced.

r = "<list of number>"
List of radii for the related corners of the polar. Radii can be positive, negative or zero. If the number of items is larger than n, the last superfluous items are ignored. If the number of items is less than n, the list is repeated from the beginning. If the attribute is not specified, the effect is as if a value of "0" were specified.

Animatable: yes, not additive or paced. If the number of list items is varied within the animation, the rule for ignoring and repeating list item applies for each animation value.

r1 = "<list of number>"
r2 = "<list of number>"
List of radii for the related control points of the polar. Radii can be positive, negative or zero. If the number of items is larger than n, the last superfluous items are ignored. If the number of items is less than n, the list is repeated from the beginning. If the attribute is not specified, the same radius list as from the attribute r is assumed.

Animatable: yes, not additive or paced. If the number of list items is varied within the animation, the rule for ignoring and repeating list item applies for each animation value.

fractions = "<list of number>"
List of fractional turn deviations for the related corners of the polar. The fraction is taken relative to the angular position of the corner point of a regular polygon. The unit of fractions is 1/n (if n is a positive number, the polar is not displayed). If the number of items is larger than n, the last superfluous items are ignored. If the number of items is less than n, the list is repeated from the beginning. If the attribute is not specified, the effect is as if a value of "0" were specified.

Animatable: yes, not additive or paced. If the number of list items is varied within the animation, the rule for ignoring and repeating list item applies for each animation value.

f1 = "<list of number>"
f2 = "<list of number>"
List of fractional turn deviation for the related control points of the polar. The fraction is taken relative to the angular position to the corner point. The unit of fractions is 1/n (if n is not a positive number, the polar is not displayed). If the number of items is larger than n, the last superfluous items are ignored. If the number of items is less than n, the list is repeated from the beginning. If the attribute is not specified, the same fraction list as from the attribute fractions is assumed.

Animatable: yes, not additive or paced. If the number of list items is varied within the animation, the rule for ignoring and repeating list item applies for each animation value.

i = "<number>"
The number of corners of an additional regular polygon (called invertor). This is intended to be able to create a hole within a shape. For an i smaller than 3 this path fragment is not displayed. If the attribute is not specified, the effect is as if a value of "4" is specified. If accidently not an integer is specified, ceil(i) is taken as value.

Animatable: yes, only discrete animation, not additive.

ir = "<number>"
Radius for the additional invertor. The radius can be positive, negative or zero. If the attribute is not specified, the effect is that this additional path fragment invertor is not displayed. Especially if i is larger than 2 and the absolute value of ir is about 2 times larger than the largest value of the r list, the polar is completely inside this invertor, this means, depending on the fill-rule and the directions of the polar and the invertor the polar can create holes in the invertor.

Animatable: yes, not additive or paced.

How to generate path data for the polar?

First the lists for r and fractions are completed related to the rules for ignoring and repeating list item.

The result are lists r(j), r1(j), r2(j) with j from 0 to n-1 and a list fractions(j), f1(j), f2(j), with j from 0 to n-1.

Note, that the formulas below can be simplified to straight lines (L instead of C with the following cx/y), if none of f1, f2, r1, r2 is specified.

x(j) and y(j) coordinates for each corner j are determined as follows

 Angles:
 o0 = offset*2*Pi/n * turns
 a(j)  = o0 + (j+fractions(j))*2*Pi/n *turns
 b(j)  = o0 + (j+f1(j))*2*Pi/n *turns
 c(j)  = o0 + (j+f2(j))*2*Pi/n *turns
 
 Points:
 x(j) = cx + r(j)*cos(a(j))
 y(j) = cy + r(j)*sin(a(j))
 cx1(j) = cx + r1(j)*cos(b(j))
 cy1(j) = cy + r1(j)*sin(b(j))
 cx2(j) = cx + r2(j)*cos(c(j))
 cy2(j) = cy + r2(j)*sin(c(j)) 
 

Determination of an equivalent path d attribute:

for j=0 to n-1
 
 if (z) {
  if(j==0) {
   path ="M x(j) y(j) C cx1(j) cy1(j) cx2(j) cy2(j) "
  } else { 
   path .="x(j) y(j) cx1(j) cy1(j) cx2(j) cy2(j) "
  }
 } else {
  if ((j==0) AND (n>1)){
   path ="M x(j) y(j) C cx1(j) cy1(j) cx2(j) cy2(j) "
  } else if (j==0) {
   path ="M x(j) y(j)"
  } else if (j <(n-1)) {
   path .="x(j) y(j) cx1(j) cy1(j) cx2(j) cy2(j) "
  } else {
   path .="x(j) y(j) "
  }
 }
   
endfor
 
 if !z
   pd = path
 else
   pd = path . "x(0) y(0)Z"
 endif

Path for the additional path fragment polygon invertor:

 
 a  = j*2*Pi/i
 x(j) = cx + ir*cos(Pi/i - a)
 y(j) = cy + ir*sin(Pi/i - a)
 
 invertor="M x(0) y(0) L"
  for j=1 to i-1
   invertor .="x(j) y(j) "
 endfor
 invertor .="x(0) y(0)Z"

if the invertor is not displayed (ir unspecified or i smaller than 3): value of attribute d = pd else d .= invertor

More typical simple use cases:

a) simple regular polygon, konvex

turns="1" z="1" fractions="1"

cy, cy some useful values r exactly one useful value, for example 100 n some useful value larger than 2

b) simple symmetric polygon, konkav, 'star'

turns="1"
z="1"
fractions="1"

cy, cy, n some useful values r exactly two different values with the same sign n some useful even value larger than 2

c) symmetric polygon, complex 'star' with intersections

turns="1"
z="1"
fractions="1"

cy, cy, n some useful values r exactly two different values with different signs n some useful even value larger than 2

d) regular polygon, possibly with intersections, another kind of 'star'

z="1"
fractions="1"

cy, cy, n some useful values r exactly one value

n some number larger than 4 turns an integer without a common factor with n (turns can be always choosen not bigger than n without any loss of figure types).

e) symmetric polygon, more complex with good combination of n and turns

z="1" fractions="1"

cy, cy, n some useful values
r: k values

n = k * j with j larger than 2, turns an integer without a common factor with n (turns can be always choosen not bigger than n without any loss of figure types).