## PgmCommon

PgmCommon — Various functions used for common tasks.

## Synopsis

    #include <pgm/pgm.h>

    #define             PGM_DEGREES_TO_RADIANS              (theta)
    #define             PGM_RADIANS_TO_DEGREES              (theta)
    #define             PGM_SINCOS                          (theta,s,c)
    #define             PGM_FABSF                           (x)
    gint32              pgm_lrintf                          (gfloat x);
    enum                PgmError;

## Description

Various functions used by Pigment for common tasks.

Last reviewed on 2009-05-07 (0.3.16)

## Details

### PGM_DEGREES_TO_RADIANS()

    #define PGM_DEGREES_TO_RADIANS(theta) ((theta) * (G_PI / 180.0f))

Converts from degrees to radians.

`theta` : | an angle in degrees.

### PGM_RADIANS_TO_DEGREES()

    #define PGM_RADIANS_TO_DEGREES(theta) ((theta) * (180.0f / G_PI))

Converts from radians to degrees.

`theta` : | an angle in radians.

### PGM_SINCOS()

    #define             PGM_SINCOS(theta,s,c)

Calculates sine and cosine of the angle `theta` simultaneously.

`theta` : | a float representing an angle in radians.
`s` : | the address of the float where the sine value is going to be stored.
`c` : | the address of the float where the cosine value is going to be stored.

### PGM_FABSF()

    #define             PGM_FABSF(x)

Calculates the absolute value of float.

`x` : | the floating-point number.

### pgm_lrintf ()

    gint32              pgm_lrintf                          (gfloat x);

Round `x` to nearest integer using the current FPU rounding mode. On platforms other than Windows where the C99 lrintf function is not available, the function reverts to a float-to-int cast which uses the truncate FPU rounding mode.

`x` : | the input floating-point number.
Returns : | the rounded nearest integer.

### enum PgmError

    typedef enum {
      PGM_ERROR_X,
      PGM_ERROR_OK
    } PgmError;

Every Pigment method returns an error code from that list.

`PGM_ERROR_X` | Generic error code.
`PGM_ERROR_OK` | No error occured.