Class: TGPoint3D

Declaration: Geometry3D.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

None.

Inherited By:

None.

Purpose:

The TGPoint3D class represents a point in a 3-D space. The point is defined by x-, y-, and z-coordinates, which (for efficiency) are public member variables. A TGPoint3D can also be interpreted as a vector from the origin (0,0,0) to the point (x,y,z). Like the 2-D class TGPoint, TGPoint3D is a primitive type, and is not intended to have derived classes. TGPoint3D is used as a basic building block for most of the 3-D geometric primitives, and as a computational type for performing many sorts of geometric calculations. TGPoint3Ds are treated much like numbers, having the typical operators +, -, *, and / for vector arithmetic, as well as +=, -=, *=, /=, ==, !=, and []. For example, given three TGPoint3Ds a, b, and c, the statement c = a + b; is equivalent to: c.fX =a.fX + b.fX; c.fY =a.fY + b.fY; c.fZ =a.fZ + b.fZ; The [] operator indexes the components. In other words, for a TGPoint3D object called p, p[0] returns p.fX, p[1] returns p.fY, and p[2] returns p.fZ.

Instantiation:

Allocate on the heap or the stack.

Deriving Classes:

Don't derive any classes from TGPoint3D: All TGPoint3D's data is public, and its destructor is not virtual.

Concurrency:

Not multithread safe.

Resource Use:

No special requirements.

Member Function: TGPoint3D::TGPoint3D

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

Interface Category:

API.

Purpose:

  1. Default constructor.
  2. Creates a point with the three specified coordinates.
  3. Copy constructor.

Calling Context:

  1. Called by the stream-in operators. You can also call it directly. (Because the member variables are public, you can call the default constructor and later assign values to the coordinates.)
  2. Call this directly.
  3. Called to copy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

These are inline functions.

Member Function: TGPoint3D::operator-

TGPoint3D operator -() const

Interface Category:

API.

Purpose:

Creates the additive inverse of this point (its reflection across all three axes).

Calling Context:

Called when a minus sign precedes a TGPoint3D in an expression.

Parameters:

Return Value:

Returns a new point at (-fX,-fY,-fZ).

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TGPoint3D::operator+=

const TGPoint3D & operator += (const TGPoint3D & Src)

Interface Category:

API.

Purpose:

Increments a point by a vector.

Calling Context:

Call this function by using the operator in an assignment statement.

Parameters:

Return Value:

Returns this point, after the vector has been added to it.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TGPoint3D::operator-=

const TGPoint3D & operator -=(const TGPoint3D & Src)

Interface Category:

API.

Purpose:

Decrements a point by a vector.

Calling Context:

Call this function by using the operator in an assignment statement.

Parameters:

Return Value:

Returns this point, after the vector has been subtracted from it.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TGPoint3D::operator*=

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

Interface Category:

API.

Purpose:

  1. Multiplies each of the point's three coordinates by the corresponding coordinates of the TGPoint3D parameter.
  2. Multiplies each of the point's three coordinates by the scalar parameter.

Calling Context:

  1. Call this function by using the operator in an assignment statement.
  2. Call this function by using the operator in an assignment statement.

Parameters:

Return Value:

Returns this point, after it has been multiplied by the vector or scalar.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TGPoint3D::operator/=

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

Interface Category:

API.

Purpose:

  1. Divides each of the point's three coordinates by the corresponding coordinates of the TGPoint3D parameter.
  2. Divides each of the point's three coordinates by the scalar parameter.

Calling Context:

  1. Call this function by using the operator in an assignment statement.
  2. Call this function by using the operator in an assignment statement.

Parameters:

Return Value:

Returns this point, after it has been divided by the vector or scalar.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TGPoint3D::operator[]

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

Interface Category:

API.

Purpose:

  1. Returns one of the coordinates of the point (fX, fY, or fZ).
  2. Returns one of the coordinates of the point (fX, fY, or fZ).

Calling Context:

  1. Call this function by using the operator in an expression.
  2. Call this function by using the operator in an expression.

Parameters:

Return Value:

Returns the x-, y-, or z-coordinate.

Exceptions:

Invokes a parameter assert if the index is not 0, 1, or 2.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TGPoint3D::operator==

bool operator ==(const TGPoint3D & Src) const

Interface Category:

API.

Purpose:

Tests two points for equality.

Calling Context:

Call this function by using the operator in an expression.

Parameters:

Return Value:

Returns true if all three coordinates of one point are equal to the corresponding coordinates of the other point.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This is an inline function.

Member Function: TGPoint3D::operator!=

bool operator != (const TGPoint3D & Src) const

Interface Category:

API.

Purpose:

Tests two points for inequality.

Calling Context:

Call this function by using the operator in an expression.

Parameters:

Return Value:

Returns true if any coordinate of one point is different from the corresponding coordinate of the other point.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This is an inline function.

Member Function: TGPoint3D::DotProduct

GCoordinate DotProduct (const TGPoint3D & vector2) const

Interface Category:

API.

Purpose:

Computes the dot product of two vectors. The dot product is x1*x2 + y1*y2 + z1*z2 (where 1 and 2 represent subscripts indicating whether the subscripted coordinate belongs to the first vector or the second vector).

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the dot product.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TGPoint3D::CrossProduct

TGPoint3D CrossProduct (const TGPoint3D & vector2) const

Interface Category:

API.

Purpose:

Computes the cross product of two vectors. The cross product is a vector whose x-coordinate is y1*z2 -y2*z1, whose y-coordinate is x2*z1 -x1*z2, and whose z-coordinate is x1*y2 -x1*y2 -x2*y1 (where 1 and 2 represent subscripts indicating whether the subscripted coordinate belongs to the first vector or the second vector).

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the cross product.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TGPoint3D::Normalize

GCoordinate Normalize ()

Interface Category:

API.

Purpose:

Makes the vector length 1.0, preserving the vector's angle with respect to each axis. However, if the vector length is zero, the vector is not changed.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the length of the vector before normalization.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TGPoint3D::VectorLength

GCoordinate VectorLength () const

Interface Category:

API.

Purpose:

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the length of the vector.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TGPoint3D::SetVectorLength

void SetVectorLength (GCoordinate length)

Interface Category:

API.

Purpose:

Sets the distance of the point from the origin, without changing the angle between the vector and any axis.

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: TGPoint3D::operator<<=

TStream & operator <<= (TStream & fromwhere)

Interface Category:

API.

Purpose:

Stream-in operator.

Calling Context:

Called to stream in data.

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: TGPoint3D::operator>>=

TStream & operator >>=(TStream & towhere) const

Interface Category:

API.

Purpose:

Stream-out operator.

Calling Context:

Called to stream out data.

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.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.