35 if ( i < 0 || j < 0 || k < 0 )
37 QgsDebugMsg( QStringLiteral(
"Invalid parameters for Bernstein poly calculation!" ) );
45 static void normalize(
QgsPoint &point )
47 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 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 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 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 Vector3D v1( endpointUXY.
x() - x, endpointUXY.
y() - y, endpointUXY.
z() );
79 Vector3D v2( endpointVXY.
x() - x, endpointVXY.
y() - y, endpointVXY.
z() );
90 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 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 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 Vector3D v1( endpointUXY.
x() - x, endpointUXY.
y() - y, endpointUXY.
z() );
98 Vector3D v2( endpointVXY.
x() - x, endpointVXY.
y() - y, endpointVXY.
z() );
110 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 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 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 Vector3D v1( endpointUXY.
x() - x, endpointUXY.
y() - y, endpointUXY.
z() );
118 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 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 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 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" ) );