Woolz Image Processing Version 1.4.0
|
Data Structures | |
struct | _WlzGeomPolyListItem2D |
Item for polygon vertex list. See WlzGeomPolyTriangulate2D(). More... | |
Files | |
file | WlzGeometry.c |
Geometric utility functions. | |
Functions | |
void | WlzEffWriteMeshTransform3DWithoutDisplacementVTK (FILE *fp, WlzMeshTransform3D *wmt3D) |
output the orginal mesh. | |
void | WlzEffWriteMeshTransform3DWithDisplacementVTK (FILE *fp, WlzMeshTransform3D *wmt3D) |
output the transformed mesh. | |
double | WlzGeomTriangle2SnArea3 (WlzDVertex3 *a, int i, int j, int k) |
output the cut plane in VTK format to a file. | |
WlzErrorNum | write_Wlz2D5Mesh (FILE *fp, char *cstr, WlzMeshTransform2D5 *wmt2D5) |
Write 2D5 mesh for inspections. | |
WlzErrorNum | Write_WlzCutScanLines (FILE *fp, char *cstr, WlzMeshScanWSp2D5 *mSnWSp) |
Write the section view parameters in the bibtex style record using the bibFile library. | |
void | WlzEffWriteOriginalPlaneVTKByDis (FILE *fp, WlzMeshTransform2D5 *wmt2D5) |
output the orginal surface corresponding to the cut plane represented by the postion of the same mesh. | |
void | WlzEffWriteOriginalPlaneVTKByPos (FILE *fp, WlzMeshTransform2D5 *wmt2D5) |
output the cutted plane. | |
WlzDVertex2 | WlzGeomTriangleCen2D (WlzDVertex2 v0, WlzDVertex2 v1, WlzDVertex2 v2) |
Computes the position of the centroid of the given triangle in 2D. | |
WlzDVertex3 | WlzGeomTriangleCen3D (WlzDVertex3 v0, WlzDVertex3 v1, WlzDVertex3 v2) |
Computes the position of the centroid of the given triangle in 3D. | |
WlzDVertex3 | WlzGeomTetrahedronCen3D (WlzDVertex3 v0, WlzDVertex3 v1, WlzDVertex3 v2, WlzDVertex3 v3) |
Computes the position of the centroid of the given tetrahedron in 3D. | |
int | WlzGeomTriangleCircumcentre (WlzDVertex2 *ccVx, WlzDVertex2 vx0, WlzDVertex2 vx1, WlzDVertex2 vx2) |
Computes the circumcentre of the given triangle. | |
int | WlzGeomVxInTriangle2D (WlzDVertex2 p0, WlzDVertex2 p1, WlzDVertex2 p2, WlzDVertex2 pP) |
Tests whether the given vertex lies within the given triangle using a barycentric coordinates test. | |
int | WlzGeomVxInTriangle3D (WlzDVertex3 v0, WlzDVertex3 v1, WlzDVertex3 v2, WlzDVertex3 vQ, double vPMax) |
First finds the closest point on the plane of the triangle to the given point. Then if the distance from the point to the plane is less than the given tolerance vvalue tests to set if the given vertex lies within the given triangle using a barycentric coordinates test (see WlzGeomVxInTriangle2D()). | |
int | WlzGeomVxInTetrahedron (WlzDVertex3 v0, WlzDVertex3 v1, WlzDVertex3 v2, WlzDVertex3 v3, WlzDVertex3 vP) |
Tests whether the given vertex lies within the given tetrahedron using a barycentric coordinates test. | |
double | WlzGeomTriangleSnArea2 (WlzDVertex2 vx0, WlzDVertex2 vx1, WlzDVertex2 vx2) |
Computes twice the signed area of the given triangle. | |
double | WlzGeomTetraSnVolume6 (WlzDVertex3 vx0, WlzDVertex3 vx1, WlzDVertex3 vx2, WlzDVertex3 vx3) |
Computes six times the signed volume of the given tetrahedron. | |
double | WlzGeomTriangleArea2Sq3 (WlzDVertex3 vx0, WlzDVertex3 vx1, WlzDVertex3 vx2) |
Computes twice the square of the area of the given 3D triangle. | |
int | WlzGeomInTriangleCircumcircle (WlzDVertex2 vx0, WlzDVertex2 vx1, WlzDVertex2 vx2, WlzDVertex2 gVx) |
Tests to see if the given vertex is inside the circumcircle of the given triangle. | |
int | WlzGeomLineSegmentsIntersect (WlzDVertex2 p0, WlzDVertex2 p1, WlzDVertex2 q0, WlzDVertex2 q1, WlzDVertex2 *dstN) |
Tests to see if the two given line segments intersect. | |
int | WlzGeomCmpAngle (WlzDVertex2 p0, WlzDVertex2 p1) |
Given two end connected 2D line segments this function compares the CCW angle of the segments. | |
int | WlzGeomVtxEqual2D (WlzDVertex2 pos0, WlzDVertex2 pos1, double tolSq) |
Checks to see if two verticies are the same within some tollerance. | |
int | WlzGeomVtxEqual3D (WlzDVertex3 pos0, WlzDVertex3 pos1, double tol) |
Checks to see if two verticies are the same within some tollerance. | |
void | WlzGeomVtxSortRadial (int nV, WlzDVertex3 *vP, int *idxBuf, WlzDVertex2 *wP, WlzDVertex3 rV) |
Sorts the given 3D verticies, which lie in a plane perpendicular to the radial vector, in order of their angle the radial vector. | |
WlzDVertex3 | WlzGeomTriangleNormal (WlzDVertex3 v0, WlzDVertex3 v1, WlzDVertex3 v2) |
Computes the unit normal vector perpendicular to the triangle ![]() | |
int | WlzGeomTriangleAABBIntersect2D (WlzDVertex2 t0, WlzDVertex2 t1, WlzDVertex2 t2, WlzDVertex2 b0, WlzDVertex2 b1, int tst) |
Tests for an intersection between the given triangle and the axis aligned bounding box using the Separating Axis Theorem (SAT). | |
int | WlzGeomTetrahedronAABBIntersect3D (WlzDVertex3 t0, WlzDVertex3 t1, WlzDVertex3 t2, WlzDVertex3 t3, WlzDVertex3 b0, WlzDVertex3 b1, int tst) |
Tests for an intersection between the given tetrahedron and the axis aligned bounding box using the Separating Axis Theorem (SAT). | |
int | WlzGeomPlaneAABBIntersect (double a, double b, double c, double d, WlzDBox3 box) |
Tests for an intersection between the plane defined by the equation: ![]() | |
int | WlzGeomPlaneLineIntersect (double a, double b, double c, double d, WlzDVertex3 p0, WlzDVertex3 p1, WlzDVertex3 *dstIsn) |
Tests for an intersection between the plane defined by the equation: ![]() ![]() ![]() | |
int | WlzGeomPlaneTriangleIntersect (double a, double b, double c, double d, WlzDVertex3 p0, WlzDVertex3 p1, WlzDVertex3 p2, WlzDVertex3 *dstIsn0, WlzDVertex3 *dstIsn1) |
Tests for an intersection between a plane and a triangle. | |
double | WlzGeomEllipseVxDistSq (WlzDVertex2 centre, WlzDVertex2 sAx, WlzDVertex2 gPnt) |
Given an ellipse defined by it's centre ![]() ![]() | |
unsigned int | WlzGeomHashVtx3D (WlzDVertex3 pos, double tol) |
Computes a hash value from a given 3D double precision position. | |
unsigned int | WlzGeomHashVtx2D (WlzDVertex2 pos, double tol) |
Computes a hash value from a given 2D double precision position. | |
int | WlzGeomCmpVtx3D (WlzDVertex3 pos0, WlzDVertex3 pos1, double tol) |
Compares the coordinates of the given 3D double precision vertices to find a signed value for sorting. | |
int | WlzGeomCmpVtx2D (WlzDVertex2 pos0, WlzDVertex2 pos1, double tol) |
Compares the coordinates of the given 2D double precision vertices to find a signed value for sorting. | |
WlzDVertex2 | WlzGeomUnitVector2D (WlzDVertex2 vec) |
Computes the 2D unit vector ![]() | |
WlzDVertex3 | WlzGeomUnitVector3D (WlzDVertex3 vec) |
Computes the 3D unit vector ![]() | |
WlzDVertex2 | WlzGeomUnitVector2D2 (WlzDVertex2 v1, WlzDVertex2 v0) |
Computes the unit 2D vector with the direction given by ![]() | |
WlzDVertex3 | WlzGeomUnitVector3D2 (WlzDVertex3 v1, WlzDVertex3 v0) |
Computes the unit 3D vector with the direction given by ![]() | |
int | WlzGeomVertexInDiamCircle (WlzDVertex2 lPos0, WlzDVertex2 lPos1, WlzDVertex2 pos) |
Determines whether a point is inside the diametral circle of a line segment. If two vectors ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | |
int | WlzGeomItrSpiralRing (int step) |
Computes the ring of a spiral. If two rings differ by more than one then at least one itteration outwards on the spiral has been performed between the rings. | |
int | WlzGeomItrSpiral2I (int step, int *pX, int *pY) |
Iterates the given positions coordinates through a 2D expanding integer spiral. | |
int | WlzGeomItrSpiralShell (int step) |
Computes the shell of a spiral. If two shells differ by more than one then at least one itteration outwards on the spiral has been performed between the shells. | |
int | WlzGeomItrSpiral3I (int step, int *pX, int *pY, int *pZ) |
Iterates the given positions coordinates through a 3D expanding integer spiral. | |
double | WlzGeomDistSq2D (WlzDVertex2 v0, WlzDVertex2 v1) |
Computes square of the Euclidean distance between the given two vertices. | |
double | WlzGeomDistSq3D (WlzDVertex3 v0, WlzDVertex3 v1) |
Computes square of the Euclidean distance between the given two vertices. | |
double | WlzGeomDist2D (WlzDVertex2 v0, WlzDVertex2 v1) |
Computes the Euclidean distance between the given two vertices. | |
double | WlzGeomDist3D (WlzDVertex3 v0, WlzDVertex3 v1) |
Computes the Euclidean distance between the given two vertices. | |
int | WlzGeomTriangleAffineSolve (double *xTr, double *yTr, double dd, WlzDVertex2 *sVx, WlzDVertex2 *dVx, double thresh) |
If the unsigned area of the triangle is very small then the only the transform translation coefficients are computed with the other coefficients being set to zero. If the unsigned area of the triangle is not very small then a system of linear equations is solved for the coefficients of the 2D affine transform from the source triangle to the destination triangle. | |
int | WlzGeomTetraAffineSolveLU (double *tr, WlzDVertex3 *sVx, WlzDVertex3 *dVx) |
Computes the affine transform coefficients from the source to target tetrahedron. | |
int | WlzGeomTetraAffineSolve (double *tr, WlzDVertex3 *sVx, WlzDVertex3 *dVx, double thresh) |
Computes the affine transform coefficients from the source to target tetrahedron. | |
WlzDVertex2 | WlzGeomObjLineSegIntersect2D (WlzObject *obj, WlzDVertex2 p0, WlzDVertex2 p1, double tol, int inside, int method, int *dstStat) |
Given a Woolz object and two vertices, finds the position along a line segment between the two vertices which is just inside/outside the boundary of the object. The destination pointer is used to return the status of the vertices, using the following code: 0 - One of the given verticies was inside and the other outside, 1 - Both the given verticies were inside, 2 - Both the given verticies were outside. This function assumes that the line segment only crosses the object's boundary once. | |
WlzDVertex3 | WlzGeomObjLineSegIntersect3D (WlzObject *obj, WlzDVertex3 p0, WlzDVertex3 p1, double tol, int inside, int method, int *dstStat) |
Given a Woolz object and two vertices, finds the position along a line segment between the two vertices which is just inside/outside the boundary of the object. The destination pointer is used to return the status of the vertices, using the following code: 0 - One of the given verticies was inside and the other outside, 1 - Both the given verticies were inside, 2 - Both the given verticies were outside. This function assumes that the line segment only crosses the object's boundary once. | |
double | WlzGeomTetraInSphereDiam (WlzDVertex3 vx0, WlzDVertex3 vx1, WlzDVertex3 vx2, WlzDVertex3 vx3) |
Given the coordinates of the four vertices of a tetrahedron the function computes the maximum diameter of an inscribed sphere. | |
double | WlzGeomTetraInSphereRegDiam (double side) |
Given the side length of a regular tetrahedron this function computes the maximum diameter of an inscribed sphere. | |
double | WlzGeomPolar2D (WlzDVertex2 org, WlzDVertex2 dst, double *dstRad) |
Computes the angle of a ray from the origin to the destination vertex along with the length of the ray. Angles are: | |
double | WlzGeomCos3V (WlzDVertex2 v0, WlzDVertex2 v1, WlzDVertex2 v2) |
Computes the cosine of angle between line segments (v0, v1) and (v1, v2). If any of these vertices are coincident then zero is returned. | |
int | WlzGeomVtxOnLineSegment2D (WlzDVertex2 tst, WlzDVertex2 seg0, WlzDVertex2 seg1, double tol) |
Tests whether the given test vertex is on the given line segment. If all three vertices are coincident then the test vertex is considered to line on the line segment. | |
int | WlzGeomVtxOnLineSegment3D (WlzDVertex3 pX, WlzDVertex3 p0, WlzDVertex3 p1, WlzDVertex3 *dstN) |
Tests whether the given test vertex is on the given line segment. If all three vertices are coincident then the test vertex is considered to be coincident with an end point on the line segment. | |
double | WlzGeomArcLength2D (WlzDVertex2 a, WlzDVertex2 b, WlzDVertex2 c) |
Computes the arc length from a to b traveling CCW on a circle with centre c. | |
int | WlzGeomRectFromWideLine (WlzDVertex2 s, WlzDVertex2 t, double w, WlzDVertex2 *v) |
Computes the coordinates of vertices that may be used to draw a wide rectangle. | |
WlzDVertex3 | WlzGeomLinePlaneIntersection (WlzDVertex3 v, WlzDVertex3 p0, WlzDVertex3 p1, WlzDVertex3 p2, WlzDVertex3 p3, int *dstPar) |
Computes the intersection of a line with a plane. | |
int | WlzGeomLineTriangleIntersect3D (WlzDVertex3 org, WlzDVertex3 dir, WlzDVertex3 v0, WlzDVertex3 v1, WlzDVertex3 v2, int *dstPar, double *dstT, double *dstU, double *dstV) |
Tests whether a line directed from a given origin intersects a triangle in 3D space. This function is based on the algorithm: Tomas Moller and Ben Trumbore, "Fast, Minimum Storage Ray/Triangle Intersection", Journal of Graphics Tools, 1997(2), pp 25--30. | |
int | WlzGeomLineLineSegmentIntersect3D (WlzDVertex3 r0, WlzDVertex3 rD, WlzDVertex3 p0, WlzDVertex3 p1, WlzDVertex3 *dstN) |
Tests to see if the two given line segment is intersected by the given line using the ALG_DBL_TOLLERANCE tollerance value. The line is a line which passes through the given point to infinity (on both sides) with the given direction. | |
int | WlzGeomVtxOnLine3D (WlzDVertex3 p0, WlzDVertex3 r0, WlzDVertex3 rD) |
Tests whether a vertex is a line. | |
double | WlzGeomInterpolateTri2D (WlzDVertex2 p0, WlzDVertex2 p1, WlzDVertex2 p2, double v0, double v1, double v2, WlzDVertex2 pX) |
Given the coordinates of the vertices of a 2D triangle and a set of values at each of these vertices, this function interpolates the value at the given position which is either inside or on an edge of the triangle. This is implimented using barycentric coordinates. Once the barycentric coordinates ( ![]() ![]() ![]() ![]() | |
double | WlzGeomInterpolatePoly2D (int n, WlzDVertex2 *p, double *v, double *w, WlzDVertex2 q, WlzErrorNum *dstErr) |
Given the vertex coordinates of an irregular possible non-convex 2D polygon ordered counter-clockwise and a set of values at each of these vertices, this function interpolates the value at the given position which must be inside the convex hull of the polygon, on an edge of the convex hull of the polygon or coincident with one of the vertices of it's convex hull. This function first calls WlzConvHullClarkson2D() to compute the convex hull and then WlzGeomInterpolateConvexPoly2D() to perform the interpolation. If the polygonis known to be convex then WlzGeomInterpolateConvexPoly2D() should be called directly since temporary workspaces are allocated. | |
double | WlzGeomInterpolateConvexPoly2D (int n, WlzDVertex2 *p, double *v, double *w, WlzDVertex2 q) |
Given the vertex coordinates of an irregular convex 2D polygon ordered counter-clockwise and a set of values at each of these vertices, this function interpolates the value at the given position which must be inside the polygon, on an edge of the polygon or coincident with one of it's vertices. This is implimented using general barycentric coordinates, see the paper: "Generalized Barycentric Coordinates on
Irregular Polygons" Mark Mayer, etal, Journal of Graphics Tools 2002. All parameters of this function must be valid. | |
double | WlzGeomInterpolateTet3D (WlzDVertex3 p0, WlzDVertex3 p1, WlzDVertex3 p2, WlzDVertex3 p3, double v0, double v1, double v2, double v3, WlzDVertex3 pX) |
Given the coordinates of the vertices of a 3D tetrahedron and a set of values at each of these vertices, this function interpolates the value at the given position which is either inside or on a face/edge of the tetrahedron. This is implimented using barycentric coordinates. Once the barycentric coordinates ( ![]() ![]() ![]() ![]() ![]() | |
void | WlzGeomMap3DTriangleTo2D (WlzDVertex3 p0, WlzDVertex3 p1, WlzDVertex3 p2, WlzDVertex2 *dstQ1, WlzDVertex2 *dstQ2) |
Given the three vertices of a triangle in 3D computes the 2D coordinates within the plane of the thriangle. | |
int | WlzGeomTriangleAABBIntersect3D (WlzDVertex3 t0, WlzDVertex3 t1, WlzDVertex3 t2, WlzDVertex3 b0, WlzDVertex3 b1, int tst) |
Tests for an intersection between the given triangle and the axis aligned bounding box in 3D using the Separating Axis Theorem (SAT). | |
int | WlzGeomTriangleTriangleIntersect2D (WlzDVertex2 s0, WlzDVertex2 s1, WlzDVertex2 s2, WlzDVertex2 t0, WlzDVertex2 t1, WlzDVertex2 t2) |
Tests for an intersection between the two triangles in 2D using the by testing for intersections between the line segments of the triangles and then for either triangle being contained within the other. | |
int | WlzGeomTriangleTriangleIntersect3D (WlzDVertex3 s0, WlzDVertex3 s1, WlzDVertex3 s2, WlzDVertex3 t0, WlzDVertex3 t1, WlzDVertex3 t2) |
Tests for an intersection between the two triangles in 3D using the Separating Axis Theorem (SAT). | |
WlzErrorNum | WlzGeomCurvature (int nC, double *dstC, WlzDVertex3 nrm, int nV, WlzDVertex3 *vtx) |
Computes the principle curvatures of a parabolic surface fitted to the given vertices at the first of these vertices. | |
WlzErrorNum | WlzGeometryLSqOPlane (WlzDVertex3 *dstNrm, WlzDVertex3 *dstCen, int nVtx, WlzDVertex3 *vtx) |
Computes the plane which is the least squares best fit to the given vertices, where this is with respect to the orthogonal distance from the vertices to the plane. | |
double | WlzGeomTriangleVtxDistSq3D (WlzDVertex3 *dstPT, int *dstZT, int *dstIT, double *dstL0, double *dstL1, WlzDVertex3 vT, WlzDVertex3 v0, WlzDVertex3 v1, WlzDVertex3 v2) |
Computes the minimum distance from the test vertex to the triangle. This algorithm is based on "Distance Between Point
and Triangle in 3D", David Eberly, Geometric Tools, 1999. In this algorithm the distance is computed for a parameterised triangle in 3D for which the following regions R[0-6] ara e defined: |
void WlzEffWriteMeshTransform3DWithoutDisplacementVTK | ( | FILE * | fp, |
WlzMeshTransform3D * | wmt3D | ||
) |
output the orginal mesh.
fp | pointer pointing to a specific file. |
wmt3D | mesh transform. |
References _WlzMeshTransform3D::elements, _WlzMeshTransform3D::nElem, _WlzMeshTransform3D::nNodes, and _WlzMeshTransform3D::nodes.
void WlzEffWriteMeshTransform3DWithDisplacementVTK | ( | FILE * | fp, |
WlzMeshTransform3D * | wmt3D | ||
) |
output the transformed mesh.
fp | pointer pointing to a specific file. |
wmt3D | mesh transform. |
References _WlzMeshTransform3D::elements, _WlzMeshTransform3D::nElem, _WlzMeshTransform3D::nNodes, and _WlzMeshTransform3D::nodes.
double WlzGeomTriangle2SnArea3 | ( | WlzDVertex3 * | a, |
int | i, | ||
int | j, | ||
int | k | ||
) |
output the cut plane in VTK format to a file.
fp | pointer pointing to a specific file. |
wmt3D | mesh transform. |
intersectIndex | The index indicating which tetrahedron cut by the plane. |
nIntersect | number of intersect with the tetrahedron. |
output the original surface correspoinding to a cut plane in VTK format.
fp | pointer pointing to a specific file. |
planepointsO | the mesh array. |
linkList | pointer pointing to a array which stores the linked list. |
nIntersect | number of intersect with the tetrahedron. |
noRedundancyNumP | number of points in the mesh nodes. |
Get twice of the signed area of the triangle determined by a, b, c, positive if a, b, c are oriented ccw, and negative if ccw.
a | an array of 3D vertices. |
i | an index of the array indicate the first point of the triangle. |
j | an index of the array indicate the second point of the triangle. |
k | an index of the array indicate the third point of the triangle. |
Referenced by WlzIsoIntersectWithTetrahadronIndex().
WlzErrorNum write_Wlz2D5Mesh | ( | FILE * | fp, |
char * | cstr, | ||
WlzMeshTransform2D5 * | wmt2D5 | ||
) |
Write 2D5 mesh for inspections.
fp | FILE pointer opened for writing. |
cstr | the out put file name. |
wmt2D5 | the 2D5 mesh transform |
References _WlzMeshTransform2D5::elements, _WlzMeshTransform2D5::nElem, _WlzMeshTransform2D5::nNodes, _WlzMeshTransform2D5::nodes, and WLZ_ERR_NONE.
WlzErrorNum Write_WlzCutScanLines | ( | FILE * | fp, |
char * | cstr, | ||
WlzMeshScanWSp2D5 * | mSnWSp | ||
) |
Write the section view parameters in the bibtex style record using the bibFile library.
fp,: | FILE pointer opened for writing |
cstr | record name |
mSnWSp | woolz ... |
References _WlzMeshScanWSp2D5::itvs, _WlzMeshScanWSp2D5::nItvs, and WLZ_ERR_NONE.
void WlzEffWriteOriginalPlaneVTKByDis | ( | FILE * | fp, |
WlzMeshTransform2D5 * | wmt2D5 | ||
) |
output the orginal surface corresponding to the cut plane represented by the postion of the same mesh.
fp | pointer pointing to a specific file. |
wmt2D5,: | the 2D5 mesh transform. |
References _WlzMeshTransform2D5::elements, _WlzMeshTransform2D5::nElem, _WlzMeshTransform2D5::nNodes, _WlzMeshTransform2D5::nodes, and _WlzMeshTransform2D5::zConst.
void WlzEffWriteOriginalPlaneVTKByPos | ( | FILE * | fp, |
WlzMeshTransform2D5 * | wmt2D5 | ||
) |
output the cutted plane.
fp | pointer pointing to a specific file. |
wmt2D5 | mesh transform. |
References _WlzMeshTransform2D5::elements, _WlzMeshTransform2D5::nElem, _WlzMeshTransform2D5::nNodes, _WlzMeshTransform2D5::nodes, and _WlzMeshTransform2D5::zConst.
WlzDVertex2 WlzGeomTriangleCen2D | ( | WlzDVertex2 | v0, |
WlzDVertex2 | v1, | ||
WlzDVertex2 | v2 | ||
) |
Computes the position of the centroid of the given triangle in 2D.
v0 | First vertex of the triangle. |
v1 | Second vertex of the triangle. |
v2 | Third vertex of the triangle. |
References WLZ_VTX_2_ADD3, and WLZ_VTX_2_SCALE.
Referenced by WlzCMeshElmClosestPosIn2D().
WlzDVertex3 WlzGeomTriangleCen3D | ( | WlzDVertex3 | v0, |
WlzDVertex3 | v1, | ||
WlzDVertex3 | v2 | ||
) |
Computes the position of the centroid of the given triangle in 3D.
v0 | First vertex of the triangle. |
v1 | Second vertex of the triangle. |
v2 | Third vertex of the triangle. |
References WLZ_VTX_3_ADD3, and WLZ_VTX_3_SCALE.
WlzDVertex3 WlzGeomTetrahedronCen3D | ( | WlzDVertex3 | v0, |
WlzDVertex3 | v1, | ||
WlzDVertex3 | v2, | ||
WlzDVertex3 | v3 | ||
) |
Computes the position of the centroid of the given tetrahedron in 3D.
v0 | First vertex of the tetrahedron. |
v1 | Second vertex of the tetrahedron. |
v2 | Third vertex of the tetrahedron. |
v3 | Fourth vertex of the tetrahedron. |
References WLZ_VTX_3_ADD4, and WLZ_VTX_3_SCALE.
Referenced by WlzCMeshElmClosestPosIn3D().
int WlzGeomTriangleCircumcentre | ( | WlzDVertex2 * | ccVx, |
WlzDVertex2 | vx0, | ||
WlzDVertex2 | vx1, | ||
WlzDVertex2 | vx2 | ||
) |
Computes the circumcentre of the given triangle.
Given a triangle then the circumcentre
is given by:
Where:
This is taken from J. O'Rourke: Computational Geometry in C, p201.
ccVx | Destination pointer for the circumcentre. |
vx0 | First vertex of triangle. |
vx1 | Second vertex of triangle. |
vx2 | Third vertex of triangle. |
References ALG_DBL_TOLLERANCE, _WlzDVertex2::vtX, and _WlzDVertex2::vtY.
Referenced by WlzMeshElemSplit().
int WlzGeomVxInTriangle2D | ( | WlzDVertex2 | p0, |
WlzDVertex2 | p1, | ||
WlzDVertex2 | p2, | ||
WlzDVertex2 | pP | ||
) |
Tests whether the given vertex lies within the given triangle using a barycentric coordinates test.
If a triangle has vertices , then any point in the plane containing the triangle can be represented by:
subject to the constraint:
is outside the triangle at one or more of
,
and
is -ve. It is inside if all are +ve and on an edge of the triangle if any are close to zero (ie < ALG_DBL_TOLLERANCE).
p0 | First vertex of triangle. |
p1 | Second vertex of triangle. |
p2 | Third vertex of triangle. |
pP | Given vertex. |
References ALG_DBL_TOLLERANCE, _WlzDVertex2::vtX, _WlzDVertex2::vtY, and WLZ_VTX_2_SUB.
Referenced by WlzCMeshElmEnclosesPos2D().
int WlzGeomVxInTriangle3D | ( | WlzDVertex3 | v0, |
WlzDVertex3 | v1, | ||
WlzDVertex3 | v2, | ||
WlzDVertex3 | vQ, | ||
double | vPMax | ||
) |
First finds the closest point on the plane of the triangle to the given point. Then if the distance from the point to the plane is less than the given tolerance vvalue tests to set if the given vertex lies within the given triangle using a barycentric coordinates test (see WlzGeomVxInTriangle2D()).
v0 | First vertex of triangle. |
v1 | Second vertex of triangle. |
v2 | Third vertex of triangle. |
vQ | Given query vertex. |
vvMax | Maximum plane vertex distance. |
References ALG_DBL_TOLLERANCE, WLZ_VTX_3_CROSS, WLZ_VTX_3_DOT, WLZ_VTX_3_SCALE, WLZ_VTX_3_SQRLEN, and WLZ_VTX_3_SUB.
Referenced by WlzCMeshElmEnclosesPos2D5().
int WlzGeomVxInTetrahedron | ( | WlzDVertex3 | v0, |
WlzDVertex3 | v1, | ||
WlzDVertex3 | v2, | ||
WlzDVertex3 | v3, | ||
WlzDVertex3 | vP | ||
) |
Tests whether the given vertex lies within the given tetrahedron using a barycentric coordinates test.
If a tetrahedron has vertices , then any point in the 3D space containing the tetrahedron can be represented by:
subject to the constraint:
is outside the tetrahedron if one or more of
,
,
and
is -ve. It is inside if all are +ve and on an edge of the tetrahedron if any are close to zero (ie fabs(x) < ALG_DBL_TOLLERANCE).
The barycentric coordinates are computed by inverting the The tetrahedron vertices
the barycentric coordinates
and the point to be queried
can be written
and solved for the the barycentric coordinates using
.
v0 | First vertex of tetrahedron. |
v1 | Second vertex of tetrahedron. |
v2 | Third vertex of tetrahedron. |
v3 | Fourth vertex of tetrahedron. |
vP | Given vertex. |
References ALG_DBL_TOLLERANCE, _WlzDVertex3::vtX, _WlzDVertex3::vtY, and _WlzDVertex3::vtZ.
Referenced by WlzCMeshElmEnclosesPos3D().
double WlzGeomTriangleSnArea2 | ( | WlzDVertex2 | vx0, |
WlzDVertex2 | vx1, | ||
WlzDVertex2 | vx2 | ||
) |
Computes twice the signed area of the given triangle.
Computes twice the signed area of the given triangle. The determinant is NOT computed with:
instead the factorized form is used because it is more robust numericaly.
vx0 | First vertex of triangle. |
vx1 | Second vertex of triangle. |
vx2 | Third vertex of triangle. |
References _WlzDVertex2::vtX, and _WlzDVertex2::vtY.
Referenced by WlzCMeshBoundConform2D(), WlzCMeshCmpElmFeat2D(), WlzCMeshElmSnArea22D(), WlzCMeshFixNegativeElms2D(), WlzCMeshSetElm2D(), WlzGMEdgeTInsertRadial(), WlzMeshClosestNod2D(), WlzMeshElemFindVxWalk(), WlzMeshElemReplace1(), WlzMeshElemReplaceNWithN(), WlzMeshElemSplit(), WlzMeshElemVerify(), WlzMeshIDomAdd(), WlzMeshTransformAdapt(), WlzMeshVxVecAdd(), and WlzNoAreaGreaterThanOne().
double WlzGeomTetraSnVolume6 | ( | WlzDVertex3 | vx0, |
WlzDVertex3 | vx1, | ||
WlzDVertex3 | vx2, | ||
WlzDVertex3 | vx3 | ||
) |
Computes six times the signed volume of the given tetrahedron.
The signed volume is computed using simple determinant evaluation:
which can be written
Simple evaluation of this determinant is not robust.
vx0 | First vertex of tetrahedron. |
vx1 | Second vertex of tetrahedron. |
vx2 | Third vertex of tetrahedron. |
vx3 | Forth vertex of tetrahedron. |
References _WlzDVertex3::vtX, _WlzDVertex3::vtY, and _WlzDVertex3::vtZ.
Referenced by WlzCMeshBoundConform3D(), WlzCMeshCmpElmFeat3D(), WlzCMeshElmSnVolume63D(), WlzCMeshFixNegativeElms3D(), WlzCMeshSetElm3D(), and WlzGeomTetraInSphereDiam().
double WlzGeomTriangleArea2Sq3 | ( | WlzDVertex3 | vx0, |
WlzDVertex3 | vx1, | ||
WlzDVertex3 | vx2 | ||
) |
Computes twice the square of the area of the given 3D triangle.
A nieve approach is used in which the area is computed using:
Where and
.
vx0 | First vertex of triangle ![]() |
vx1 | Second vertex of triangle ![]() |
vx2 | Third vertex of triangle ![]() |
References WLZ_VTX_3_CROSS, WLZ_VTX_3_SQRLEN, and WLZ_VTX_3_SUB.
Referenced by WlzCMeshElmSqArea22D5(), WlzCMeshSetElm2D5(), WlzGeomTetraInSphereDiam(), WlzGMModelConstructSimplex3N(), and WlzGMModelSpxStats().
int WlzGeomInTriangleCircumcircle | ( | WlzDVertex2 | vx0, |
WlzDVertex2 | vx1, | ||
WlzDVertex2 | vx2, | ||
WlzDVertex2 | gVx | ||
) |
Tests to see if the given vertex is inside the circumcircle of the given triangle.
vx0 | First vertex of triangle. |
vx1 | Second vertex of triangle. |
vx2 | Third vertex of triangle. |
gVx | Given vertex to test. |
References _WlzDVertex2::vtX, and _WlzDVertex2::vtY.
int WlzGeomLineSegmentsIntersect | ( | WlzDVertex2 | p0, |
WlzDVertex2 | p1, | ||
WlzDVertex2 | q0, | ||
WlzDVertex2 | q1, | ||
WlzDVertex2 * | dstN | ||
) |
Tests to see if the two given line segments intersect.
Tests to see if the two given line segments intersect using the ALG_DBL_TOLLERANCE tollerance value. This is taken from J. O'Rourke: Computational Geometry in C, p250, but has ben modified to include the use of ALG_DBL_TOLLERANCE.
p0 | 1st vertex of 1st line segment. |
p1 | 2nd vertex 1st line segment. |
q0 | 1st vertex of 2nd line segment. |
q1 | 2nd vertex of 2nd line segment. |
dstN | Destination ptr for intersection vertex, may be NULL. The intersection value is not set if there is no intersection or the intersection is along the line segmants. |
References ALG_DBL_TOLLERANCE, _WlzDVertex2::vtX, and _WlzDVertex2::vtY.
int WlzGeomCmpAngle | ( | WlzDVertex2 | p0, |
WlzDVertex2 | p1 | ||
) |
Given two end connected 2D line segments this function compares the CCW angle of the segments.
Given two end connected 2D line segments: and
, compares the CCW angle of the segments, where
is the origin
.
p0 | 1st segment endpoint vertex. |
p1 | 2nd segment endpoint vertex. |
References ALG_DBL_TOLLERANCE, _WlzDVertex2::vtX, and _WlzDVertex2::vtY.
int WlzGeomVtxEqual2D | ( | WlzDVertex2 | pos0, |
WlzDVertex2 | pos1, | ||
double | tolSq | ||
) |
Checks to see if two verticies are the same within some tollerance.
pos0 | First node position. |
pos1 | Second node position. |
tolSq | Square of tollerance value. |
References _WlzDVertex2::vtX, and _WlzDVertex2::vtY.
Referenced by WlzGeomVtxOnLineSegment2D(), and WlzGMModelConstructSimplex2N().
int WlzGeomVtxEqual3D | ( | WlzDVertex3 | pos0, |
WlzDVertex3 | pos1, | ||
double | tol | ||
) |
Checks to see if two verticies are the same within some tollerance.
pos0 | First node position. |
pos1 | Second node position. |
tol | Tollerance value. |
References _WlzDVertex3::vtX, _WlzDVertex3::vtY, and _WlzDVertex3::vtZ.
void WlzGeomVtxSortRadial | ( | int | nV, |
WlzDVertex3 * | vP, | ||
int * | idxBuf, | ||
WlzDVertex2 * | wP, | ||
WlzDVertex3 | rV | ||
) |
Sorts the given 3D verticies, which lie in a plane perpendicular to the radial vector, in order of their angle the radial vector.
Sorts the given 3D verticies, which lie in a plane perpendicular to the radial vector, in order of their angle the radial vector. No checks are made of the given parameters validity, it's assumed that: (nV > 0) && (vP != NULL) && (wP != NULL) && (iP != NULL) (|rV| > 0) && (rV.(uV = *vP) == 0) Note that it is the indicies that are sorted NOT the verticies themselves.
nV | Number of 3D verticies. |
vP | The 3D verticies. |
idxBuf | Buffer of nV indicies used for sorting the verticies. |
wP | Workspace with nV 2D verticies. |
rV | The radial vector. |
References AlgHeapSortIdx(), WLZ_VTX_3_CROSS, WLZ_VTX_3_DOT, WLZ_VTX_3_LENGTH, and WLZ_VTX_3_SCALE.
WlzDVertex3 WlzGeomTriangleNormal | ( | WlzDVertex3 | v0, |
WlzDVertex3 | v1, | ||
WlzDVertex3 | v2 | ||
) |
Computes the unit normal vector perpendicular to the triangle .
v0 | First vertex of triangle. |
v1 | Second vertex of triangle. |
v2 | Third vertex of triangle. |
References ALG_DBL_TOLLERANCE, _WlzDVertex3::vtX, _WlzDVertex3::vtY, _WlzDVertex3::vtZ, WLZ_VTX_3_CROSS, WLZ_VTX_3_LENGTH, WLZ_VTX_3_SCALE, and WLZ_VTX_3_SUB.
Referenced by WlzCMeshComputeNormalsElm(), WlzCMeshIntersectDom2D5(), and WlzGMVertexNormal3D().
int WlzGeomTriangleAABBIntersect2D | ( | WlzDVertex2 | t0, |
WlzDVertex2 | t1, | ||
WlzDVertex2 | t2, | ||
WlzDVertex2 | b0, | ||
WlzDVertex2 | b1, | ||
int | tst | ||
) |
Tests for an intersection between the given triangle and the axis aligned bounding box using the Separating Axis Theorem (SAT).
Given an axis aligned bounding box and a triangle this function tests for an intersection using the Separating Axis Theorem (SAT) which states : Two 2D convex domains do not intersect iff there exists a line, called a separating axis, on which projection intervals of the domains do not intersect. The minimal set of axes that need to be considered is formed by the normals to all edges of the (polygonal) domains. For an axis aligned bounding box and a triangle in 2D, this is equivalent to testing for the intersection of the given axis aligned bounding box with the axis aligned bounding box of the triangle and the axes normal to the faces of the triangle. The mathematics are simplified by the box being axis aligned.
The algorithm may return false positives when the domains are very close to touching.
t0 | First vertex of triangle. |
t1 | Second vertex of triangle. |
t2 | Third vertex of triangle. |
b0 | Minimum coordinates of axis aligned bounding box. |
b1 | Maximum coordinates of axis aligned bounding box. |
tst | Determines the actual intersection tests used: 0 - AABB / triangle. 1 - AABB / AABB(triangle) only. 2 - AABB / triangle omitting the AABB / AABB(triangle) test this is probably only useful if the AABB / AABB(triangle) are known to intersect. |
References ALG_DBL_TOLLERANCE, ALG_MAX3, ALG_MIN3, _WlzDVertex2::vtX, _WlzDVertex2::vtY, and WLZ_VTX_2_SUB.
int WlzGeomTetrahedronAABBIntersect3D | ( | WlzDVertex3 | t0, |
WlzDVertex3 | t1, | ||
WlzDVertex3 | t2, | ||
WlzDVertex3 | t3, | ||
WlzDVertex3 | b0, | ||
WlzDVertex3 | b1, | ||
int | tst | ||
) |
Tests for an intersection between the given tetrahedron and the axis aligned bounding box using the Separating Axis Theorem (SAT).
Given an axis aligned bounding box and a tetrahedron this function tests for an intersection using the Separating Axis Theorem (SAT) which states : Two 3D convex domains do not intersect iff there exists a line, called a separating axis, on which projection intervals of the domains do not intersect. The minimal set of axes that need to be considered is formed by the normals to all faces of the (polyhedral) domains and the cross product of all edge combinations in which one edge is from each polyhedron. For an axis aligned bounding box and a tetrahedron in 3D, this is equivalent to testing for the intersection of the given axis aligned bounding box with the axis aligned bounding box of the tetrahedron, testing for intersections on the axes normal to the faces of the tetrahedron and testing for intersection along the cross product of the axis aligned bounding box - tetrahedron edges. The mathematics are simplified by the box being axis aligned.
The algorithm may return false positives when the domains are very close to touching.
t0 | First vertex of tetrahedron. |
t1 | Second vertex of tetrahedron. |
t2 | Third vertex of tetrahedron. |
t3 | Fourth vertex of tetrahedron. |
b0 | Minimum coordinates of axis aligned bounding box. |
b1 | Maximum coordinates of axis aligned bounding box. |
tst | Determines the actual intersection tests used: 0 - AABB / tetrahedron. 1 - AABB / AABB(tetrahedron) only. 2 - AABB / tetrahedron omitting the AABB / AABB(tetrahedron) test this is probably only useful if the AABB / AABB(tetrahedron) are known to intersect. |
References ALG_DBL_TOLLERANCE, _WlzDVertex3::vtX, _WlzDVertex3::vtY, _WlzDVertex3::vtZ, WLZ_VTX_3_CROSS, WLZ_VTX_3_SQRLEN, and WLZ_VTX_3_SUB.
int WlzGeomPlaneAABBIntersect | ( | double | a, |
double | b, | ||
double | c, | ||
double | d, | ||
WlzDBox3 | box | ||
) |
Tests for an intersection between the plane defined by the equation: and the given axis aligned bounding box.
a | Plane X parameter. |
b | Plane Y parameter. |
c | Plane Z parameter. |
d | Other plane parameter. |
box | Axis aligned bounding box. |
References ALG_DBL_TOLLERANCE, _WlzDVertex3::vtX, _WlzDVertex3::vtY, _WlzDVertex3::vtZ, _WlzDBox3::xMax, _WlzDBox3::xMin, _WlzDBox3::yMax, _WlzDBox3::yMin, _WlzDBox3::zMax, and _WlzDBox3::zMin.
Referenced by Wlz3DViewIntersectAABB().
int WlzGeomPlaneLineIntersect | ( | double | a, |
double | b, | ||
double | c, | ||
double | d, | ||
WlzDVertex3 | p0, | ||
WlzDVertex3 | p1, | ||
WlzDVertex3 * | dstIsn | ||
) |
Tests for an intersection between the plane defined by the equation: and the line segment with end points
and
.
a | Plane X parameter. |
b | Plane Y parameter. |
c | Plane Z parameter. |
d | Other plane parameter. |
p0 | First end point of the line segment. |
p1 | Second end point of the line segment. |
dstIsn | Destination pointer for point of intersection, may be NULL. |
References ALG_DBL_TOLLERANCE, _WlzDVertex3::vtX, _WlzDVertex3::vtY, and _WlzDVertex3::vtZ.
Referenced by WlzGeomPlaneTriangleIntersect().
int WlzGeomPlaneTriangleIntersect | ( | double | a, |
double | b, | ||
double | c, | ||
double | d, | ||
WlzDVertex3 | p0, | ||
WlzDVertex3 | p1, | ||
WlzDVertex3 | p2, | ||
WlzDVertex3 * | dstIsn0, | ||
WlzDVertex3 * | dstIsn1 | ||
) |
Tests for an intersection between a plane and a triangle.
Tests for an intersection between the plane defined by the equation: and the triangle with end verticies
,
and
. If the destination pointers for the intersection points are not NULL and the intersection code is 1 then the single point of intersection is returned in dstIsn0. If the destination pointers are not NULL and the intersection code is either 1 or 2 then the twther the single intersection point is returned in dstIsn0 or the two intersection points are returned in dstIsn0 and dstIsn1.
a | Plane X parameter. |
b | Plane Y parameter. |
c | Plane Z parameter. |
d | Other plane parameter. |
p0 | First triangle vertex. |
p1 | Second triangle vertex. |
p2 | Third triangle vertex. |
dstIsn0 | Destination pointer for first point of intersection, may be NULL. |
dstIsn1 | Destination pointer for second point of intersection, may be NULL. |
References ALG_DBL_TOLLERANCE, WLZ_VTX_3_SQRLEN, WLZ_VTX_3_SUB, and WlzGeomPlaneLineIntersect().
Referenced by WlzGetSectionFromGMModel().
double WlzGeomEllipseVxDistSq | ( | WlzDVertex2 | centre, |
WlzDVertex2 | sAx, | ||
WlzDVertex2 | gPnt | ||
) |
Given an ellipse defined by it's centre and it's semi axes
. This function computes the square of the ratio of the distances from the centre of the ellipse to the given point and from the centre of the ellipse in the direction of the given point to the ellipse.
Equation of ellipse is:
and a straight line through the origin:
Solving for and
at the ellipse gives the square of the distance ratio for given point
is
with .
centre | Centre of ellipse. |
sAx | Ellipse semi axes, both ![]() |
gPnt | Given point. |
References ALG_DBL_TOLLERANCE, _WlzDVertex2::vtX, _WlzDVertex2::vtY, and WLZ_VTX_2_SUB.
unsigned int WlzGeomHashVtx3D | ( | WlzDVertex3 | pos, |
double | tol | ||
) |
Computes a hash value from a given 3D double precision position.
pos | Given position. |
tol | Tolerance, ![]() |
References _WlzDVertex3::vtX, _WlzDVertex3::vtY, and _WlzDVertex3::vtZ.
Referenced by WlzGMModelAddVertexToHT(), WlzGMModelMatchVertexG3D(), and WlzGMModelRemVertex().
unsigned int WlzGeomHashVtx2D | ( | WlzDVertex2 | pos, |
double | tol | ||
) |
Computes a hash value from a given 2D double precision position.
pos | Given position. |
tol | Tolerance, ![]() |
References _WlzDVertex2::vtX, and _WlzDVertex2::vtY.
Referenced by WlzGMModelMatchVertexG2D().
int WlzGeomCmpVtx3D | ( | WlzDVertex3 | pos0, |
WlzDVertex3 | pos1, | ||
double | tol | ||
) |
Compares the coordinates of the given 3D double precision vertices to find a signed value for sorting.
pos0 | First vertex. |
pos1 | Second vertex. |
tol | Tolerance, ![]() |
References _WlzDVertex3::vtX, _WlzDVertex3::vtY, _WlzDVertex3::vtZ, and WLZ_VTX_3_SUB.
Referenced by WlzBasisFnIMQ3DFromCPts(), WlzBasisFnMQ3DFromCPts(), and WlzGMVertexCmpSign3D().
int WlzGeomCmpVtx2D | ( | WlzDVertex2 | pos0, |
WlzDVertex2 | pos1, | ||
double | tol | ||
) |
Compares the coordinates of the given 2D double precision vertices to find a signed value for sorting.
pos0 | First vertex. |
pos1 | Second vertex. |
tol | Tolerance, ![]() |
References _WlzDVertex2::vtX, _WlzDVertex2::vtY, and WLZ_VTX_2_SUB.
Referenced by WlzBasisFnGauss2DFromCPts(), WlzBasisFnIMQ2DFromCPts(), WlzBasisFnMQ2DFromCPts(), WlzBasisFnTPS2DFromCPts(), and WlzGMVertexCmpSign2D().
WlzDVertex2 WlzGeomUnitVector2D | ( | WlzDVertex2 | vec | ) |
Computes the 2D unit vector .
vec | Given vector, ![]() |
References ALG_DBL_TOLLERANCE, _WlzDVertex2::vtX, _WlzDVertex2::vtY, WLZ_VTX_2_LENGTH, and WLZ_VTX_2_SCALE.
WlzDVertex3 WlzGeomUnitVector3D | ( | WlzDVertex3 | vec | ) |
Computes the 3D unit vector .
vec | Given vector, ![]() |
References ALG_DBL_TOLLERANCE, _WlzDVertex3::vtX, _WlzDVertex3::vtY, _WlzDVertex3::vtZ, WLZ_VTX_3_LENGTH, and WLZ_VTX_3_SCALE.
WlzDVertex2 WlzGeomUnitVector2D2 | ( | WlzDVertex2 | v1, |
WlzDVertex2 | v0 | ||
) |
Computes the unit 2D vector with the direction given by . If the two given vertices are coincident then a zero vector is returned instead of a unit vector.
v1 | Position of vertex, ![]() |
v0 | Position of vertex, ![]() |
References ALG_DBL_TOLLERANCE, _WlzDVertex2::vtX, _WlzDVertex2::vtY, WLZ_VTX_2_LENGTH, WLZ_VTX_2_SCALE, and WLZ_VTX_2_SUB.
WlzDVertex3 WlzGeomUnitVector3D2 | ( | WlzDVertex3 | v1, |
WlzDVertex3 | v0 | ||
) |
Computes the unit 3D vector with the direction given by . If the two given vertices are coincident then a zero vector is returned instead of a unit vector.
v1 | Position of vertex, ![]() |
v0 | Position of vertex, ![]() |
References ALG_DBL_TOLLERANCE, _WlzDVertex3::vtX, _WlzDVertex3::vtY, _WlzDVertex3::vtZ, WLZ_VTX_3_LENGTH, WLZ_VTX_3_SCALE, and WLZ_VTX_3_SUB.
int WlzGeomVertexInDiamCircle | ( | WlzDVertex2 | lPos0, |
WlzDVertex2 | lPos1, | ||
WlzDVertex2 | pos | ||
) |
Determines whether a point is inside the diametral circle of a line segment. If two vectors and
are directed from the line segment end points to the point, then the angle between the vectors is
if the point is inside the diametral circle,
if it lies on the circle and
if it lies outside the circle. This is easily tested by
.
lPos0 | Vertex at one end of line segment. |
lPos1 | Vertex at other end of line segment. |
pos | Position of point. |
References WLZ_VTX_2_DOT, and WLZ_VTX_2_SUB.
int WlzGeomItrSpiralRing | ( | int | step | ) |
Computes the ring of a spiral. If two rings differ by more than one then at least one itteration outwards on the spiral has been performed between the rings.
step | Spiral step count. |
Referenced by WlzCMeshClosestNod2D(), WlzCMeshClosestNod2D5(), WlzCMeshClosestNod3D(), WlzCMeshElmClosestPosIn2D(), and WlzCMeshElmClosestPosIn3D().
int WlzGeomItrSpiral2I | ( | int | step, |
int * | pX, | ||
int * | pY | ||
) |
Iterates the given positions coordinates through a 2D expanding integer spiral.
step | Spiral step count, must be zero when this function is called for the for first step. |
pX | Destination pointer for column coordinate. |
pY | Destination pointer for line coordinate. |
Referenced by WlzCMeshClosestNod2D(), and WlzCMeshElmClosestPosIn2D().
int WlzGeomItrSpiralShell | ( | int | step | ) |
Computes the shell of a spiral. If two shells differ by more than one then at least one itteration outwards on the spiral has been performed between the shells.
step | Spiral step count. |
References cbrt().
int WlzGeomItrSpiral3I | ( | int | step, |
int * | pX, | ||
int * | pY, | ||
int * | pZ | ||
) |
Iterates the given positions coordinates through a 3D expanding integer spiral.
step | Spiral step count, must be zero when this function is called for the for first step. |
pX | Destination pointer for column coordinate. |
pY | Destination pointer for line coordinate. |
pZ | Destination pointer for plane coordinate. |
References cbrt().
Referenced by WlzCMeshClosestNod2D5(), WlzCMeshClosestNod3D(), and WlzCMeshElmClosestPosIn3D().
double WlzGeomDistSq2D | ( | WlzDVertex2 | v0, |
WlzDVertex2 | v1 | ||
) |
Computes square of the Euclidean distance between the given two vertices.
v0 | First of the given vertices. |
v1 | Second of the given vertices. |
References WLZ_VTX_2_SQRLEN, and WLZ_VTX_2_SUB.
Referenced by WlzCMeshElmMaxSqEdgLen2D(), and WlzCMeshUpdateMaxSqEdgLen2D().
double WlzGeomDistSq3D | ( | WlzDVertex3 | v0, |
WlzDVertex3 | v1 | ||
) |
Computes square of the Euclidean distance between the given two vertices.
v0 | First of the given vertices. |
v1 | Second of the given vertices. |
References WLZ_VTX_3_SQRLEN, and WLZ_VTX_3_SUB.
Referenced by WlzCMeshElmMaxSqEdgLen2D5(), WlzCMeshElmMaxSqEdgLen3D(), WlzCMeshUpdateMaxSqEdgLen2D5(), and WlzCMeshUpdateMaxSqEdgLen3D().
double WlzGeomDist2D | ( | WlzDVertex2 | v0, |
WlzDVertex2 | v1 | ||
) |
Computes the Euclidean distance between the given two vertices.
v0 | First of the given vertices. |
v1 | Second of the given vertices. |
References WLZ_VTX_2_LENGTH, and WLZ_VTX_2_SUB.
double WlzGeomDist3D | ( | WlzDVertex3 | v0, |
WlzDVertex3 | v1 | ||
) |
Computes the Euclidean distance between the given two vertices.
v0 | First of the given vertices. |
v1 | Second of the given vertices. |
References WLZ_VTX_3_LENGTH, and WLZ_VTX_3_SUB.
int WlzGeomTriangleAffineSolve | ( | double * | xTr, |
double * | yTr, | ||
double | dd, | ||
WlzDVertex2 * | sVx, | ||
WlzDVertex2 * | dVx, | ||
double | thresh | ||
) |
If the unsigned area of the triangle is very small then the only the transform translation coefficients are computed with the other coefficients being set to zero. If the unsigned area of the triangle is not very small then a system of linear equations is solved for the coefficients of the 2D affine transform from the source triangle to the destination triangle.
xTr | Transform coordinates for x. |
yTr | Transform coordinates for y. |
dd | Twice the area of the source triangle. |
sVx | Source triangle vertices. |
dVx | Destination triangle vertices. |
thresh | Threshold value for twice the area. |
References _WlzDVertex2::vtX, and _WlzDVertex2::vtY.
int WlzGeomTetraAffineSolveLU | ( | double * | tr, |
WlzDVertex3 * | sVx, | ||
WlzDVertex3 * | dVx | ||
) |
Computes the affine transform coefficients from the source to target tetrahedron.
This is done by solving for general 3D affine transform matrix which transforms the source tetrahedrons vertices to those of the destination tetrahedron If the destination tetrahedron vertices are given by
and the source vertices by
then the transform being sought satisfies
Solving for
LU decomposition is used to solve for . For the degenerate cases the transformation is given as a simple translation. This function is slower than WlzGeomTetraAffineSolve() by about a factor of 8, but it may be more robust.
tr | Transform matrix with 4x4 contiguous coefficients which are equivalent to the base storage of the matrix in a WlzAffineTransform. |
sVx | Source tetrahedron vertices. |
dVx | Destination tetrahedron vertices. |
References AlgMatrixLUInvertRaw4(), _WlzDVertex3::vtX, _WlzDVertex3::vtY, and _WlzDVertex3::vtZ.
int WlzGeomTetraAffineSolve | ( | double * | tr, |
WlzDVertex3 * | sVx, | ||
WlzDVertex3 * | dVx, | ||
double | thresh | ||
) |
Computes the affine transform coefficients from the source to target tetrahedron.
This is done by solving for general 3D affine transform matrix which transforms the source tetrahedrons vertices to those of the destination tetrahedron If the destination tetrahedron vertices are given by
and the source vertices by
then the transform being sought satisfies
Solving for
Setting
with
and
For efficiency the followingcollect common sub-expressions are used
giving
and for the non-degenerate case, when
and so ( )
For the degenerate cases in which then the transformation is given as a simple translation.
tr | Transform matrix with 4x4 contiguous coefficients which are equivalent to the base storage of the matrix in a WlzAffineTransform. |
sVx | Source tetrahedron vertices. |
dVx | Destination tetrahedron vertices. |
thresh | Threshold value which is the lower limit of 6 x the source tetrahedron's volume. |
References _WlzDVertex3::vtX, _WlzDVertex3::vtY, and _WlzDVertex3::vtZ.
WlzDVertex2 WlzGeomObjLineSegIntersect2D | ( | WlzObject * | obj, |
WlzDVertex2 | p0, | ||
WlzDVertex2 | p1, | ||
double | tol, | ||
int | inside, | ||
int | method, | ||
int * | dstStat | ||
) |
Given a Woolz object and two vertices, finds the position along a line segment between the two vertices which is just inside/outside the boundary of the object. The destination pointer is used to return the status of the vertices, using the following code: 0 - One of the given verticies was inside and the other outside, 1 - Both the given verticies were inside, 2 - Both the given verticies were outside. This function assumes that the line segment only crosses the object's boundary once.
Given the line segment ,
any position along the segment can be given by a parameter
(range [0-1]), where
.
obj | Given object. Object must have a valid domain. |
p0 | First vertex. |
p1 | Second vertex. |
tol | Acceptable placement error. |
inside | Non-zero if the returned position should be inside or on the boundary, if zero it will be outside or on the boundary. |
method | Method for finding intersection: 0 - bisection, 1 - increment. If increment is used each point along the line segment will be tested until termination, this may be very slow if tol is small, with possibly 1/tol incremental steps. |
dstStat | Destination pointer for status, may be NULL. |
References ALG_MAX, _WlzDVertex2::vtX, _WlzDVertex2::vtY, WLZ_VTX_2_ADD, WLZ_VTX_2_LENGTH, WLZ_VTX_2_SCALE, WLZ_VTX_2_SQRLEN, WLZ_VTX_2_SUB, and WlzInsideDomain().
Referenced by WlzCMeshBoundConform2D().
WlzDVertex3 WlzGeomObjLineSegIntersect3D | ( | WlzObject * | obj, |
WlzDVertex3 | p0, | ||
WlzDVertex3 | p1, | ||
double | tol, | ||
int | inside, | ||
int | method, | ||
int * | dstStat | ||
) |
Given a Woolz object and two vertices, finds the position along a line segment between the two vertices which is just inside/outside the boundary of the object. The destination pointer is used to return the status of the vertices, using the following code: 0 - One of the given verticies was inside and the other outside, 1 - Both the given verticies were inside, 2 - Both the given verticies were outside. This function assumes that the line segment only crosses the object's boundary once.
Given the line segment ,
any position along the segment can be given by a parameter
(range [0-1]), where
.
obj | Given object. Object must have a valid domain. |
p0 | First vertex. |
p1 | Second vertex. |
tol | Acceptable placement error. |
inside | Non-zero if the returned position should be inside or on the boundary, if zero it will be outside or on the boundary. |
method | Method for finding intersection: 0 - bisection, 1 - increment. If increment is used each point along the line segment will be tested until termination, this may be very slow if tol is small, with possibly 1/tol incremental steps. |
dstStat | Destination pointer for status, may be NULL. |
References ALG_MAX3, _WlzDVertex3::vtX, _WlzDVertex3::vtY, _WlzDVertex3::vtZ, WLZ_VTX_3_ADD, WLZ_VTX_3_LENGTH, WLZ_VTX_3_SCALE, WLZ_VTX_3_SQRLEN, WLZ_VTX_3_SUB, and WlzInsideDomain().
Referenced by WlzCMeshBoundConform3D().
double WlzGeomTetraInSphereDiam | ( | WlzDVertex3 | vx0, |
WlzDVertex3 | vx1, | ||
WlzDVertex3 | vx2, | ||
WlzDVertex3 | vx3 | ||
) |
Given the coordinates of the four vertices of a tetrahedron the function computes the maximum diameter of an inscribed sphere.
Diameter of the (maximum) inscribed sphere is given by:
where is the volume of the tetrahedron and
is it's surface area. "Encyclopedia of Mathematics" ISBN 1402006098 (http://eom.springer.de).
vx0 | First vertex of tetrahedron. |
vx1 | Second vertex of tetrahedron. |
vx2 | Third vertex of tetrahedron. |
vx3 | Forth vertex of tetrahedron. |
References ALG_DBL_TOLLERANCE, WlzGeomTetraSnVolume6(), and WlzGeomTriangleArea2Sq3().
double WlzGeomTetraInSphereRegDiam | ( | double | side | ) |
Given the side length of a regular tetrahedron this function computes the maximum diameter of an inscribed sphere.
Diameter of the (maximum) inscribed sphere is given by:
where is the volume of the tetrahedron and
is it's surface area. "Encyclopedia of Mathematics" ISBN 1402006098 (http://eom.springer.de). Standard formulae are used for the area and volume.
side | Length of an edge. |
References ALG_DBL_TOLLERANCE, ALG_M_SQRT2, and ALG_M_SQRT3.
double WlzGeomPolar2D | ( | WlzDVertex2 | org, |
WlzDVertex2 | dst, | ||
double * | dstRad | ||
) |
Computes the angle of a ray from the origin to the destination vertex along with the length of the ray. Angles are:
(y) ^ pi/2 | | pi | <------+-------> (x) | 0 | 3pi/2| V
org | Position of the origin. |
dst | Position of the destination. |
dstRad | Destination pointer for the length of the ray, may be NULL. |
References ALG_M_PI, _WlzDVertex2::vtX, _WlzDVertex2::vtY, WLZ_VTX_2_LENGTH, and WLZ_VTX_2_SUB.
double WlzGeomCos3V | ( | WlzDVertex2 | v0, |
WlzDVertex2 | v1, | ||
WlzDVertex2 | v2 | ||
) |
Computes the cosine of angle between line segments (v0, v1) and (v1, v2). If any of these vertices are coincident then zero is returned.
v0 | First vertex. |
v1 | Second vertex (the common one). |
v2 | Third vertex. |
References ALG_DBL_TOLLERANCE, WLZ_VTX_2_SQRLEN, and WLZ_VTX_2_SUB.
int WlzGeomVtxOnLineSegment2D | ( | WlzDVertex2 | tst, |
WlzDVertex2 | seg0, | ||
WlzDVertex2 | seg1, | ||
double | tol | ||
) |
Tests whether the given test vertex is on the given line segment. If all three vertices are coincident then the test vertex is considered to line on the line segment.
tst | Test vertex. |
seg0 | First vertex of line segment. |
seg1 | Second vertex of line segment. |
tol | Tollerance. |
References _WlzDVertex2::vtX, _WlzDVertex2::vtY, WLZ_VTX_2_SUB, WlzGeomVtxEqual2D(), _WlzDBox2::xMax, _WlzDBox2::xMin, _WlzDBox2::yMax, and _WlzDBox2::yMin.
int WlzGeomVtxOnLineSegment3D | ( | WlzDVertex3 | pX, |
WlzDVertex3 | p0, | ||
WlzDVertex3 | p1, | ||
WlzDVertex3 * | dstN | ||
) |
Tests whether the given test vertex is on the given line segment. If all three vertices are coincident then the test vertex is considered to be coincident with an end point on the line segment.
Consider a line segment from a vertex at to another vertex at
, with a third test vertex at
, the shortest path from
to the line segment will be perpendicular to the line segment. Let the position of the intersection of this perpendicular with the line segment be at
, with distance
from {p_x}, then:
and after substitution:
Observing that the numerator is a vector quad product
gives
Obviously if is on the line segment then
. ALG_DBL_TOLLERANCE as a tolerance for squared distances in this function.
pX | Test vertex. |
p0 | First vertex of line segment. |
p1 | Second vertex of line segment. |
dstN | Destination pointer for the intersection, may be NULL. |
References ALG_DBL_TOLLERANCE, WLZ_VTX_3_CROSS, WLZ_VTX_3_DOT, WLZ_VTX_3_SCALE_ADD, WLZ_VTX_3_SQRLEN, and WLZ_VTX_3_SUB.
Referenced by WlzGeomLineLineSegmentIntersect3D().
double WlzGeomArcLength2D | ( | WlzDVertex2 | a, |
WlzDVertex2 | b, | ||
WlzDVertex2 | c | ||
) |
Computes the arc length from a to b traveling CCW on a circle with centre c.
a | Start point. |
b | End point. |
c | Cirecle centre. |
References ALG_DBL_TOLLERANCE, ALG_M_PI, ALG_M_PI_2, _WlzDVertex2::vtX, _WlzDVertex2::vtY, WLZ_VTX_2_SQRLEN, and WLZ_VTX_2_SUB.
int WlzGeomRectFromWideLine | ( | WlzDVertex2 | s, |
WlzDVertex2 | t, | ||
double | w, | ||
WlzDVertex2 * | v | ||
) |
Computes the coordinates of vertices that may be used to draw a wide rectangle.
Given two vertices ,
which define a line segment and width
perpendicular to the line segent, this function computes the coordinates of the vertices
,
of the rectangle. The vertices are sorted such that the rectangle may be drawn using the line segmants:
,
,
,
. Given the line segment
it can be shown that the vertices which share a line segment passing through
are:
and
where and
. Should
and
be coincident then the destination rectangle vertices are left unmodified..
s | First vertex of line segment. |
t | Second vertex of line segment. |
w | line width. |
v | Destination pointer for the four vertices of the rectangle. |
References ALG_DBL_TOLLERANCE, _WlzDVertex2::vtX, _WlzDVertex2::vtY, WLZ_VTX_2_ADD, WLZ_VTX_2_LENGTH, and WLZ_VTX_2_SUB.
WlzDVertex3 WlzGeomLinePlaneIntersection | ( | WlzDVertex3 | v, |
WlzDVertex3 | p0, | ||
WlzDVertex3 | p1, | ||
WlzDVertex3 | p2, | ||
WlzDVertex3 | p3, | ||
int * | dstPar | ||
) |
Computes the intersection of a line with a plane.
Computes the intersection of line (vector ) through an off plane vertex (
) with a plane. The plane is defined by three on plane vertices
.
the vertex at the intersection is found by solving the vector equations
These are equivalunt to solving
v | Unit vector for ray. |
p0 | First point on the plane. |
p1 | Second point on the plane. |
p2 | Third point on the plane. |
p3 | Off plane point that ray passes through. |
dstPar | Destination value set to 1 if the vector is parrallel to the plane, must not be NULL. |
References ALG_DBL_TOLLERANCE, _WlzDVertex3::vtX, _WlzDVertex3::vtY, _WlzDVertex3::vtZ, and WLZ_VTX_3_SUB.
int WlzGeomLineTriangleIntersect3D | ( | WlzDVertex3 | org, |
WlzDVertex3 | dir, | ||
WlzDVertex3 | v0, | ||
WlzDVertex3 | v1, | ||
WlzDVertex3 | v2, | ||
int * | dstPar, | ||
double * | dstT, | ||
double * | dstU, | ||
double * | dstV | ||
) |
Tests whether a line directed from a given origin intersects a triangle in 3D space. This function is based on the algorithm: Tomas Moller and Ben Trumbore, "Fast, Minimum Storage Ray/Triangle Intersection", Journal of Graphics Tools, 1997(2), pp 25--30.
Given a parameterised line
and a triangle specified by it's vertices , the point of intersection may be written in terms of the barycentric coordinates
Solving for ,
and
gives
where ,
,
and
.
The and
are only set if the line passes through the triangle.
org | Line origin, ![]() |
dir | Line direction, ![]() |
v0 | First vertex on triangle. |
v1 | Second vertex on the triangle |
v2 | Third vertex on the triangle |
dstPar | Destination pointer for flag set to 1 if the vector is parrallel to the plane, may be NULL. |
dstT | Destination pointer for t parameter, may be NULL. |
dstU | Destination pointer for u parameter, may be NULL. |
dstV | Destination pointer for v parameter, may be NULL. |
References ALG_DBL_TOLLERANCE, _WlzGeomPolyListItem2D::v, WLZ_VTX_3_CROSS, WLZ_VTX_3_DOT, and WLZ_VTX_3_SUB.
int WlzGeomLineLineSegmentIntersect3D | ( | WlzDVertex3 | r0, |
WlzDVertex3 | rD, | ||
WlzDVertex3 | p0, | ||
WlzDVertex3 | p1, | ||
WlzDVertex3 * | dstN | ||
) |
Tests to see if the two given line segment is intersected by the given line using the ALG_DBL_TOLLERANCE tollerance value. The line is a line which passes through the given point to infinity (on both sides) with the given direction.
Given a line parameterised by :
and a line segment parameterised by :
their intersection at is given by
giving
If the denominator then the line and the line segment are parrallel, provided that
and
. The line segment is intersected by the line if
is in the range [0-1]. The point of intersection
is
Special cases are considered for ,
and
.
r0 | A vertex on the line. |
rD | Direction of the line. |
p0 | First end vertex of the line segment. |
p1 | Second end vertex of the line segment. |
dstN | Destination ptr for intersection vertex, may be NULL. The intersection value will be set if the ray and line segment intersect at a single point. |
References ALG_DBL_TOLLERANCE, _WlzGeomPolyListItem2D::v, _WlzDVertex3::vtX, _WlzDVertex3::vtY, _WlzDVertex3::vtZ, WLZ_VTX_3_CROSS, WLZ_VTX_3_SCALE_ADD, WLZ_VTX_3_SQRLEN, WLZ_VTX_3_SUB, WlzGeomVtxOnLine3D(), and WlzGeomVtxOnLineSegment3D().
int WlzGeomVtxOnLine3D | ( | WlzDVertex3 | p0, |
WlzDVertex3 | r0, | ||
WlzDVertex3 | rD | ||
) |
Tests whether a vertex is a line.
Tests whether the given vertex is on the given line
. If the point on the line and the given vertex are coincident then obviously the vertex is on the line otherwise the vertex is on the line if the squared length of the cross product of the line direction and the direction of the vertex (with respect to the point on the line) is less than ALG_DBL_TOLLERANCE, ie if
p0 | Given vertex. |
r0 | Point on line. |
rD | Direction of line. |
References ALG_DBL_TOLLERANCE, WLZ_VTX_3_CROSS, WLZ_VTX_3_SQRLEN, and WLZ_VTX_3_SUB.
Referenced by WlzGeomLineLineSegmentIntersect3D().
double WlzGeomInterpolateTri2D | ( | WlzDVertex2 | p0, |
WlzDVertex2 | p1, | ||
WlzDVertex2 | p2, | ||
double | v0, | ||
double | v1, | ||
double | v2, | ||
WlzDVertex2 | pX | ||
) |
Given the coordinates of the vertices of a 2D triangle and a set of values at each of these vertices, this function interpolates the value at the given position which is either inside or on an edge of the triangle. This is implimented using barycentric coordinates. Once the barycentric coordinates ( ,
,
) have been computed then the interpolated value is given by:
. If the determinant is zero in solving for the barycentric coordinates then the interpolated value is just the mean of the given values.
p0 | First vertex of triangle. |
p1 | Second vertex of triangle. |
p2 | Third vertex of triangle. |
v0 | Value at first vertex of triangle. |
v1 | Value at second vertex of triangle. |
v2 | Value at third vertex of triangle. |
pX | Given position, which is within (or on) the triangle. |
References ALG_DBL_TOLLERANCE, _WlzDVertex2::vtX, and _WlzDVertex2::vtY.
Referenced by WlzCMeshCurvToImage(), and WlzCMeshMeshMeshProduct().
double WlzGeomInterpolatePoly2D | ( | int | n, |
WlzDVertex2 * | p, | ||
double * | v, | ||
double * | w, | ||
WlzDVertex2 | q, | ||
WlzErrorNum * | dstErr | ||
) |
Given the vertex coordinates of an irregular possible non-convex 2D polygon ordered counter-clockwise and a set of values at each of these vertices, this function interpolates the value at the given position which must be inside the convex hull of the polygon, on an edge of the convex hull of the polygon or coincident with one of the vertices of it's convex hull. This function first calls WlzConvHullClarkson2D() to compute the convex hull and then WlzGeomInterpolateConvexPoly2D() to perform the interpolation. If the polygonis known to be convex then WlzGeomInterpolateConvexPoly2D() should be called directly since temporary workspaces are allocated.
n | Number of polygon vertices, which is the same as the number of values and generalised barycentric coordinates. |
p | The vertices of the convex polygon (ordered counter-clockwise). |
v | Values at the corresponding polygon vertices. |
w | Used to compute and return the generalised barycentric coordinates of the given position. The coordinate values of vertices outside the polygon's convex hull will be zero. |
q | Given position, which is must be within or on the convex hull of the polygon. |
dstErr | Destination error pointer, may be NULL. |
References AlcFree(), AlcMalloc(), WLZ_ERR_MEM_ALLOC, WLZ_ERR_NONE, WlzConvHullClarkson2D(), and WlzGeomInterpolateConvexPoly2D().
double WlzGeomInterpolateConvexPoly2D | ( | int | n, |
WlzDVertex2 * | p, | ||
double * | v, | ||
double * | w, | ||
WlzDVertex2 | q | ||
) |
Given the vertex coordinates of an irregular convex 2D polygon ordered counter-clockwise and a set of values at each of these vertices, this function interpolates the value at the given position which must be inside the polygon, on an edge of the polygon or coincident with one of it's vertices. This is implimented using general barycentric coordinates, see the paper: "Generalized Barycentric Coordinates on Irregular Polygons" Mark Mayer, etal, Journal of Graphics Tools 2002. All parameters of this function must be valid.
n | Number of polygon vertices, which is the same as the number of values and generalised barycentric coordinates. |
p | The vertices of the convex polygon (ordered counter-clockwise). |
v | Values at the corresponding polygon vertices. |
w | Used to compute and return the generalised barycentric coordinates of the given position. |
q | Given position, which is must be in or on the polygon. |
References _WlzDVertex2::vtX, _WlzDVertex2::vtY, WLZ_VTX_2_LENGTH, WLZ_VTX_2_SQRLEN, and WLZ_VTX_2_SUB.
Referenced by WlzGeomInterpolatePoly2D().
double WlzGeomInterpolateTet3D | ( | WlzDVertex3 | p0, |
WlzDVertex3 | p1, | ||
WlzDVertex3 | p2, | ||
WlzDVertex3 | p3, | ||
double | v0, | ||
double | v1, | ||
double | v2, | ||
double | v3, | ||
WlzDVertex3 | pX | ||
) |
Given the coordinates of the vertices of a 3D tetrahedron and a set of values at each of these vertices, this function interpolates the value at the given position which is either inside or on a face/edge of the tetrahedron. This is implimented using barycentric coordinates. Once the barycentric coordinates ( ,
,
,
) have been computed then the interpolated value is given by:
. If the determinant is zero in solving for the barycentric coordinates then the interpolated value is just the mean of the given values.
p0 | First vertex of tetrahedron. |
p1 | Second vertex of tetrahedron. |
p2 | Third vertex of tetrahedron. |
p3 | Fourth vertex of tetrahedron. |
v0 | Value at first vertex of tetrahedron. |
v1 | Value at second vertex of tetrahedron. |
v2 | Value at third vertex of tetrahedron. |
v3 | Value at fourth vertex of tetrahedron. |
pX | Given position, which is within (or on) the tetrahedron. |
References ALG_DBL_TOLLERANCE, _WlzDVertex3::vtX, _WlzDVertex3::vtY, _WlzDVertex3::vtZ, and WLZ_VTX_3_SUB.
void WlzGeomMap3DTriangleTo2D | ( | WlzDVertex3 | p0, |
WlzDVertex3 | p1, | ||
WlzDVertex3 | p2, | ||
WlzDVertex2 * | dstQ1, | ||
WlzDVertex2 * | dstQ2 | ||
) |
Given the three vertices of a triangle in 3D computes the 2D coordinates within the plane of the thriangle.
If the 3D coordinates of the vertices of the triangle are ,
and
then this function computes the coordinates of vertices in the plane of the triangle, such that:
,
and
. Where:
,
,
,
and
.
The first vertex in the plane is not returned because it's coordinates are always (0,0).
p0 | First vertex of triangle (origin of the 2D plane). |
p1 | Second vertex of triangle (on the ![]() |
p2 | Third vertex of triangle. |
dstQ1 | Destination pointer for the second vertex in the plane, must not be NULL. |
dstQ2 | Destination pointer for the third vertex in the plane, must not be NULL. |
References ALG_DBL_TOLLERANCE, _WlzGeomPolyListItem2D::v, _WlzDVertex2::vtX, _WlzDVertex2::vtY, WLZ_VTX_3_CROSS, WLZ_VTX_3_DOT, WLZ_VTX_3_LENGTH, WLZ_VTX_3_SCALE, and WLZ_VTX_3_SUB.
int WlzGeomTriangleAABBIntersect3D | ( | WlzDVertex3 | t0, |
WlzDVertex3 | t1, | ||
WlzDVertex3 | t2, | ||
WlzDVertex3 | b0, | ||
WlzDVertex3 | b1, | ||
int | tst | ||
) |
Tests for an intersection between the given triangle and the axis aligned bounding box in 3D using the Separating Axis Theorem (SAT).
Given an axis aligned bounding box and a triangle this function tests for an intersection using the Separating Axis Theorem (SAT) which states : Two 3D convex domains do not intersect iff there exists a line, called a separating axis, on which projection intervals of the domains do not intersect. The minimal set of axes that need to be considered is formed by the normals to all faces of the (polyhedral) domains and the cross product of all edge combinations in which one edge is from each polyhedron. For an axis aligned bounding box and a triangle in 3D, this is equivalent to testing for the intersection of the given axis aligned bounding box with the axis aligned bounding box of the triangle, testing for intersections on the axes normal to the face of the triangle and testing for intersection along the cross product of the axis aligned bounding box - triangle edges. The mathematics are simplified by the box being axis aligned.
The algorithm may return false positives when the domains are very close to touching.
t0 | First vertex of the triangle. |
t1 | Second vertex of the triangle. |
t2 | Third vertex of the triangle. |
b0 | Minimum of the bounding box. |
b1 | Maximum of the bounding box. |
tst | Determines the actual intersection tests used: 0 - AABB / triangle. 1 - AABB / AABB(triangle) only. 2 - AABB / triangle omitting the AABB / AABB(tetrahedron) test this is probably only useful if the AABB / AABB(triangle) are known to intersect. |
References ALG_DBL_TOLLERANCE, _WlzDVertex3::vtX, _WlzDVertex3::vtY, _WlzDVertex3::vtZ, WLZ_VTX_3_CROSS, WLZ_VTX_3_SQRLEN, and WLZ_VTX_3_SUB.
Referenced by WlzCMeshIntersectDom2D5(), and WlzGeoModelGridWSpSet3D().
int WlzGeomTriangleTriangleIntersect2D | ( | WlzDVertex2 | s0, |
WlzDVertex2 | s1, | ||
WlzDVertex2 | s2, | ||
WlzDVertex2 | t0, | ||
WlzDVertex2 | t1, | ||
WlzDVertex2 | t2 | ||
) |
Tests for an intersection between the two triangles in 2D using the by testing for intersections between the line segments of the triangles and then for either triangle being contained within the other.
See WlzGeomTriangleTriangleIntersect2DA().
s0 | First vertex of the first triangle. |
s1 | Second vertex of the first triangle. |
s2 | Third vertex of the first triangle. |
t0 | First vertex of the second triangle. |
t1 | Second vertex of the second triangle. |
t2 | Third vertex of the second triangle. |
int WlzGeomTriangleTriangleIntersect3D | ( | WlzDVertex3 | s0, |
WlzDVertex3 | s1, | ||
WlzDVertex3 | s2, | ||
WlzDVertex3 | t0, | ||
WlzDVertex3 | t1, | ||
WlzDVertex3 | t2 | ||
) |
Tests for an intersection between the two triangles in 3D using the Separating Axis Theorem (SAT).
See WlzGeomTriangleTriangleIntersect3DA().
s0 | First vertex of the first triangle. |
s1 | Second vertex of the first triangle. |
s2 | Third vertex of the first triangle. |
t0 | First vertex of the second triangle. |
t1 | Second vertex of the second triangle. |
t2 | Third vertex of the second triangle. |
WlzErrorNum WlzGeomCurvature | ( | int | nC, |
double * | dstC, | ||
WlzDVertex3 | nrm, | ||
int | nV, | ||
WlzDVertex3 * | vtx | ||
) |
Computes the principle curvatures of a parabolic surface fitted to the given vertices at the first of these vertices.
nC | Number of curvatures required: 1 computes the Gaussian curvature, 2 computes both principle curvatures. |
dstC | Destination pointer for the curvature value(s), must not be NULL. If nC == 2 then the values atr Gaussian followed by mean curvature. |
nrm | Normal at the first vertex. |
nV | Number of vertices, must be >= 3. |
vtx | Array of vertex positions, the first of which must be the vertex at which the curvature is to be computed. The array contents are modified by this function. Must not be NULL. |
References AlcFree(), AlcMalloc(), ALG_DBL_TOLLERANCE, AlgMatrixFree(), AlgMatrixRectNew(), AlgMatrixSVSolve(), _AlgMatrixRect::array, _AlgMatrix::core, _AlgMatrix::rect, _WlzDVertex3::vtX, _WlzDVertex3::vtY, _WlzDVertex3::vtZ, WLZ_ERR_MEM_ALLOC, WLZ_ERR_NONE, WLZ_ERR_PARAM_DATA, WLZ_VTX_3_CROSS, WLZ_VTX_3_DOT, WLZ_VTX_3_LENGTH, WLZ_VTX_3_SCALE, WLZ_VTX_3_SET, WLZ_VTX_3_SUB, and WlzErrorFromAlg().
Referenced by WlzCMeshComputeCurvaturesFromNodNorm().
WlzErrorNum WlzGeometryLSqOPlane | ( | WlzDVertex3 * | dstNrm, |
WlzDVertex3 * | dstCen, | ||
int | nVtx, | ||
WlzDVertex3 * | vtx | ||
) |
Computes the plane which is the least squares best fit to the given vertices, where this is with respect to the orthogonal distance from the vertices to the plane.
The orthogonal distance regression plane is an eigenvector problem. This solution is based on one from http://mathforum.org which is credited to Doctor George. Starting with the distance from a point to a plane we wish to find such as to minimise
setting gives
where is the centroid of the vertices. Using the centroid
Define
such that:
Define
The Rayleigh Quotient is minimised by the eigenvector of
. However there is no need to compute the eigenvectors of
. The SVD of
is
where is a diagonal vector containing the singular values of
. The columns of
are it's singular vectors and
is an orthogonal matrix.
The decomposition of diagonalises the matrix and gives an eigenvector decomposition. It means that the eigenvectors of
are the squares of the singular values of
and the eigenvectors of
are the singular vectors of
.
is the covarience matrix.
dstNrm | Destination pointer for the plane normal. |
dstCen | Destination pointer for the centroid of the vertices which is on the plane. |
nVtx | umber of vertices. |
vtx | Vector of vertices. |
References AlcFree(), AlcMalloc(), AlgMatrixFree(), AlgMatrixRectNew(), AlgMatrixSVDecomp(), AlgMatrixZero(), _AlgMatrixRect::array, _AlgMatrix::core, _AlgMatrix::rect, _WlzGeomPolyListItem2D::v, _WlzDVertex3::vtX, _WlzDVertex3::vtY, _WlzDVertex3::vtZ, WLZ_ERR_NONE, WLZ_ERR_PARAM_DATA, WLZ_VTX_3_SUB, WlzCentreOfMassVtx3D(), and WlzErrorFromAlg().
Referenced by WlzCMeshCompSurfMapToCircle().
double WlzGeomTriangleVtxDistSq3D | ( | WlzDVertex3 * | dstPT, |
int * | dstZT, | ||
int * | dstIT, | ||
double * | dstL0, | ||
double * | dstL1, | ||
WlzDVertex3 | vT, | ||
WlzDVertex3 | v0, | ||
WlzDVertex3 | v1, | ||
WlzDVertex3 | v2 | ||
) |
Computes the minimum distance from the test vertex to the triangle. This algorithm is based on "Distance Between Point and Triangle in 3D", David Eberly, Geometric Tools, 1999. In this algorithm the distance is computed for a parameterised triangle in 3D for which the following regions R[0-6] ara e defined:
l1 ^ \ R2 | \ | \ | \ | \| *v2 |\ | \ R3 | \ R1 | \ | \ | R0 \ | \ v1 -------*-------*-------> l0 |v0 \ R4 | R5 \ R6 | \
where and
Inside the triangle
The squared distance from some point with origin at
is then found by minimising
As this is a quadratic in and
it can easily be minimised.
dstPT | Destination pointer for the position of vertex in the triangle that is closest to the test vertex . |
dstZT | Destination pointer, the value of which will be set to a non-zero value if the triangle has zero area. May be NULL. |
dstIT | Destination pointer, the value of which will be set to a non-zero value if the projected test vertex is within the triangle, ie in region zero. May be NULL. |
dstL0 | Destination pointer for the first triangle parameter ( ![]() |
dstL1 | Destination pointer for the second triangle parameter ( ![]() |
vT | The position of the test vertex. |
v0 | First vertex of the triangle. |
v1 | Second vertex of the triangle. |
v2 | Third vertex of the triangle. |
References ALG_DBL_TOLLERANCE, _WlzDVertex3::vtX, _WlzDVertex3::vtY, _WlzDVertex3::vtZ, WLZ_VTX_3_DOT, and WLZ_VTX_3_SUB.
Referenced by WlzCMeshClosePointDom2D5().