next up previous contents index
Next: Integer Line Segments ( Up: Simple Geometry Previous: Simple Geometry   Contents   Index


Integer Points ( IPoint )

Definition

An instance ip of type IPoint is a point (a, b), where a and b are integers. We call a the x-coordinate of ip and b the y-coordinate of ip.

#include < AGD/IPoint.h >

Creation

IPoint ip creates an instance ip of type IPoint initialized to the point (0, 0).

IPoint ip(int x, int y) creates an instance ip of type IPoint initialized to the point (x, y).

IPoint ip(const IPoint& p) creates an instance ip of type IPoint initialized to the point p.

Operations

int ip.xcoord() returns the x-coordinate of ip.

int ip.ycoord() returns the y-coordinate of ip.

void ip.xcoord(int x) sets the x-coordinate of ip to x.

void ip.ycoord(int y) sets the y-coordinate of ip to y.

IPoint& ip.inc_x(int dx) increments the x-coordinate of ip by dx. Returns a reference to ip.

IPoint& ip.inc_y(int dy) increments the y-coordinate of ip by dy. Returns a reference to ip.

bool ip == const IPoint& p Test for equality.

bool ip != const IPoint& p Test for inequality.

IPoint ip + const IPoint& ip1 returns the addition (of coordinates).

IPoint ip - const IPoint& ip1 returns the subtraction (of coordinates).

IPoint& ip += const IPoint& ip1 adds ip1 to ip. Returns a reference to ip.

IPoint& ip -= const IPoint& ip1 subtracts ip1 from ip. Returns a reference to ip.

IPoint int x * const IPoint& ip returns the multiplication of dp with the scalar x.

ostream& ostream& O << const IPoint& ip
    writes ip to output stream O.

istream& istream& I >> IPoint& ip reads the coordinates of ip (two int numbers) from input stream I.


next up previous contents index
Next: Integer Line Segments ( Up: Simple Geometry Previous: Simple Geometry   Contents   Index

© Copyright 1998-2001, Algorithmic Solutions Software GmbH. All rights reserved.
2001-08-13