IGPoint2D
- IGPoint2D represents a point or a vector on a 2-D plane.
The point is defined by an x-coordinate and a y-coordinate. This class provides the basic means
for communicating between transforms and the rest of the 2-D world.
IGPoint2D's components are deliberately public. Note the handy arithmetic operators; these
perform vector arithmetic on the points.
Do not derive your own classes from this class.
IGPoint2D - Member Functions and Data by Group
Constructors & Destructor
Use the constructors and destructor in this group to create or destroy objects of
class IGPoint2 representing a point or a vector on a 2-D plane.
- ~IGPoint2D
public:
~IGPoint2D()
- Destroys the point object of class IGPoint2D.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- IGPoint2D
- Constructs an object of class IGPoint2D that represents a point or a vector on a 2-D plane.
Overload 1
- Constructor that creates a point or a vector on a 2-D plane that uses the coordinates in an IPoint.
public:
IGPoint2D(const IPoint& point)
- Use this constructor to create a point or a vector on a 2-D plane that uses the coordinates in an IPoint.
- point
- A constant reference to the new IPoint to be used.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Overload 2
- Constructor that uses the given coordinates.
public:
IGPoint2D(GCoordinate x, GCoordinate y)
- x
- The x-coordinates to copy from.
- y
- The y-coordinates to copy from.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Overload 3
- Copy constructor.
public:
IGPoint2D(const IGPoint2D&)
- Use this constructor to create a point or a vector on a 2-D plane that is copied from the given one.
- IGPoint2D
- A constant reference to the new IGPoint2D to copy from.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Overload 4
- Default constructor.
public:
IGPoint2D()
- Use this constructor to create an object with default coordinate values of fX=0.0 and fY=0.0
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Assignment Operator
Use the function in this group to assign the given 2D point object to the target point object.
- operator =
public:
IGPoint2D& operator =(const IGPoint2D& Src)
- Assignment operator.
- Src
- The point to be copied.
- Return
- A non-const reference to the left-hand side object.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Computing Values
Use the functions in this group to compute values such as the dot product or the cross product
of the point and the vector argument, or the angle between the vector and the positive x-axis.
- crossProduct
public:
GCoordinate crossProduct(const IGPoint2D& vector) const
- Computes the cross product of the point and the vector argument.
- vector
- The vector whose cross product with this vector is to be computed.
- Return
- (fX * vector.fY) -(vector.fX * fY).
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- dotProduct
public:
GCoordinate dotProduct(const IGPoint2D& vector) const
- Computes the dot product of the point and the vector argument.
- vector
- The vector whose dot product with this vector is to be computed.
- Return
- (fX * vector.fX) + (fY * vector.fY).
- Exception
IGraphicException
| Calls a parameter assert if the index is not 0 or 1.
|
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- vectorAngle
public:
GDegrees vectorAngle() const
- Computes the angle, in degrees, between the vector and the positive x-axis.
- Return
- The angle of the vector with respect to the x-axis (0<=angle<360).
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Data Types
These data types are define for coordinate values.
- fX
- x- coordinates
public:
GCoordinate fX
- The X coordinate value.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- fY
- y- coordinates
public:
GCoordinate fY
- The Y coordinate value.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Modifying a Point
Use the function in this group to
normalize the point, moving it onto the unit circle, preserving its vector angle, and to convert an IGPoint2D to an IPoint.
- normalize
public:
GCoordinate normalize()
- Moves the point onto the unit circle, preserving its vector angle. The new vector length is 1.0.
- Return
- The vector's length before normalization.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- operator IPoint
public:
operator IPoint() const
- Converts an IGPoint2D to an IPoint.
- Return
- The IPoint.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Obtaining a Point's Coordinate Values
Use the functions in this group to obtain the x or y coordinate of the point.
- operator []
- Use the functions in this group to obtain the x or y coordinate of the point.
Overload 1
- Returns the x or y coordinate of a const IGPoint2D.
public:
const GCoordinate& operator [](unsigned long index) const
- index
- 0 for the x-coordinate, 1 for the y-coordinate.
- Return
- The specified coordinate.
- Exception
IGraphicException
| Calls a parameter assert if the index is not 0 or 1.
|
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Overload 2
- Returns the x or y coordinate, depending on the index.
public:
GCoordinate& operator [](unsigned long index)
- index
- 0 for the x-coordinate, 1 for the y-coordinate.
- Return
- The specified coordinate.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Obtaining Information About One or Two Points
Use the functions in this group to
obtain information about points, such as the reflection of the point across the origin, whether the
point's coordinates are the same as or different from those of the given point, the origin point, the distance of the
point from the origin, and the infinity point. You can also use a function in this group to
linearly interpolate between two points or extrapolate beyond them.
- infinite
public:
static const IGPoint2D& infinite()
- Returns the infinity point (kInfinity, kInfinity).
- Return
- A reference to the IGPoint2D representing the infinity.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- interpolate
public:
IGPoint2D
interpolate( const IGPoint2D& dest,
GParametric u ) const
- Linearly interpolates between two points (or extrapolates beyond them).
- dest
- A constant reference to the other point, corresponding to u=1.0.
- u
- Any value, where 0.0=this point and 1.0=dest.
- Return
- The interpolated point.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- operator !=
public:
bool operator !=(const IGPoint2D& Src) const
- Tests whether the point's coordinates differ from those of the argument.
- Src
- A constant reference to the object whose coordinates are compared to.
- Return
- Returns true if fX does not equal Src's x-coordinate or fY does not equal Src's y-coordinate.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- operator -
public:
IGPoint2D operator -() const
- Returns the reflection of the point across the origin with coordinates (-fX,-fY).
- Return
- An IGPoint2D with coordinates (-fX,-fY).
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- operator ==
public:
bool operator ==(const IGPoint2D& Src) const
- Tests whether the point's coordinates equal those of the argument.
- Src
- A constant reference to the object whose coordinates are compared to.
- Return
- Returns true if fX and fY are identical to Src's x- and y-coordinates, respectively.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- origin
public:
static const IGPoint2D& origin()
- Returns the origin point (0.0, 0.0).
- Return
- A reference to the IGPoint2D representing the origin.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- vectorLength
public:
GCoordinate vectorLength() const
- Returns the distance of the point from the origin.
- Return
- The length of the vector: sqrt(fX*fX+fY*fY).
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Operators
Use the operators in this group to multiply, divide, add, or subtract the point by the given value.
- operator *=
- Multiplies the IGPoint2D by the given argument.
Overload 1
- Multiplies the IGPoint2D by the scalar argument.
public:
IGPoint2D& operator *=(const GCoordinate Src)
- Src
- The scalar by which to multiply the IGPoint2D.
- Return
- The IGPoint2D after multiplication by the argument.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Overload 2
- Multiplies the IGPoint2D by the vector argument.
public:
IGPoint2D& operator *=(const IGPoint2D& Src)
- Src
- The vector by which to multiply the IGPoint2D.
- Return
- The IGPoint2D after multiplication by the argument.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- operator +=
public:
IGPoint2D& operator +=(const IGPoint2D& Src)
- Adds the vector specified by the argument to the IGPoint2D.
- Src
- The vector to be added.
- Return
- The IGPoint2D after the vector argument has been added.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- operator -=
public:
IGPoint2D& operator -=(const IGPoint2D& Src)
- Subtracts the vector specified by the argument from the IGPoint2D.
- Src
- The vector by which to subtract the IGPoint2D.
- Return
- The IGPoint2D after subtraction by the argument.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- operator /=
- Divides the IGPoint2D by the given argument.
Overload 1
- Divides the IGPoint2D by the vector argument.
public:
IGPoint2D& operator /=(const IGPoint2D& Src)
- Src
- The vector by which to divide the IGPoint2D.
- Return
- The IGPoint2D after division by the argument.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Overload 2
- Divides the IGPoint2D by the scalar argument.
public:
IGPoint2D& operator /=(const GCoordinate Src)
- Src
- The scalar by which to divide the IGPoint2D.
- Return
- The IGPoint2D after division by the argument.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Setting a Point's or Vector's Values
Use the functions in this group to set the points point's position using vector angle and vector length, set the
vector angle without changing the vector length, and to set the distance of the point from the origin,
without changing the vector angle.
- setPolarCoordinates
public:
void
setPolarCoordinates( GDegrees angle,
GCoordinate length = 1.0 )
- Sets the point's position using polar coordinates (vector angle and vector length).
- angle
- The new vector angle, in degrees.
- length
- The new vector length. By default, length is set to 1.0.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- setVectorAngle
public:
void setVectorAngle(GDegrees angle)
- Sets the vector angle without changing the vector length.
- angle
- The new vector angle, in degrees. Angles are measured relative to the positive portion of the x-axis.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- setVectorLength
public:
void setVectorLength(GCoordinate length)
- Sets the distance of the point from the origin, without changing the vector angle.
- length
- The new length of the vector.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Streaming an Object In and Out
Use the functions and operators in this group to stream the 2D point object in and out.
- operator <<=
public:
IDataStream& operator <<=(IDataStream&)
- Operator that streams the point object in using the given polymorphic stream.
- IDataStream
- The polymorphic stream used to stream the object in.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- operator >>=
public:
IDataStream& operator >>=(IDataStream&) const
- Operator that streams the point object out using the given polymorphic stream.
- IDataStream
- The polymorphic stream used to stream the object out.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- readFromStream
public:
void readFromStream(IDataStream& toWhere)
- Streams the point object in from the polymorphic streaming specified by fromWhere.
- fromWhere
- The stream used to stream in the point object.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- writeToStream
public:
void writeToStream(IDataStream& toWhere) const
- Streams the point object out to the polymorphic streaming specified by toWhere.
- toWhere
- The polymorphic stream used to stream out the object, in this case, a point object.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
IGPoint2D - Inherited Member Functions and Data
Inherited Public Functions
Inherited Public Data
Inherited Protected Functions
Inherited Protected Data