Go to the previous, next section.
#include <nihcl/Point.h>
Instances of class
Point
represent x-y coordinate pairs. By (Smalltalk-80) convention,
Point(0,0)
is the top left corner of the display, with x increasing to the right and y increasing to the bottom.
Point()
Point
initialized to (0,0).
Point(short
newx, short
newy)
Point
initialized to (newx,newy).
short x() const
short y() const
Point
.
short x(short
newx)
short y(short
newy)
Point
to
newx
or
newy, respectively, and returns the new value.
virtual unsigned hash() const
bool operator==(const Point&) const
bool operator!=(const Point&) const
YES
if the left
Point
operand is equal to (or not equal to) the right
Point
operand.
bool operator<(const Point&) const
bool operator<=(const Point&) const
bool operator>(const Point&) const
bool operator>=(const Point&) const
YES
if the relation holds between
both
the x and y coordinates of the operands. For example, point (Ax,Ay) < point (Bx,By) if Ax < Bx
and
Ay < By.
Point operator-() const
Point
with x and y coordinate values opposite in sign from the x and y coordinate values of the operand
Point
. For example,
-Point(1,2)
is (-1,-2).
Point operator+(const Point&) const
Point operator-(const Point&) const
Point
with x and y coordinate values that are the sum or difference of the x and y coordinate values of the operand
Point
s. For example,
Point(1,2) + Point(3,4)
is (4,6).
friend Point operator*(const Point&
p, int
i)
friend Point operator*(int
i, const Point&
p)
Point
p
by the integer
i. For example,
2 * Point(1,2)
is (2,4).
int operator*(const Point&) const
Point
s. For example,
Point(1,2) * Point(3,4)
is 1*3 + 2*4 = 11.
void operator+=(const Point&)
void operator-=(const Point&)
Point
by one that is the sum or difference of the x and y coordinates of this
Point
and those of the right operand
Point
. For example
Point p(1,2); p += Point(3,4); cout << p << endl;
void operator*=(int
s)
Point
by one with the x and y coordinates each multiplied by
s. For example:
Point p(1,2); p *= 10; cout << p << endl;
prints (10,20).
Point max(const Point&
p) const
Point min(const Point&
p) const
Point
whose x coordinate is the larger (smaller) of this
Point
's x coordinate and that of
p
, and whose y coordinate is the larger (smaller) of this
Point
's y coordinate and that of
p
.
virtual int compare(const Object&
ob) const
Point
with the argument object
ob, which must also be an instance of class
Point
. Returns a negative result if this
Point
is less than
ob, zero if this
Point
equals
ob, and a positive result if this
Point
is greater than
ob. One point is considered greater than another if its y coordinate is greater, or if its y coordinate is equal and its x coordinate is greater.
bool isBelow(const Point&
p) const { return yc > p.yc; }
bool isAbove(const Point&
p) const { return yc < p.yc; }
YES
if the y coordinate of this
Point
is greater than (or less than, respectively) the y coordinate of
Point
p.
bool isRight(const Point&
p) const { return xc > p.xc; }
bool isLeft(const Point&
p) const { return xc < p.xc; }
YES
if the x coordinate of this
Point
is greater than (or less than, respectively) the x coordinate of
Point
p.
virtual bool isEqual(const Object&
ob) const
YES
if
ob
is of species
Point
and equals this
Point
.
double dist(const Point&
p) const
Point
and the
Point
p.
Point transpose() const
Point
whose x coordinate is equal to the y coordinate of this
Point
and whose y coordinate is equal to the x coordinate of this
Point
.
virtual void deepenShallowCopy()
Point
.
virtual void printOn(ostream&
strm
=cout) const
Point
on the output stream
strm
in the format (x,y).
virtual const Class* species() const
Point
.
short xc,yc;
Point
.
virtual void storer(OIOofd&
fd) const
virtual void storer(OIOout&
strm) const
Point
on
fd
or
strm.
Go to the previous, next section.