25using namespace Qt::StringLiterals;
38 if ( i < 0 || j < 0 || k < 0 )
40 QgsDebugError( u
"Invalid parameters for Bernstein poly calculation!"_s );
48static void normalize(
QgsPoint &point )
50 const double length = sqrt( pow( point.
x(), 2 ) + pow( point.
y(), 2 ) + pow( point.
z(), 2 ) );
53 point.
setX( point.
x() / length );
54 point.
setY( point.
y() / length );
55 point.
setZ( point.
z() / length );
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() );
127 endpointUXY.
setZ( 3 * ( zu - zv ) );
129 endpointVXY.
setZ( 3 * ( zv - zw ) );
130 const Vector3D v1( endpointUXY.
x() - x, endpointUXY.
y() - y, endpointUXY.
z() );
131 const Vector3D v2( endpointVXY.
x() - x, endpointVXY.
y() - y, endpointVXY.
z() );
161 endpointUXY.
setZ( 3 * ( zu - zv ) );
163 endpointVXY.
setZ( 3 * ( zv - zw ) );
164 const Vector3D v1( endpointUXY.
x() - x, endpointUXY.
y() - y, endpointUXY.
z() );
165 const Vector3D v2( endpointVXY.
x() - x, endpointVXY.
y() - y, endpointVXY.
z() );
309 int ptn1, ptn2, ptn3;
314 mTIN->getTriangle( x, y,
point1, ptn1, &v1, &state1,
point2, ptn2, &v2, &state2,
point3, ptn3, &v3, &state3 );
362 if (
mTIN->calcNormalForPoint( x, y, ptn1, &target1 ) )
383 if (
mTIN->calcNormalForPoint( x, y, ptn2, &target2 ) )
404 if (
mTIN->calcNormalForPoint( x, y, ptn3, &target3 ) )
456 cp4.setZ( midpoint3.
z() + midpoint3cp4.
getZ() );
478 cp13.setZ( midpoint1.
z() + midpoint1cp13.
getZ() );
501 cp11.setZ( midpoint2.
z() + midpoint2cp11.
getZ() );
553 int ptn1, ptn2, ptn3;
558 mTIN->
getTriangle( x, y, &
point1, &ptn1, &v1, &state1, &
point2, &ptn2, &v2, &state2, &
point3, &ptn3, &v3, &state3 );
607 Vector3D tmp( 0, 0, 0 );
612 if (
mTIN->calcNormalForPoint( x, y, ptn1, &tmp ) )
614 tmpx = -tmp.getX() / tmp.getZ();
615 tmpy = -tmp.getY() / tmp.getZ();
627 if ( state2 == NormVecDecorator::Breakline )
629 if (
mTIN->calcNormalForPoint( x, y, ptn2, &tmp ) )
631 tmpx = -tmp.getX() / tmp.getZ();
632 tmpy = -tmp.getY() / tmp.getZ();
644 if ( state3 == NormVecDecorator::Breakline )
646 if (
mTIN->calcNormalForPoint( x, y, ptn3, &tmp ) )
648 tmpx = -tmp.getX() / tmp.getZ();
649 tmpy = -tmp.getY() / tmp.getZ();
666 if ( state1 == NormVecDecorator::Breakline )
680 if ( state2 == NormVecDecorator::Breakline )
693 if ( state3 == NormVecDecorator::Breakline )
707 QgsPoint midpoint3( (
cp1.getX() +
cp2.getX() ) / 2, (
cp1.getY() +
cp2.getY() ) / 2, (
cp1.getZ() +
cp2.getZ() ) / 2 );
708 Vector3D cp1cp2(
cp2.getX() -
cp1.getX(),
cp2.getY() -
cp1.getY(),
cp2.getZ() -
cp1.getZ() );
709 Vector3D odir3( 0, 0, 0 );
722 Vector3D midpoint3cp4( 0, 0, 0 );
723 MathUtils::derVec( &cp1cp2, &odir3, &midpoint3cp4,
cp4.getX() - midpoint3.getX(),
cp4.getY() - midpoint3.getY() );
724 cp4.setZ( midpoint3.getZ() + midpoint3cp4.getZ() );
729 QgsPoint midpoint1( (
cp9.getX() +
cp16.getX() ) / 2, (
cp9.getY() +
cp16.getY() ) / 2, (
cp9.getZ() +
cp16.getZ() ) / 2 );
731 Vector3D odir1( 0, 0, 0 );
744 Vector3D midpoint1cp13( 0, 0, 0 );
746 cp13.setZ( midpoint1.getZ() + midpoint1cp13.getZ() );
752 QgsPoint midpoint2( (
cp14.getX() +
cp6.getX() ) / 2, (
cp14.getY() +
cp6.getY() ) / 2, (
cp14.getZ() +
cp6.getZ() ) / 2 );
754 Vector3D odir2( 0, 0, 0 );
767 Vector3D midpoint2cp11( 0, 0, 0 );
769 cp11.setZ( midpoint2.getZ() + midpoint2cp11.getZ() );
775 Vector3D cp4cp3(
cp3.getX() -
cp4.getX(),
cp3.getY() -
cp4.getY(),
cp3.getZ() -
cp4.getZ() );
777 Vector3D cp4cp7( 0, 0, 0 );
779 cp7.setZ(
cp4.getZ() + cp4cp7.getZ() );
784 Vector3D cp4cp5(
cp5.getX() -
cp4.getX(),
cp5.getY() -
cp4.getY(),
cp5.getZ() -
cp4.getZ() );
786 Vector3D cp4cp8( 0, 0, 0 );
788 cp8.setZ(
cp4.getZ() + cp4cp8.getZ() );
795 Vector3D cp13cp12( 0, 0, 0 );
797 cp12.setZ(
cp13.getZ() + cp13cp12.getZ() );
800 Vector3D cp7cp8(
cp8.getX() -
cp7.getX(),
cp8.getY() -
cp7.getY(),
cp8.getZ() -
cp7.getZ() );
802 Vector3D cp7cp10( 0, 0, 0 );
804 cp10.setZ(
cp7.getZ() + cp7cp10.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...
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.
Represents a 3D-Vector, capable of storing 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)