Geometric Functions (2D)

:Associate with "Geometric Functions (2D)" More...

Functions

GEOMLIBEXPORT int ArcFrom3Pts (const DPOINT2D *p1, const DPOINT2D *p2, const DPOINT2D *p3, double *cx, double *cy, double *r, double *sang, double *eang)
GEOMLIBEXPORT int CheckPointD (const DPOINT2D *start, const DPOINT2D *end, const DPOINT2D *point)
int CheckPointL (const LPOINT2D *start, const LPOINT2D *end, const LPOINT2D *point)
GEOMLIBEXPORT int CircleFrom2Pts (const DPOINT2D *p1, const DPOINT2D *p2, double *cx, double *cy, double *r)
GEOMLIBEXPORT int CircleFrom3Pts (const DPOINT2D *T1, const DPOINT2D *T2, const DPOINT2D *T3, double *center_x, double *center_y, double *radius)
int ClipLineD (const DRECT2D *cliprect, DPOINT2D *start, DPOINT2D *end)
int ComputeDPolygonsFromSelectedVoronoi (DPOLYGON **Dpolys, INT32 *NumDpolys, VORONOI_DIAGRAM *vdiagram)
ERRVALUE ComputeSimpleBufferL (const LPOINT2D *ipointlist, int inumpoints, double bufdist, int joinstyle, LPOINT2D **rpointlist, int *rnumpoints)
GEOMLIBEXPORT double DistPointLineSegD (const DPOINT2D *start, const DPOINT2D *end, const DPOINT2D *point, DPOINT2D *closest)
double DistPointLineSegW (const WPOINT2D *start, const WPOINT2D *end, const WPOINT2D *point, DPOINT2D *closest)
GEOMLIBEXPORT double DistPointRectD (const DRECT2D *rect, const DPOINT2D *point, DPOINT2D *closest)
void DoneVoronoiDiagram (VORONOI_DIAGRAM *vdiagram)
int ExtendLineToRectD (DPOINT2D *ip1, DPOINT2D *ip2, DRECT2D *rect, DPOINT2D *op1, DPOINT2D *op2)
double FindDistToArc (const CONICARC *arc, const DPOINT2D *point, int type)
double FindDistToEArc (const CONICEARC *earc, double x, double y, int type)
double FindDistToEllipse (const CONICELLIPSE *elp, double x, double y)
GEOMLIBEXPORT int FindLineInt (const DPOINT2D *line1pt1, const DPOINT2D *line1pt2, const DPOINT2D *line2pt1, const DPOINT2D *line2pt2, DPOINT2D *intpoint)
void InitVoronoiDiagram (VORONOI_DIAGRAM *vdiagram)
GEOMLIBEXPORT ERRVALUE LineFromConic (const CADEARC &earc, SIMPLE_ARRAY< DPOINT2D > &PointList, TRANS2D_AFFINE *ArcToPixel, bool IsChord, bool IsWedge)
INT32 MfitBSplineMovePoint (DPOINT2D *In, DPOINT2D **Out, INT32 NumPts, INT32 EditPoint, int F, double Tolerance, UINT32 Flags)
INT32 MfitPointsBezier (DPOINT2D *In, DPOINT2D **Out, INT32 NumPts, INT32 NumOut, double Tolerance, UINT32 Flags)
INT32 MfitPointsBSpline (DPOINT2D *In, DPOINT2D **Out, INT32 NumPts, int F, double Tolerance, UINT32 Flags)
INT32 MfitPointsBSplineQuadratic (DPOINT2D *In, DPOINT2D **Out, INT32 NumPts, int F, double Tolerance, UINT32 Flags)
INT32 MfitPointsSpline3D (DPOINT3D *In, DPOINT3D **Out, INT32 NumPts, INT32 F, double Tolerance, int SplineType, UINT32 Flags)
GEOMLIBEXPORT int PointInPolyD (const DPOLYGON *polygon, const DPOINT2D *point)
int PointInPolyL (const LPOLYGON *polygon, const LPOINT2D *point)
GEOMLIBEXPORT int PolyStatsD (const DPOLYGON *polygon, double *area, double *centx, double *centy, int *orient)
GEOMLIBEXPORT INT32 RemoveDupPts (DPOINT2D *pts, INT32 num)
GEOMLIBEXPORT INT32 RemoveDupPtsT (DPOINT2D *pts, INT32 num, double thresh)
GEOMLIBEXPORT int SolveLinear (int n, double *A, double *b, double *x)
int SolveLinearSVD (int n, double *A, double *B, double *X)
int VoronoiProc (DPOINT3D **Points, INT32 *NumPoints, VORONOI_DIAGRAM *vdiagram, double ExtFactor)

Detailed Description

:Associate with "Geometric Functions (2D)"


Function Documentation

