NormCoord Class Reference

Normalised vector/coordinate When normalised, the vector is always of unit length. More...

#include <pathtrap.h>

Inheritance diagram for NormCoord:

CCObject SimpleCCObject List of all members.

Public Member Functions

 NormCoord ()
 NormCoord (double X, double Y)
 NormCoord (NormCoord &Other)
void Normalise (void)
void Average (NormCoord &C1, NormCoord &C2)
double GetLength ()
void SetFromLine (DocCoord &P1, DocCoord &P2)
void SetNormalToLine (DocCoord &P1, DocCoord &P2)
double DotProduct (NormCoord &Other)
NormCoordoperator= (const NormCoord &Other)

Public Attributes

double x
double y

Private Member Functions

 CC_DECLARE_DYNCREATE (NormCoord)

Detailed Description

Normalised vector/coordinate When normalised, the vector is always of unit length.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/12/96
Notes: The entire class is inlined to keep these simple operations efficient

Definition at line 171 of file pathtrap.h.


Constructor & Destructor Documentation

NormCoord::NormCoord  )  [inline]
 

Definition at line 176 of file pathtrap.h.

00176 { x = y = 0.0; };

NormCoord::NormCoord double  X,
double  Y
[inline]
 

Definition at line 177 of file pathtrap.h.

00177 { x = X; y = Y; };

NormCoord::NormCoord NormCoord Other  )  [inline]
 

Definition at line 178 of file pathtrap.h.

00178 { x = Other.x; y = Other.y; };


Member Function Documentation

void NormCoord::Average NormCoord C1,
NormCoord C2
[inline]
 

Definition at line 200 of file pathtrap.h.

00201     {
00202         if (C1.x + C2.x == 0.0 && C1.y + C2.y == 0.0)
00203         {
00204             double Temp = C1.x;
00205             x = C1.y;
00206             y = -Temp;
00207         }
00208         else
00209         {
00210             x = (C1.x + C2.x) / 2.0;
00211             y = (C1.y + C2.y) / 2.0;
00212             Normalise();
00213         }
00214     }

NormCoord::CC_DECLARE_DYNCREATE NormCoord   )  [private]
 

double NormCoord::DotProduct NormCoord Other  )  [inline]
 

Definition at line 239 of file pathtrap.h.

00240     {
00241         return( (x * Other.x) + (y * Other.y) );
00242     }

double NormCoord::GetLength  )  [inline]
 

Definition at line 216 of file pathtrap.h.

00217     {
00218         return sqrt(x * x + y * y);
00219     }

void NormCoord::Normalise void   )  [inline]
 

Definition at line 182 of file pathtrap.h.

00183     {
00184         double Normalise = sqrt(x*x + y*y);
00185         if (Normalise == 0.0)
00186         {
00187             TRACE( _T("** NormCoord::Normalise - Zero-length vector (%f)\n"), Normalise);
00188         }
00189         else
00190         {
00191             Normalise = 1/Normalise;
00192             x *= Normalise;
00193             y *= Normalise;
00194         }
00195     }

NormCoord& NormCoord::operator= const NormCoord Other  )  [inline]
 

Definition at line 245 of file pathtrap.h.

00246     {
00247         x = Other.x;
00248         y = Other.y;
00249         return(*this);
00250     }

void NormCoord::SetFromLine DocCoord P1,
DocCoord P2
[inline]
 

Definition at line 222 of file pathtrap.h.

00223     {
00224         x = P1.x - P2.x;
00225         y = P1.y - P2.y;
00226         Normalise();
00227     }

void NormCoord::SetNormalToLine DocCoord P1,
DocCoord P2
[inline]
 

Definition at line 230 of file pathtrap.h.

00231     {
00232         x = P1.y - P2.y;
00233         y = -(P1.x - P2.x);
00234         Normalise();
00235     }


Member Data Documentation

double NormCoord::x
 

Definition at line 253 of file pathtrap.h.

double NormCoord::y
 

Definition at line 254 of file pathtrap.h.


The documentation for this class was generated from the following file:
Generated on Sat Nov 10 03:57:14 2007 for Camelot by  doxygen 1.4.4