fc2d

Syntax

double fc2d(double x, double y)

Arguments

x
A double-precision floating-point pixel x-coordinate.
y
A double-precision floating-point pixel y-coordinate.

Return

A double-precision floating-point value in the range -511 to 512.

Description

Pixels are usually addressed by their cartesian coordinates [x,y], but FilterMeister also allows the use of polar coordinates, and provides a set of functions for conversion between the two systems. Polar coordinates are expressed as [d,m], where 'd' represents the 'direction' to the pixel from the origin [0,0], and 'm' is the 'magnitude' of the distance from the origin. The c2d() function returns the polar coordinate direction 'd' for the pixel at [x,y], relative to the top left corner of the image. A 'd' value of 0 represents the direction to the right along the x-axis (ie y=0); a value of 256 represents the direction downward along the y-axis (ie x=0); a value of 512 represents the direction to the left along the x-axis (where y=0); and a value of -256 represents the upward direction on the y-axis (where x=0). Naturally, intermediate values represent the intermediate angles.

Comment

Note that there is a bug in fc2d, so that it doesn't give exactly the same results as c2d.

Example

%ffp

ForEveryTile: {

  for (y=y_start; y < y_end; ++y) {
    for (x=x_start; x < x_end; ++x) {
      for (z=0; z < Z; ++z) {
        double a = (double)x - (double)X / 2.0;
        double b = (double)y - (double)Y / 2.0;
        double result = 256.0 * fabs(fc2d(a, b)) / 512.0;
        pset(x, y, z, (int)result );
      }
    }
  }

  return true;
}

See Also

c2m, fc2m, r2x, r2y