IPoint2 Class Reference

#include <ipoint2.h>

Class Description

See also
Class Point2.

Description:
This class describes a 2D point using int x and y coordinates. Methods are provided to add and subtract points, multiply and divide by scalars, normalize and compute the dot product of two IPoint2s. All methods are implemented by the system.
Data Members:
int x,y;
+ Inheritance diagram for IPoint2:

Public Member Functions

 IPoint2 ()
 Initializes all vector components to zero. More...
 
 IPoint2 (int X, int Y)
 
 IPoint2 (const IPoint2 &a)
 
 IPoint2 (int af[2])
 
intoperator[] (int i)
 
const intoperator[] (int i) const
 
 operator int * ()
 
IPoint2 operator- () const
 
IPoint2 operator+ () const
 
IPoint2operator-= (const IPoint2 &)
 
IPoint2operator+= (const IPoint2 &)
 
IPoint2operator*= (const IPoint2 &)
 Member-wise, in-place multiplication of this vector: (x*x, y*y) More...
 
IPoint2operator*= (int)
 
IPoint2operator/= (int)
 
IPoint2 operator- (const IPoint2 &) const
 
IPoint2 operator+ (const IPoint2 &) const
 
int DotProd (const IPoint2 &) const
 
IPoint2 operator* (const IPoint2 &) const
 Member-wise multiplication of two vectors: (x*x, y*y) More...
 
int operator== (const IPoint2 &p) const
 
int operator!= (const IPoint2 &p) const
 

Public Attributes

int x
 
int y
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 

Constructor & Destructor Documentation

IPoint2 ( )
inline

Initializes all vector components to zero.

39 : x(0), y(0) {}
int y
Definition: ipoint2.h:36
int x
Definition: ipoint2.h:36
IPoint2 ( int  X,
int  Y 
)
inline
Remarks
Constructor. Data members are initialized to X and Y.
41 { x = X; y = Y; }
int y
Definition: ipoint2.h:36
int x
Definition: ipoint2.h:36
IPoint2 ( const IPoint2 a)
inline
Remarks
Constructor. Data members are initialized to a.x and a.y.
43 { x = a.x; y = a.y; }
int y
Definition: ipoint2.h:36
int x
Definition: ipoint2.h:36
IPoint2 ( int  af[2])
inline
Remarks
Constructor. Data members are initialized as x = af[0] and y = af[1].
46 { x = af[0]; y = af[1]; }
int y
Definition: ipoint2.h:36
int x
Definition: ipoint2.h:36

Member Function Documentation

int& operator[] ( int  i)
inline
Remarks
Allows access to x, y using the subscript operator.
Returns
An index of 0 will return x, 1 will return y.
51 { DbgAssert((i == 0) || (i == 1)); return (&x)[i]; }
#define DbgAssert(expr)
Definition: assert1.h:72
int x
Definition: ipoint2.h:36
const int& operator[] ( int  i) const
inline
Remarks
Allows access to x, y using the subscript operator.
Returns
An index of 0 will return x, 1 will return y.
54 { DbgAssert((i == 0) || (i == 1)); return (&x)[i]; }
#define DbgAssert(expr)
Definition: assert1.h:72
int x
Definition: ipoint2.h:36
operator int * ( )
inline
Remarks
Returns the address of the IPoint2.x.
58 { return(&x); }
int x
Definition: ipoint2.h:36
IPoint2 operator- ( ) const
inline
Remarks
Unary -. Negates both x and y.
62 { return(IPoint2(-x,-y)); }
int y
Definition: ipoint2.h:36
int x
Definition: ipoint2.h:36
IPoint2()
Initializes all vector components to zero.
Definition: ipoint2.h:39
IPoint2 operator+ ( ) const
inline
Remarks
Unary +. Returns the Ipoint2 unaltered.
64 { return *this; }
IPoint2 & operator-= ( const IPoint2 a)
inline
Remarks
Subtracts a IPoint2 from this IPoint2.
128  {
129  x -= a.x; y -= a.y;
130  return *this;
131  }
int y
Definition: ipoint2.h:36
int x
Definition: ipoint2.h:36
IPoint2 & operator+= ( const IPoint2 a)
inline
Remarks
Adds a IPoint2 to this IPoint2.
133  {
134  x += a.x; y += a.y;
135  return *this;
136  }
int y
Definition: ipoint2.h:36
int x
Definition: ipoint2.h:36
IPoint2 & operator*= ( const IPoint2 rhs)
inline

Member-wise, in-place multiplication of this vector: (x*x, y*y)

139 {
140  x *= rhs.x;
141  y *= rhs.y;
142  return *this;
143 }
int y
Definition: ipoint2.h:36
int x
Definition: ipoint2.h:36
IPoint2 & operator*= ( int  f)
inline
Remarks
Multiplies this IPoint2 by an integer value.
145  {
146  x *= f; y *= f;
147  return *this;
148  }
int y
Definition: ipoint2.h:36
int x
Definition: ipoint2.h:36
IPoint2 & operator/= ( int  f)
inline
Remarks
Divides this IPoint2 by an integer value.
150  {
151  x /= f; y /= f;
152  return *this;
153  }
int y
Definition: ipoint2.h:36
int x
Definition: ipoint2.h:36
IPoint2 operator- ( const IPoint2 b) const
inline
Remarks
Subtracts a IPoint2 from a IPoint2.
155  {
156  return(IPoint2(x-b.x,y-b.y));
157  }
int y
Definition: ipoint2.h:36
int x
Definition: ipoint2.h:36
IPoint2()
Initializes all vector components to zero.
Definition: ipoint2.h:39
IPoint2 operator+ ( const IPoint2 b) const
inline
Remarks
Adds a IPoint2 to a IPoint2.
159  {
160  return(IPoint2(x+b.x,y+b.y));
161  }
int y
Definition: ipoint2.h:36
int x
Definition: ipoint2.h:36
IPoint2()
Initializes all vector components to zero.
Definition: ipoint2.h:39
int DotProd ( const IPoint2 b) const
inline
Remarks
Returns the dot product of two IPoint2's. This is the sum of both x values multiplied together and both y values multiplied together.
Operators:
163  {
164  return(x*b.x+y*b.y);
165  }
int y
Definition: ipoint2.h:36
int x
Definition: ipoint2.h:36
IPoint2 operator* ( const IPoint2 b) const
inline

Member-wise multiplication of two vectors: (x*x, y*y)

167  {
168  return IPoint2(x * b.x, y * b.y);
169  }
int y
Definition: ipoint2.h:36
int x
Definition: ipoint2.h:36
IPoint2()
Initializes all vector components to zero.
Definition: ipoint2.h:39
int operator== ( const IPoint2 p) const
inline
Remarks
Equality operator. Compare two IPoint2's.
Returns
Nonzero if the IPoint2's are equal; otherwise 0.

95 { return (x == p.x && y == p.y); }
int y
Definition: ipoint2.h:36
int x
Definition: ipoint2.h:36
int operator!= ( const IPoint2 p) const
inline
96 { return (x != p.x || y != p.y); }
int y
Definition: ipoint2.h:36
int x
Definition: ipoint2.h:36

Member Data Documentation

int x
int y