35 if ( i < 0 || j < 0 || k < 0 )
37 QgsDebugMsg( QStringLiteral(
"Invalid parameters for Bernstein poly calculation!" ) );
45 static void normalize(
QgsPoint &point )
47 const double length = sqrt( pow( point.
x(), 2 ) + pow( point.
y(), 2 ) + pow( point.
z(), 2 ) );
50 point.
setX( point.
x() / length );
51 point.
setY( point.
y() / length );
52 point.
setZ( point.
z() / length );
71 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() );
72 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() );
73 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() );
75 endpointUXY.
setZ( 3 * ( zu - zv ) );
77 endpointVXY.
setZ( 3 * ( zv - zw ) );
78 const Vector3D v1( endpointUXY.
x() - x, endpointUXY.
y() - y, endpointUXY.
z() );
79 const Vector3D v2( endpointVXY.
x() - x, endpointVXY.
y() - y, endpointVXY.
z() );
90 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() );
91 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() );
92 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() );
94 endpointUXY.
setZ( 3 * ( zu - zv ) );
96 endpointVXY.
setZ( 3 * ( zv - zw ) );
97 const Vector3D v1( endpointUXY.
x() - x, endpointUXY.
y() - y, endpointUXY.
z() );
98 const Vector3D v2( endpointVXY.
x() - x, endpointVXY.
y() - y, endpointVXY.
z() );
110 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() );
111 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() );
112 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() );
114 endpointUXY.
setZ( 3 * ( zu - zv ) );
116 endpointVXY.
setZ( 3 * ( zv - zw ) );
117 const Vector3D v1( endpointUXY.
x() - x, endpointUXY.
y() - y, endpointUXY.
z() );
118 const Vector3D v2( endpointVXY.
x() - x, endpointVXY.
y() - y, endpointVXY.
z() );
131 result.
setZ( 1 ); normalize( result );
138 result.
setZ( 1 ); normalize( result );
145 result.
setZ( 1 ); normalize( result );
157 QgsDebugMsg( QStringLiteral(
"warning, null pointer" ) );
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 );
470 QgsDebugMsg( QStringLiteral(
"warning, null pointer" ) );
479 int ptn1, ptn2, ptn3;
484 mTIN->
getTriangle( x, y, &
point1, &ptn1, &v1, &state1, &
point2, &ptn2, &v2, &state2, &
point3, &ptn3, &v3, &state3 );
540 tmpx = -tmp.getX() / tmp.getZ();
541 tmpy = -tmp.getY() / tmp.getZ();
553 if ( state2 == NormVecDecorator::Breakline )
557 tmpx = -tmp.getX() / tmp.getZ();
558 tmpy = -tmp.getY() / tmp.getZ();
570 if ( state3 == NormVecDecorator::Breakline )
574 tmpx = -tmp.getX() / tmp.getZ();
575 tmpy = -tmp.getY() / tmp.getZ();
592 if ( state1 == NormVecDecorator::Breakline )
606 if ( state2 == NormVecDecorator::Breakline )
619 if ( state3 == NormVecDecorator::Breakline )
649 MathUtils::derVec( &cp1cp2, &odir3, &midpoint3cp4,
cp4.getX() - midpoint3.getX(),
cp4.getY() - midpoint3.getY() );
650 cp4.
setZ( midpoint3.getZ() + midpoint3cp4.getZ() );
672 cp13.
setZ( midpoint1.getZ() + midpoint1cp13.getZ() );
695 cp11.
setZ( midpoint2.getZ() + midpoint2cp11.getZ() );
739 QgsDebugMsg( QStringLiteral(
"warning, null pointer" ) );
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
Standard constructor.
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.
bool isEmpty() const override SIP_HOLDGIL
Returns true if the geometry is empty.
void setX(double x) SIP_HOLDGIL
Sets the point's x-coordinate.
void setY(double y) SIP_HOLDGIL
Sets the point's y-coordinate.
void setZ(double z) SIP_HOLDGIL
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 ...