34 if ( i < 0 || j < 0 || k < 0 )
36 QgsDebugError( QStringLiteral(
"Invalid parameters for Bernstein poly calculation!" ) );
44static void normalize(
QgsPoint &point )
46 const double length = sqrt( pow( point.
x(), 2 ) + pow( point.
y(), 2 ) + pow( point.
z(), 2 ) );
49 point.
setX( point.
x() / length );
50 point.
setY( point.
y() / length );
51 point.
setZ( point.
z() / length );
70 const double zu =
point1.
z() *
calcBernsteinPoly( 2, 2, 0, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp1.
z() *
calcBernsteinPoly( 2, 1, 1, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp2.
z() *
calcBernsteinPoly( 2, 0, 2, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp3.
z() *
calcBernsteinPoly( 2, 1, 0, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp4.
z() *
calcBernsteinPoly( 2, 0, 1, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp7.
z() *
calcBernsteinPoly( 2, 0, 0, 2, barycoord.
x(), barycoord.
y(), barycoord.
z() );
71 const double zv =
cp1.
z() *
calcBernsteinPoly( 2, 2, 0, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp2.
z() *
calcBernsteinPoly( 2, 1, 1, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
point2.
z() *
calcBernsteinPoly( 2, 0, 2, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp4.
z() *
calcBernsteinPoly( 2, 1, 0, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp5.
z() *
calcBernsteinPoly( 2, 0, 1, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp8.
z() *
calcBernsteinPoly( 2, 0, 0, 2, barycoord.
x(), barycoord.
y(), barycoord.
z() );
72 const double zw =
cp3.
z() *
calcBernsteinPoly( 2, 2, 0, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp4.
z() *
calcBernsteinPoly( 2, 1, 1, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp5.
z() *
calcBernsteinPoly( 2, 0, 2, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp7.
z() *
calcBernsteinPoly( 2, 1, 0, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp8.
z() *
calcBernsteinPoly( 2, 0, 1, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp10.
z() *
calcBernsteinPoly( 2, 0, 0, 2, barycoord.
x(), barycoord.
y(), barycoord.
z() );
74 endpointUXY.
setZ( 3 * ( zu - zv ) );
76 endpointVXY.
setZ( 3 * ( zv - zw ) );
77 const Vector3D v1( endpointUXY.
x() - x, endpointUXY.
y() - y, endpointUXY.
z() );
78 const Vector3D v2( endpointVXY.
x() - x, endpointVXY.
y() - y, endpointVXY.
z() );
89 const double zu =
point2.
z() *
calcBernsteinPoly( 2, 2, 0, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp9.
z() *
calcBernsteinPoly( 2, 1, 1, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp16.
z() *
calcBernsteinPoly( 2, 0, 2, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp5.
z() *
calcBernsteinPoly( 2, 1, 0, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp13.
z() *
calcBernsteinPoly( 2, 0, 1, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp8.
z() *
calcBernsteinPoly( 2, 0, 0, 2, barycoord.
x(), barycoord.
y(), barycoord.
z() );
90 const double zv =
cp9.
z() *
calcBernsteinPoly( 2, 2, 0, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp16.
z() *
calcBernsteinPoly( 2, 1, 1, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
point3.
z() *
calcBernsteinPoly( 2, 0, 2, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp13.
z() *
calcBernsteinPoly( 2, 1, 0, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp15.
z() *
calcBernsteinPoly( 2, 0, 1, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp12.
z() *
calcBernsteinPoly( 2, 0, 0, 2, barycoord.
x(), barycoord.
y(), barycoord.
z() );
91 const double zw =
cp5.
z() *
calcBernsteinPoly( 2, 2, 0, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp13.
z() *
calcBernsteinPoly( 2, 1, 1, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp15.
z() *
calcBernsteinPoly( 2, 0, 2, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp8.
z() *
calcBernsteinPoly( 2, 1, 0, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp12.
z() *
calcBernsteinPoly( 2, 0, 1, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp10.
z() *
calcBernsteinPoly( 2, 0, 0, 2, barycoord.
x(), barycoord.
y(), barycoord.
z() );
93 endpointUXY.
setZ( 3 * ( zu - zv ) );
95 endpointVXY.
setZ( 3 * ( zv - zw ) );
96 const Vector3D v1( endpointUXY.
x() - x, endpointUXY.
y() - y, endpointUXY.
z() );
97 const Vector3D v2( endpointVXY.
x() - x, endpointVXY.
y() - y, endpointVXY.
z() );
108 const double zu =
point3.
z() *
calcBernsteinPoly( 2, 2, 0, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp14.
z() *
calcBernsteinPoly( 2, 1, 1, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp6.
z() *
calcBernsteinPoly( 2, 0, 2, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp15.
z() *
calcBernsteinPoly( 2, 1, 0, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp11.
z() *
calcBernsteinPoly( 2, 0, 1, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp12.
z() *
calcBernsteinPoly( 2, 0, 0, 2, barycoord.
x(), barycoord.
y(), barycoord.
z() );
109 const double zv =
cp14.
z() *
calcBernsteinPoly( 2, 2, 0, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp6.
z() *
calcBernsteinPoly( 2, 1, 1, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
point1.
z() *
calcBernsteinPoly( 2, 0, 2, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp11.
z() *
calcBernsteinPoly( 2, 1, 0, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp3.
z() *
calcBernsteinPoly( 2, 0, 1, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp7.
z() *
calcBernsteinPoly( 2, 0, 0, 2, barycoord.
x(), barycoord.
y(), barycoord.
z() );
110 const double zw =
cp15.
z() *
calcBernsteinPoly( 2, 2, 0, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp11.
z() *
calcBernsteinPoly( 2, 1, 1, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp3.
z() *
calcBernsteinPoly( 2, 0, 2, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp12.
z() *
calcBernsteinPoly( 2, 1, 0, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp7.
z() *
calcBernsteinPoly( 2, 0, 1, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp10.
z() *
calcBernsteinPoly( 2, 0, 0, 2, barycoord.
x(), barycoord.
y(), barycoord.
z() );
112 endpointUXY.
setZ( 3 * ( zu - zv ) );
114 endpointVXY.
setZ( 3 * ( zv - zw ) );
115 const Vector3D v1( endpointUXY.
x() - x, endpointUXY.
y() - y, endpointUXY.
z() );
116 const Vector3D v2( endpointVXY.
x() - x, endpointVXY.
y() - y, endpointVXY.
z() );
171 const double z =
point1.
z() *
calcBernsteinPoly( 3, 3, 0, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp1.
z() *
calcBernsteinPoly( 3, 2, 1, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp2.
z() *
calcBernsteinPoly( 3, 1, 2, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
point2.
z() *
calcBernsteinPoly( 3, 0, 3, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp3.
z() *
calcBernsteinPoly( 3, 2, 0, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp4.
z() *
calcBernsteinPoly( 3, 1, 1, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp5.
z() *
calcBernsteinPoly( 3, 0, 2, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp7.
z() *
calcBernsteinPoly( 3, 1, 0, 2, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp8.
z() *
calcBernsteinPoly( 3, 0, 1, 2, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp10.
z() *
calcBernsteinPoly( 3, 0, 0, 3, barycoord.
x(), barycoord.
y(), barycoord.
z() );
181 const double z =
cp10.
z() *
calcBernsteinPoly( 3, 0, 0, 3, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp8.
z() *
calcBernsteinPoly( 3, 1, 0, 2, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp5.
z() *
calcBernsteinPoly( 3, 2, 0, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
point2.
z() *
calcBernsteinPoly( 3, 3, 0, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp12.
z() *
calcBernsteinPoly( 3, 0, 1, 2, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp13.
z() *
calcBernsteinPoly( 3, 1, 1, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp9.
z() *
calcBernsteinPoly( 3, 2, 1, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp15.
z() *
calcBernsteinPoly( 3, 0, 2, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp16.
z() *
calcBernsteinPoly( 3, 1, 2, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
point3.
z() *
calcBernsteinPoly( 3, 0, 3, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() );
191 const double z =
point1.
z() *
calcBernsteinPoly( 3, 0, 3, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp3.
z() *
calcBernsteinPoly( 3, 0, 2, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp7.
z() *
calcBernsteinPoly( 3, 0, 1, 2, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp10.
z() *
calcBernsteinPoly( 3, 0, 0, 3, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp6.
z() *
calcBernsteinPoly( 3, 1, 2, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp11.
z() *
calcBernsteinPoly( 3, 1, 1, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp12.
z() *
calcBernsteinPoly( 3, 1, 0, 2, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp14.
z() *
calcBernsteinPoly( 3, 2, 1, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
cp15.
z() *
calcBernsteinPoly( 3, 2, 0, 1, barycoord.
x(), barycoord.
y(), barycoord.
z() ) +
point3.
z() *
calcBernsteinPoly( 3, 3, 0, 0, barycoord.
x(), barycoord.
y(), barycoord.
z() );
233 int ptn1, ptn2, ptn3;
238 mTIN->
getTriangle( x, y,
point1, ptn1, &v1, &state1,
point2, ptn2, &v2, &state2,
point3, ptn3, &v3, &state3 );
477 int ptn1, ptn2, ptn3;
482 mTIN->
getTriangle( x, y, &
point1, &ptn1, &v1, &state1, &
point2, &ptn2, &v2, &state2, &
point3, &ptn3, &v3, &state3 );
538 tmpx = -tmp.getX() / tmp.getZ();
539 tmpy = -tmp.getY() / tmp.getZ();
551 if ( state2 == NormVecDecorator::Breakline )
555 tmpx = -tmp.getX() / tmp.getZ();
556 tmpy = -tmp.getY() / tmp.getZ();
568 if ( state3 == NormVecDecorator::Breakline )
572 tmpx = -tmp.getX() / tmp.getZ();
573 tmpy = -tmp.getY() / tmp.getZ();
590 if ( state1 == NormVecDecorator::Breakline )
604 if ( state2 == NormVecDecorator::Breakline )
617 if ( state3 == NormVecDecorator::Breakline )
647 MathUtils::derVec( &cp1cp2, &odir3, &midpoint3cp4,
cp4.getX() - midpoint3.getX(),
cp4.getY() - midpoint3.getY() );
648 cp4.
setZ( midpoint3.getZ() + midpoint3cp4.getZ() );
670 cp13.
setZ( midpoint1.getZ() + midpoint1cp13.getZ() );
693 cp11.
setZ( midpoint2.getZ() + midpoint2cp11.getZ() );
double der2X
Derivative in x-direction at point2.
virtual void setTriangulation(NormVecDecorator *tin)
QgsPoint cp8
Control point 8.
QgsPoint cp1
Control point 1.
double der3X
Derivative in x-direction at point3.
QgsPoint cp2
Control point 2.
QgsPoint cp14
Control point 14.
QgsPoint cp13
Control point 13.
QgsPoint cp9
Control point 9.
QgsPoint point3
Third point of the triangle in x-,y-,z-coordinates.
double der2Y
Derivative in y-direction at point2.
NormVecDecorator * mTIN
Association with a triangulation object.
QgsPoint cp10
Control point 10.
double der1X
Derivative in x-direction at point1.
double mEdgeTolerance
Tolerance of the barycentric coordinates at the borders of the triangles (to prevent errors because o...
QgsPoint lpoint1
Stores point1 of the last run.
QgsPoint cp5
Control point 5.
QgsPoint cp4
Control point 4.
QgsPoint cp3
Control point 3.
QgsPoint lpoint2
Stores point2 of the last run.
bool calcPoint(double x, double y, QgsPoint &result) override
Performs a linear interpolation in a triangle and assigns the x-,y- and z-coordinates to point.
QgsPoint cp7
Control point 7.
double calcBernsteinPoly(int n, int i, int j, int k, double u, double v, double w)
Calculates the Bernsteinpolynomials to calculate the Beziertriangle. 'n' is three in the cubical case...
QgsPoint point2
Second point of the triangle in x-,y-,z-coordinates.
double der3Y
Derivative in y-direction at point3.
QgsPoint cp12
Control point 12.
QgsPoint cp16
Control point 16.
void init(double x, double y)
Finds out, in which triangle the point with the coordinates x and y is.
bool calcNormVec(double x, double y, QgsPoint &result) override
Calculates the normal vector and assigns it to vec (not implemented at the moment)
QgsPoint cp6
Control point 6.
QgsPoint cp15
Control point 15.
CloughTocherInterpolator()=default
QgsPoint lpoint3
Stores point3 of the last run.
QgsPoint point1
First point of the triangle in x-,y-,z-coordinates.
double der1Y
Derivative in y-direction at point1.
QgsPoint cp11
Control point 11.
Decorator class which adds the functionality of estimating normals at the data points.
bool getTriangle(double x, double y, QgsPoint &p1, Vector3D *v1, QgsPoint &p2, Vector3D *v2, QgsPoint &p3, Vector3D *v3)
Finds out, in which triangle a point with coordinates x and y is and assigns the triangle points to p...
bool calcNormalForPoint(double x, double y, int pointIndex, Vector3D *result)
Calculates the normal of a triangle-point for the point with coordinates x and y. This is needed,...
PointState
Enumeration for the state of a point. Normal means, that the point is not on a BreakLine,...
Point geometry type, with support for z-dimension and m-values.
void setY(double y)
Sets the point's y-coordinate.
void setX(double x)
Sets the point's x-coordinate.
bool isEmpty() const override
Returns true if the geometry is empty.
void setZ(double z)
Sets the point's z-coordinate.
Class Vector3D represents a 3D-Vector, capable to store x-,y- and z-coordinates in double values.
void setX(double x)
Sets the x-component of the vector.
double getY() const
Returns the y-component of the vector.
double getX() const
Returns the x-component of the vector.
void setY(double y)
Sets the y-component of the vector.
double getZ() const
Returns the z-component of the vector.
void setZ(double z)
Sets the z-component of the vector.
bool ANALYSIS_EXPORT derVec(const Vector3D *v1, const Vector3D *v2, Vector3D *result, double x, double y)
Calculates the z-component of a vector with coordinates 'x' and 'y'which is in the same tangent plane...
int ANALYSIS_EXPORT faculty(int n)
Faculty function.
bool ANALYSIS_EXPORT BarycentricToXY(double u, double v, double w, QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *result)
bool ANALYSIS_EXPORT calcBarycentricCoordinates(double x, double y, QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *result)
Calculates the barycentric coordinates of a point (x,y) with respect to p1, p2, p3 and stores the thr...
void ANALYSIS_EXPORT normalFromPoints(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, Vector3D *vec)
Calculates the normal vector of the plane through the points p1, p2 and p3 and assigns the result to ...
#define QgsDebugError(str)