#include <math_MultipleVarFunctionWithGradient.hxx>
#include <math_MultipleVarFunctionWithHessian.hxx>
-//! This class implements function which operates with Eucluidean distance <br>
-//! between 2 curves in case of C1 and C2 continuity is C0.
+//! This class implements function which calculate Eucluidean distance
+//! between point on curve and point on other curve in case of C1 and C2 continuity is C0.
class Extrema_GlobOptFuncCCC0 : public math_MultipleVarFunction
{
public:
};
-//! This class implements function which operates with Eucluidean distance <br>
-//! between 2 curves in case of C1 and C2 continuity is C1.
+//! This class implements function which calculate Eucluidean distance
+//! between point on curve and point on other curve in case of C1 and C2 continuity is C1.
class Extrema_GlobOptFuncCCC1 : public math_MultipleVarFunctionWithGradient
{
public:
};
-//! This class implements function which operates with Eucluidean distance <br>
-//! between 2 curves in case of C1 and C2 continuity is C2 or more.
+//! This class implements function which calculate Eucluidean distance
+//! between point on curve and point on other curve in case of C1 and C2 continuity is C2.
class Extrema_GlobOptFuncCCC2 : public math_MultipleVarFunctionWithHessian
{
public:
#include <Standard_Integer.hxx>
#include <Standard_OutOfRange.hxx>
-//! F = Sqrt( (x1(cu) - x2(su,sv))^2
-// + (y1(cu) - y2(su,sv))^2
-// + (z1(cu) - z2(su,sv))^2 )
+//!F(cu, su, sv)=(C^{(x)}(cu)-S^{(x)}(su,sv))^{2}+
+// (C^{(y)}(cu)-S^{(y)}(su,sv))^{2}+
+// (C^{(z)}(cu)-S^{(z)}(su,sv))^{2}
//=======================================================================
Standard_Real sv,
Standard_Real &F)
{
- F = myC->Value(cu).Distance(myS->Value(su, sv));
+ F = myC->Value(cu).SquareDistance(myS->Value(su, sv));
}
//=======================================================================
+ (CD0.X() - SD0.X()) * CD2.X()
+ (CD0.Y() - SD0.Y()) * CD2.Y()
+ (CD0.Z() - SD0.Z()) * CD2.Z();
+
H(1,2) = - CD1.X() * SD1U.X()
- CD1.Y() * SD1U.Y()
- CD1.Z() * SD1U.Z();
+
H(1,3) = - CD1.X() * SD1V.X()
- CD1.Y() * SD1V.Y()
- CD1.Z() * SD1V.Z();
+
H(2,1) = H(1,2);
+
H(2,2) = + SD1U.X() * SD1U.X()
+ SD1U.Y() * SD1U.Y()
+ SD1U.Z() * SD1U.Z()
- (CD0.X() - SD0.X()) * SD2UU.X()
- - (CD0.X() - SD0.X()) * SD2UU.Y()
- - (CD0.X() - SD0.X()) * SD2UU.Z();
+ - (CD0.Y() - SD0.Y()) * SD2UU.Y()
+ - (CD0.Z() - SD0.Z()) * SD2UU.Z();
+
H(2,3) = + SD1U.X() * SD1V.X()
+ SD1U.Y() * SD1V.Y()
+ SD1U.Z() * SD1V.Z()
- (CD0.X() - SD0.X()) * SD2UV.X()
- - (CD0.X() - SD0.X()) * SD2UV.Y()
- - (CD0.X() - SD0.X()) * SD2UV.Z();
+ - (CD0.Y() - SD0.Y()) * SD2UV.Y()
+ - (CD0.Z() - SD0.Z()) * SD2UV.Z();
+
H(3,1) = H(1,3);
+
H(3,2) = H(2,3);
+
H(3,3) = + SD1V.X() * SD1V.X()
+ SD1V.Y() * SD1V.Y()
+ SD1V.Z() * SD1V.Z()
- (CD0.X() - SD0.X()) * SD2VV.X()
- - (CD0.X() - SD0.X()) * SD2VV.Y()
- - (CD0.X() - SD0.X()) * SD2VV.Z();
+ - (CD0.Y() - SD0.Y()) * SD2VV.Y()
+ - (CD0.Z() - SD0.Z()) * SD2VV.Z();
}
//=======================================================================
{
myFunc->Value(aCurrPoint, aCurrValue);
- if (aCurrValue * aCurrValue < aParticle->Distance)
+ if (aCurrValue < aParticle->Distance)
{
Standard_Integer aDimIdx;
for(aDimIdx = 0; aDimIdx < myN; ++aDimIdx)
aParticle->Position[aDimIdx] = aCurrPoint(aDimIdx + 1);
aParticle->BestPosition[aDimIdx] = aCurrPoint(aDimIdx + 1);
}
- aParticle->Distance = aCurrValue * aCurrValue;
- aParticle->BestDistance = aCurrValue * aCurrValue;
+ aParticle->Distance = aCurrValue;
+ aParticle->BestDistance = aCurrValue;
aParticle = aPool.GetWorstParticle();
}
}
myFunc->Value(aCurrPoint, aParticle->Distance);
- aParticle->Distance *= aParticle->Distance;
if(aParticle->Distance < aParticle->BestDistance)
{
aParticle->BestDistance = aParticle->Distance;