paths.cpp File Reference

(r1785/r1492)

#include "camtypes.h"
#include <math.h>
#include "pathutil.h"
#include "pathproc.h"
#include "vector.h"
#include "osrndrgn.h"
#include "pen.h"
#include "blobs.h"
#include "fitcurve.h"
#include "layermgr.h"
#include "gclip.h"
#include "grndrgn.h"
#include "XaDraw.h"
#include "cstroke.h"

Go to the source code of this file.

Functions

 DECLARE_SOURCE ("$Revision: 1492 $")
INT32 FindNonColinear (const DocCoord CoordArray[], const UINT32 &ulNumCoords)
 Support function for IsIsometric Finds the first of three points in the given CoordArray that are not in a straight line.
template<class T>
BOOL IsNear (const T &x1, const T &x2, const T &Tolerance)
 Support function for IsIsometric Determines whether two values are near enough to each other to be considered equal. Notes: This is a templated function with <class t>="">.
BOOL Solve3Simultaneous (const CCVector3 &constsX0, const CCVector3 &constsX1, const CCVector3 &constsY0, double &v0, double &v1, double &v2)
 Support function for IsIsometric Determines whether two values are near enough to each other to be considered equal. Notes: This is a templated function with <class t>="">Support function for IsIsometric Solves 3 simultaneous equations for the three values v1,v2,v3.


Function Documentation

DECLARE_SOURCE "$Revision: 1492 $"   ) 
 

INT32 FindNonColinear const DocCoord  CoordArray[],
const UINT32 ulNumCoords
 

Support function for IsIsometric Finds the first of three points in the given CoordArray that are not in a straight line.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/08/96
Parameters:
CoordArray,: The path with which to comapre this one [INPUTS] Tolerance: The accuracy to which this path transformed to the otherPath may be considered equal.
Returns:
The index in the array of the first point -1 if a straight line

Definition at line 9890 of file paths.cpp.

09891 {
09892     UINT32 index = 0;
09893     UINT32 x1,y1,x2,y2;
09894     // Three points are colinear if the vectors between them have a zero cross-product
09895 
09896     while (index < ulNumCoords - 2)
09897     {
09898         // Might save time to work out the first two outside the loop
09899         // Depends on number of linear paths really
09900         x1 = CoordArray[index + 1].x - CoordArray[index].x;
09901         y1 = CoordArray[index + 1].y - CoordArray[index].y;
09902 
09903         x2 = CoordArray[index + 2].x - CoordArray[index + 1].x;
09904         y2 = CoordArray[index + 2].y - CoordArray[index + 1].y;
09905 
09906         if (x1 * y2 != x2 * y1)
09907         {
09908             return index;
09909         }
09910         ++index;
09911     }
09912 
09913     return -1;
09914 }

template<class T>
BOOL IsNear const T &  x1,
const T &  x2,
const T &  Tolerance
[inline]
 

Support function for IsIsometric Determines whether two values are near enough to each other to be considered equal. Notes: This is a templated function with <class t>="">.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/08/96
Parameters:
x1,: The first of the two values to compare [INPUTS] x2: The second of the two values to compare Tolerance: The value within which x1 is considered to be near to x2
Returns:
TRUE if the two values have an absolute difference greater than or equal to the given Tolerance FALSE otherwise

Definition at line 9936 of file paths.cpp.

09937 {
09938     return (ABS(x1 - x2) <= Tolerance) ? TRUE : FALSE;
09939 }

BOOL Solve3Simultaneous const CCVector3 constsX0,
const CCVector3 constsX1,
const CCVector3 constsY0,
double &  v0,
double &  v1,
double &  v2
 

Support function for IsIsometric Determines whether two values are near enough to each other to be considered equal. Notes: This is a templated function with <class t>="">Support function for IsIsometric Solves 3 simultaneous equations for the three values v1,v2,v3.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/08/96
Parameters:
constsX0,: First values in the 3 simultaneous equations [INPUTS] constsX1: Second values in the 3 simultaneous equations constsY0: Third values in the 3 simultaneous equations
v1,v2,v3,: The three solution values [OUTPUTS]
Returns:
TRUE if there were a solution FALSE otherwise

Definition at line 9979 of file paths.cpp.

09980 {
09981     const double Tolerance = 1e-10;
09982 
09983     double DivA = (constsX0.v0 - constsX0.v1) * (constsY0.v0 - constsY0.v2) - (constsX0.v0 - constsX0.v2) * (constsY0.v0 - constsY0.v1);
09984     if (IsNear(DivA, 0.0, Tolerance))
09985     {
09986         return FALSE;
09987     }
09988 
09989     double DivB = (constsY0.v0 - constsY0.v1) * (constsX0.v0 - constsX0.v2) - (constsY0.v0 - constsY0.v2) * (constsX0.v0 - constsX0.v1);
09990     if (IsNear(DivB, 0.0, Tolerance))
09991     {
09992         return FALSE;
09993     }
09994 
09995     v0 = ((constsY0.v0 - constsY0.v2) * (constsX1.v0 - constsX1.v1) - (constsY0.v0 - constsY0.v1) * (constsX1.v0 - constsX1.v2)) / DivA;
09996 
09997 
09998     v1 = ((constsX1.v0 - constsX1.v1) * (constsX0.v0 - constsX0.v2) - (constsX1.v0 - constsX1.v2) * (constsX0.v0 - constsX0.v1)) / DivB;
09999     
10000 
10001     v2 = constsX1.v0 - v0 * constsX0.v0 - v1 * constsY0.v0;
10002 
10003     return TRUE;
10004 }


Generated on Sat Nov 10 03:49:18 2007 for Camelot by  doxygen 1.4.4