GEOMLIBEXPORT int ArcFrom3Pts ( const DPOINT2D p1,
const DPOINT2D p2,
const DPOINT2D p3,
double *  cx,
double *  cy,
double *  r,
double *  sang,
double *  eang 
)

Compute arc from three points on the circumference of a circle.

GEOMLIBEXPORT int CheckPointD ( const DPOINT2D start,
const DPOINT2D end,
const DPOINT2D point 
)

Determine point location relative to a line (double coordinates).

Returns:
-1 if left of line, 0 if on line, +1 if right of line.
A right-handed cartesian coordinate system is assumed for left/right determination.
Parameters:
start  Starting point used to define line
end  Ending point used to define line
point  Point to check

int CheckPointL ( const LPOINT2D start,
const LPOINT2D end,
const LPOINT2D point 
)

Determine point location relative to a line (LONG coordinates).

Returns:
-1 if left of line, 0 if on line, +1 if right of line.
A right-handed cartesian coordinate system is assumed for left/right determination.
Parameters:
start  Starting point used to define line
end  Ending point used to define line
point  Point to check

GEOMLIBEXPORT int CircleFrom2Pts ( const DPOINT2D p1,
const DPOINT2D p2,
double *  cx,
double *  cy,
double *  r 
)

Compute circle from 2 points defining the diameter.

Returns:
0 if real circle: -1 if mathematically impossible.

GEOMLIBEXPORT int CircleFrom3Pts ( const DPOINT2D T1,
const DPOINT2D T2,
const DPOINT2D T3,
double *  center_x,
double *  center_y,
double *  radius 
)

Compute circle from 3 points on the circumference.

int ClipLineD ( const DRECT2D cliprect,
DPOINT2D start,
DPOINT2D end 
)

Clip line to rectangle (double coordinates).

Returns:
0 - line completely outside cliprect, 1 - line start was modifed, 2 - line end was modified, 3 - both ends were modified, 4 - line completely inside cliprect.
Parameters:
cliprect  Rectangle to clip to
start  Starting point of segment, modified if necessary
end  Ending point of segment, modified if necessary

int ComputeDPolygonsFromSelectedVoronoi ( DPOLYGON **  Dpolys,
INT32 NumDpolys,
VORONOI_DIAGRAM vdiagram 
)

ERRVALUE ComputeSimpleBufferL ( const LPOINT2D ipointlist,
int  inumpoints,
double  bufdist,
int  joinstyle,
LPOINT2D **  rpointlist,
int *  rnumpoints 
)

Compute buffer on one side of a polyline.

Note: Consecutive points in the input point list MUST be different. Positive buffer distances will result in a buffer to the right of the line assuming Cartesian coordinates (+ right/up, - left/down).

Parameters:
rpointlist  Allocated point list returned
rnumpoints  Number of points returned

GEOMLIBEXPORT double DistPointLineSegD ( const DPOINT2D start,
const DPOINT2D end,
const DPOINT2D point,
DPOINT2D closest 
)

Determine distance between point and line segment (double coordinates).

Returns:
Distance to closest point on line segment.
Parameters:
start  Starting point of line segment
end  Ending point of line segment
point  Point to test
closest  Closest point on segment returned (NULL if not needed)

double DistPointLineSegW ( const WPOINT2D start,
const WPOINT2D end,
const WPOINT2D point,
DPOINT2D closest 
)

Determine distance between point and line segment (WORD coordinates).

Returns:
Distance to closest point on line segment.
Parameters:
start  Starting point of line segment
end  Ending point of line segment
point  Point to test
closest  Closest point on segment returned (NULL if not needed, DPOINT2D)

GEOMLIBEXPORT double DistPointRectD ( const DRECT2D rect,
const DPOINT2D point,
DPOINT2D closest 
)

Determine distance between point and rectangle (double coordinates).

Returns:
Distance to closest point on rectangle.
Parameters:
rect  Rectangle to compute distance to
point  Point to test
closest  Closest point on rectangle returned (NULL if not needed)

void DoneVoronoiDiagram ( VORONOI_DIAGRAM vdiagram  ) 

int ExtendLineToRectD ( DPOINT2D ip1,
DPOINT2D ip2,
DRECT2D rect,
DPOINT2D op1,
DPOINT2D op2 
)

Extend line to rectangle boundaries.

Returns:
True if line intersects rectangle, false if not.

double FindDistToArc ( const CONICARC arc,
const DPOINT2D point,
int  type 
)

Compute the distance from a point to an arc.

Returns:
Distance to the arc.
Values for type field: CONIC_ARC CONIC_ARCCHORD CONIC_ARCWEDGE
Parameters:
arc  Structure containing arc info
point  The point to get distance to
type  Type of arc to check

double FindDistToEArc ( const CONICEARC earc,
double  x,
double  y,
int  type 
)

