Class: TGPoint

Declaration: BaseGeometry.h

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.

Member Function: TGPoint::TGPoint

  1. TGPoint ()
  2. TGPoint (GCoordinate x, GCoordinate y)
  3. TGPoint (const TGPoint &)

Interface Category:

API.

Purpose:

  1. Default constructor. The member variables are not initialized.
  2. Creates a TGPoint by initializing fX and fY to the specified coordinates.
  3. Copy constructor.

Calling Context:

  1. Creates a point without initializing the member variables.
  2. Creates a point with the specified coordinates.
  3. Called to copy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TGPoint::~TGPoint

~ 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:

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:

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*=

  1. TGPoint & operator *= (const TGPoint & Src)
  2. TGPoint & operator *= (const GCoordinate Src)

Interface Category:

API.

Purpose:

  1. Multiplies the TGPoint by the vector argument. (fX is multiplied by Src.fX, and fY by Src.fY.)
  2. Multiplies the TGPoint by the scalar argument. (Both coordinates are multiplied by the argument.)

Calling Context:

  1. Called to scale a point preceding a *= sign.
  2. Called to scale a point preceding a *= sign.
  3. Call this function directly.

Parameters:

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/=

  1. TGPoint & operator /= (const TGPoint & Src)
  2. TGPoint & operator /= (const GCoordinate Src)

Interface Category:

API.

Purpose:

  1. Divides the TGPoint by the vector argument. (fX is divided by Src.fX, and fY by Src.fY.)
  2. Divides the TGPoint by the argument's value. (Both coordinates are divided by the argument.)

Calling Context:

  1. Called to scale a point preceding a /= sign.
  2. Called to scale a point preceding a /= sign.
  3. Call this function directly.

Parameters:

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:

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:

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:

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:

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:

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[]

  1. GCoordinate & operator [] (unsigned long index)
  2. const GCoordinate & operator [] (unsigned long index) const

Interface Category:

API.

Purpose:

  1. Returns the x- or y-coordinate, depending on the index.
  2. Returns the x- or y-coordinate of a const TGPoint.

Calling Context:

  1. Called to retrieve a coordinate of the TGPoint preceding the [ symbol.
  2. Called to retrieve a coordinate of the const TGPoint preceding the [ symbol.
  3. Call this function directly.

Parameters:

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:

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:

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:

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:

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:

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:

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.