PTARITH(3R)

NAME
ptarith: add, sub, mul, div - arithmetic on Points

SYNOPSIS
#include <dmd.h>

Point add (p, q)

Point sub (p, q)

Point mul (p, a)

Point div (p, a)

Point p, q;
int a;

DESCRIPTION
The add function returns the Point sum of its arguments:

{ p.x+q.x, p.y+q.y }

The sub function returns the Point difference of its arguments:

{ p.x-q.x, p.y-q.y }

The mul function returns the Point:

{ p.x*a, p.y*a }

The div function returns the Point:

{ p.x/a, p.y/a }.

EXAMPLE
The following routine returns the center Point of a window.

    #include <dmd.h>
    Point add();
    Point sub();
    Point div();
    Point
    getcenter()
    {
        Point offset;
        offset = div (sub
            (Drect.corner,Drect.origin), 2);
        return add (Drect.origin, offset);
    }

SEE ALSO
globals(3R), rectarith(3R), transform(3R/3L).