Compute the distance from a point to an elliptical arc.

Returns:
Distance to the elliptical arc.
Values for type field: CONIC_EARC CONIC_EARCCHORD CONIC_EARCWEDGE
Parameters:
earc  Structure containing elliptical arc info
x  X coordinate of point
y  Y coordinate of point
type  Type of arc to check

double FindDistToEllipse ( const CONICELLIPSE elp,
double  x,
double  y 
)

Compute the distance from a point to an ellipse.

Returns:
Distance to the ellipse.
Parameters:
elp  Structure containing ellipse info
x  X coordinate of point
y  Y coordinate of point

GEOMLIBEXPORT int FindLineInt ( const DPOINT2D line1pt1,
const DPOINT2D line1pt2,
const DPOINT2D line2pt1,
const DPOINT2D line2pt2,
DPOINT2D intpoint 
)

Determine if line segments intersect, where, and type of intersection.

Returns:
Type and location of intersection.

void InitVoronoiDiagram ( VORONOI_DIAGRAM vdiagram  ) 

Initialize VoronoiDiagram.

GEOMLIBEXPORT ERRVALUE LineFromConic ( const CADEARC earc,
SIMPLE_ARRAY< DPOINT2D > &  PointList,
TRANS2D_AFFINE ArcToPixel,
bool  IsChord,
bool  IsWedge 
)

Generates a line based on a conic definition.

Parameters:
earc  Conic to generate line from
PointList  Line points RETURNED
ArcToPixel  Determine density of line points to approximate arc
IsChord  Is ARC_CHORD
IsWedge  Is ARC_WEDGE

INT32 MfitBSplineMovePoint ( DPOINT2D In,
DPOINT2D **  Out,
INT32  NumPts,
INT32  EditPoint,
int  F,
double  Tolerance,
UINT32  Flags 
)

Compute cubic B - spline for 4 segments arround one point (2 on left and 2 on right side) in the given point list / 2D - line.

Returns:
ret > 0 - number of points in output buffer ret < 0 - error code.
Note: This function need 4 points at least. Note: Programmer can use the same pointers for input and output buffers. IMPORTANT: Tolerance value will be ALWAYS used to eliminate dup. points!
Parameters:
In  Input array of points - passed
Out  Pointer to output array - returned
NumPts  Number of points in input array
EditPoint  Point that you want to move (will be center point of 7-point chain)
F  Number of additional knots between input points
Tolerance  Currently used only with SPLINE_UseMinDistance flag minimal allowed distance between points in spline
Flags  Processing flags

INT32 MfitPointsBezier ( DPOINT2D In,
DPOINT2D **  Out,
INT32  NumPts,
INT32  NumOut,
double  Tolerance,
UINT32  Flags 
)

Compute Bezier for given point list / 2D - line.

Returns:
ret > 0 - number of points in output buffer, ret == 0 - too few lines in input buffer, can't compute spline, but this is not an error. ret < 0 - error code.
Note: Programmer can use the same pointers for input and output buffers. IMPORTANT: Tolerance value will be ALWAYS used to eliminate dup. points!
Parameters:
In  Input array of points - passed
Out  Pointer to output array - returned
NumPts  Number of points in input array
NumOut  Number of output points
Tolerance  Currently used only with SPLINE_UseMinDistance flag minimal allowed distance between points in spline
Flags  Processing flags: SPLINE_UseMinDistance - use Tolerance parameter

INT32 MfitPointsBSpline ( DPOINT2D In,
DPOINT2D **  Out,
INT32  NumPts,
int  F,
double  Tolerance,
UINT32  Flags 
)

Compute cubic B - spline for given point list / 2D - line.

Returns:
ret > 0 - number of points in output buffer, ret == 0 - too few lines in input buffer, can't compute spline, but this is not an error. ret < 0 - error code.
Processing flags: SPLINE_UseMinDistance - use Tolerance parameter SPLINE_TreatAsClosed - all non-closed lines will be treated as closed, this flag has no impact on really closed lines. Note: Programmer can use the same pointers for input and output buffers. IMPORTANT: Tolerance value will be ALWAYS used to eliminate dup. points!
Parameters:
In  Input array of points - passed
Out  Pointer to output array - returned
NumPts  Number of points in input array
F  Number of additional knots between input points
Tolerance  Currently used only with SPLINE_UseMinDistance flag minimal allowed distance between points in spline
Flags  Flags

INT32 MfitPointsBSplineQuadratic ( DPOINT2D In,
DPOINT2D **  Out,
INT32  NumPts,
int  F,
double  Tolerance,
UINT32  Flags 
)

Compute quadratic B - spline for given point list / 2D - line.

