Taxonomy Categories:
Member Functions:
Interface Category:
API.
Inherits From:
None.
Inherited By:
None.
Purpose:
The TGPoint class represents a point on a 2-D plane. The point is defined by an x-coordinate and a y-coordinate, which (for efficiency) are public member variables. A TGPoint can also be interpreted as a vector from the origin (0,0) to the point (x,y). The class supplies a number of operators for vector arithmetic. TGPoint is defined in Geometry.h because TGPoint provides the basic means for communicating between transforms and the rest of the 2-D world.
Instantiation:
Allocate on the heap or the stack.
Deriving Classes:
Do not derive any classes from TGPoint: All TGPoint's data is public, and its destructor is not virtual.
Concurrency:
Not multithread safe.
Resource Use:
No special requirements.
- TGPoint ()
- TGPoint (GCoordinate x, GCoordinate y)
- TGPoint (const TGPoint &)
Interface Category:
API.
Purpose:
- Default constructor. The member variables are not initialized.
- Creates a TGPoint by initializing fX and fY to the specified coordinates.
- Copy constructor.
Calling Context:
- Creates a point without initializing the member variables.
- Creates a point with the specified coordinates.
- Called to copy an object.
Parameters:
- Takes no parameters.
- GCoordinate x -The new x-coordinate.
- GCoordinate y -The new y-coordinate.
- const TGPoint & -The TGPoint to be copied.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
~ TGPoint ()
Interface Category:
API.
Purpose:
Destructor.
Calling Context:
Called to destroy an object.
Parameters:
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TGPoint::operator-
TGPoint operator -() const
Interface Category:
API.
Purpose:
Returns the reflection of the point across the origin with coordinates (-fX,-fY).
Calling Context:
Called to negate a point following a minus symbol.
Call this function directly.
Parameters:
Return Value:
A TGPoint with coordinates (-fX,-fY).
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TGPoint::operator+=
TGPoint & operator += (const TGPoint & Src)
Interface Category:
API.
Purpose:
Adds the vector specified by the argument to the TGPoint.
Calling Context:
Called to increment the point preceding the += sign.
Call this function directly.
Parameters:
Parameters:
- const TGPoint & Src -The vector to be added.
Return Value:
The TGPoint after the vector argument has been added.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TGPoint::operator-=
TGPoint & operator -=(const TGPoint & Src)
Interface Category:
API.
Purpose:
Subtracts the vector specified by the argument from the TGPoint.
Calling Context:
Called to decrement the point preceding the -=sign.
Call this function directly.
Parameters:
- const TGPoint & Src -The vector to be subtracted.
Return Value:
The TGPoint after the vector argument has been subtracted.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TGPoint::operator*=
- TGPoint & operator *= (const TGPoint & Src)
- TGPoint & operator *= (const GCoordinate Src)
Interface Category:
API.
Purpose:
- Multiplies the TGPoint by the vector argument. (fX is multiplied by Src.fX, and fY by Src.fY.)
- Multiplies the TGPoint by the scalar argument. (Both coordinates are multiplied by the argument.)
Calling Context:
- Called to scale a point preceding a *= sign.
- Called to scale a point preceding a *= sign.
Call this function directly.
Parameters:
- const TGPoint & Src -The vector by which to multiply the TGPoint.
- const GCoordinate Src -A scalar value.
Return Value:
The TGPoint after multiplication by the argument.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TGPoint::operator/=
- TGPoint & operator /= (const TGPoint & Src)
- TGPoint & operator /= (const GCoordinate Src)
Interface Category:
API.
Purpose:
- Divides the TGPoint by the vector argument. (fX is divided by Src.fX, and fY by Src.fY.)
- Divides the TGPoint by the argument's value. (Both coordinates are divided by the argument.)
Calling Context:
- Called to scale a point preceding a /= sign.
- Called to scale a point preceding a /= sign.
Call this function directly.
Parameters:
- const TGPoint & Src -The vector by which to divide the TGPoint.
- const GCoordinate Src -The value by which to divide fX and fY.
Return Value:
The TGPoint after division by the argument.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TGPoint::operator=
TGPoint & operator =(const TGPoint & Src)
Interface Category:
API.
Purpose:
Assignment operator.
Calling Context:
Called when an object is assigned to another compatible object.
Call this function directly.
Parameters:
- const TGPoint & Src -The point to be copied.
Return Value:
A non-const reference to the left-hand side object.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TGPoint::operator==
bool operator ==(const TGPoint & Src) const
Interface Category:
API.
Purpose:
Tests whether the point's coordinates equal those of the argument.
Calling Context:
Called to test equivalence of two objects.
Call this function directly.
Parameters:
- const TGPoint & Src -The object whose coordinates are compared to this object's coordinates.
Return Value:
Returns true if fX and fY are identical to Src's x- and y-coordinates, respectively.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TGPoint::operator!=
bool operator != (const TGPoint & Src) const
Interface Category:
API.
Purpose:
Tests whether the point's coordinates differ from those of the argument.
Calling Context:
Called to test equivalence of two objects.
Call this function directly.
Parameters:
- const TGPoint & Src -The object whose coordinates are compared to this object's coordinates.
Return Value:
Returns true if fX does not equal Src's x-coordinate or fY does not equal Src's y-coordinate.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TGPoint::operator<<=
TStream & operator <<= (TStream & fromwhere)
Interface Category:
API.
Purpose:
Stream-in operator.
Calling Context:
Called to stream in data.
Call this function directly.
Parameters:
- TStream & fromwhere -The stream from which the object streams itself in.
Return Value:
Returns a reference to the stream the object streams itself in from.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TGPoint::operator>>=
TStream & operator >>=(TStream & towhere) const
Interface Category:
API.
Purpose:
Stream-out operator.
Calling Context:
Called to stream out data.
Call this function directly.
Parameters:
- TStream & towhere -The stream to which the object streams itself.
Return Value:
Returns a reference to the stream the object streams itself out to.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TGPoint::operator[]
- GCoordinate & operator [] (unsigned long index)
- const GCoordinate & operator [] (unsigned long index) const
Interface Category:
API.
Purpose:
- Returns the x- or y-coordinate, depending on the index.
- Returns the x- or y-coordinate of a const TGPoint.
Calling Context:
- Called to retrieve a coordinate of the TGPoint preceding the [ symbol.
- Called to retrieve a coordinate of the const TGPoint preceding the [ symbol.
Call this function directly.
Parameters:
- unsigned long index -0 for the x-coordinate, 1 for the y-coordinate.
- unsigned long index -0 for the x-coordinate, 1 for the y-coordinate.
Return Value:
The specified coordinate.
Exceptions:
Calls a parameter assert if the index is neither 0 nor 1.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TGPoint::DotProduct
GCoordinate DotProduct (const TGPoint & vector) const
Interface Category:
API.
Purpose:
Computes the dot product of the point and the vector argument.
Calling Context:
Call this function directly.
Parameters:
- const TGPoint & vector -The vector whose dot product with this vector is to be computed.
Return Value:
(fX * vector.fX) + (fY * vector.fY).
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TGPoint::CrossProduct
GCoordinate CrossProduct (const TGPoint & vector) const
Interface Category:
API.
Purpose:
Computes the cross product of the point and the vector argument.
Calling Context:
Call this function directly.
Parameters:
- const TGPoint & vector -The vector whose cross product with this vector is to be computed.
Return Value:
(fX * vector.fY) -(vector.fX * fY).
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TGPoint::Interpolate
TGPoint Interpolate (const TGPoint & dest, GParametric u) const
Interface Category:
API.
Purpose:
Linearly interpolates between two points (or extrapolates beyond them).
Calling Context:
Call this function directly.
Parameters:
- const TGPoint & dest -The other point, corresponding to u =1.0.
- GParametric u -Any value, where 0.0 =this point and 1.0 =dest. Values less than 0 or greater than 1 create an extrapolation along the line running through dest and this point.
Return Value:
The interpolated point.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TGPoint::VectorLength
GCoordinate VectorLength () const
Interface Category:
API.
Purpose:
Returns the distance of the point from the origin.
Calling Context:
Call this function directly.
Parameters:
Return Value:
The length of the vector.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TGPoint::Normalize
GCoordinate Normalize ()
Interface Category:
API.
Purpose:
Moves the point onto the unit circle, preserving its vector angle. The new vector length is 1.0.
Calling Context:
Call this function directly.
Parameters:
Return Value:
The vector's length before normalization.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TGPoint::VectorAngle
GDegrees VectorAngle () const
Interface Category:
API.
Purpose:
Computes the angle (in degrees) between the vector and the x-axis.
Calling Context:
Call this function directly.
Parameters:
Return Value:
The angle of the vector with respect to the x-axis (0 <= angle < 360).
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TGPoint::SetVectorLength
void SetVectorLength (GCoordinate length)
Interface Category:
API.
Purpose:
Sets the distance of the point from the origin, without changing the vector angle.
Calling Context:
Call this function directly.
Parameters:
- GCoordinate length -The new length of the vector.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TGPoint::SetVectorAngle
void SetVectorAngle (GDegrees angle)
Interface Category:
API.
Purpose:
Sets the vector angle without changing the vector length.
Calling Context:
Call this function directly.
Parameters:
- GDegrees angle -The new vector angle, in degrees. Angles are measured relative to the positive portion of the x-axis.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TGPoint::SetPolarCoordinates
void SetPolarCoordinates (GDegrees angle, GCoordinate length =1.0)
Interface Category:
API.
Purpose:
Sets the point's position using polar coordinates (vector angle and vector length).
Calling Context:
Call this function directly. Also called by other TGPoint member functions.
Parameters:
- GDegrees angle -The new angle, in degrees.
- GCoordinate length =1.0 -The new vector length.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.