Returns:
ret > 0 - number of points in output buffer, ret == 0 - too few lines in input buffer, can't compute spline, but this is not an error. ret < 0 - error code.
Note: Programmer can use the same pointers for input and output buffers. IMPORTANT: Tolerance value will be ALWAYS used to eliminate dup. points! Processing flags: SPLINE_UseMinDistance - use Tolerance parameter SPLINE_TreatAsClosed - all non-closed lines will be treated as closed, this flag has no impact on really closed lines.
Parameters:
In  Input array of points - passed
Out  Pointer to output array - returned
NumPts  Number of points in input array
F  Number of additional knots between input points.
Tolerance  Currently used only with SPLINE_UseMinDistance flag minimal allowed distance between points in spline.
Flags  Flags

INT32 MfitPointsSpline3D ( DPOINT3D In,
DPOINT3D **  Out,
INT32  NumPts,
INT32  F,
double  Tolerance,
int  SplineType,
UINT32  Flags 
)

Compute spline for given point list / 3D - line.

Returns:
ret > 0 - number of points in output buffer, ret == 0 - too few lines in input buffer, can't compute spline, but this is not an error. ret < 0 - error code.
NOTE: This function doesn't spline in XY-plane, it's just densify line and splines in Z/distance plane. Note: Programmer can use the same pointers for input and output buffers. IMPORTANT: Tolerance value will be ALWAYS used to eliminate dup. points! Type of the spline to use: SPLINETYPE_Cubic - cubic spline (default type) SPLINETYPE_Quad - quadratic spline SPLINETYPE_Bezier - Bezier spline Processing flags: SPLINE_UseMinDistance - use Tolerance parameter SPLINE_TreatAsClosed - all non-closed lines will be treated as closed, this flag has no impact on really closed lines.
Parameters:
In  Input array of points - passed
Out  Pointer to output array - returned
NumPts  Number of points in input array
F  Number of additional knots between input points or desired number of points in output (for Bezier)
Tolerance  Currently used only with SPLINE_UseMinDistance flag minimal allowed distance between points in spline
SplineType  Spline type
Flags  Flags

GEOMLIBEXPORT int PointInPolyD ( const DPOLYGON polygon,
const DPOINT2D point 
)

Determine if a point is inside a polygon (double coordinates).

Returns:
0 if point outside, 1 if point inside.
Parameters:
polygon  Polygon to use
point  Point to test

int PointInPolyL ( const LPOLYGON polygon,
const LPOINT2D point 
)

Determine if a point is inside a polygon (LONG coordinates).

Returns:
0 if point outside, 1 if point inside.
Parameters:
polygon  Polygon to use
point  Point to test

GEOMLIBEXPORT int PolyStatsD ( const DPOLYGON polygon,
double *  area,
double *  centx,
double *  centy,
int *  orient 
)

Compute polygon area, centroid, perimeter, orientation (double coordinates).

Parameters:
polygon  Polygon to compute attributes of
area  Polygon area returned (NULL if don't care)
centx  X centroid returned (NULL if don't care)
centy  Y centroid returned (NULL if don't care)
orient  Polygon orientation (1=clockwise, 0=anticlockwise) returned (NULL ok)

GEOMLIBEXPORT INT32 RemoveDupPts ( DPOINT2D pts,
INT32  num 
)

Remove duplicate and colinear points from a point buffer.

Returns:
Number of points left in point buffer.
NOTE: This function does not reallocate the buffer to fit the reduced number of points.
Parameters:
pts  Point buffer
num  Number of points in point buffer

GEOMLIBEXPORT INT32 RemoveDupPtsT ( DPOINT2D pts,
INT32  num,
double  thresh 
)

Check and remove duplicate and colinear points in a line within a threshold.

Parameters:
pts  Point buffer
num  Number of points in point buffer
thresh  Threshold

GEOMLIBEXPORT int SolveLinear ( int  n,
double *  A,
double *  b,
double *  x 
)

Solve general set of linear equations.

Notes: Solve the matrix equation: A * X = B for X Where: A is an NxN matrix, X is a 1xN matrix, B is an Nx1 matrix

Parameters:
n  Number of equations
A  NxN coefficient matrix "A"
b  Nx1 result matrix "B"
x  1xN unknown matrix returned "X"

int SolveLinearSVD ( int  n,
double *  A,
double *  B,
double *  X 
)

Solve general set of linear equations, using MatSolveSVD().

Notes: Solve the matrix equation: A * X = B for X Where: A is an NxN matrix X is a 1xN matrix B is an Nx1 matrix

Parameters:
n  Number of equations
A  NxN coefficient matrix "A"
B  Nx1 result matrix "B"
X  1xN unknown matrix returned "X"

int VoronoiProc ( DPOINT3D **  Points,
INT32 NumPoints,
VORONOI_DIAGRAM vdiagram,
double  ExtFactor 
)


Generated on Thu Apr 26 04:46:39 2007 for TNTsdk by  doxygen 1.5.2