Hello,

I have aquestion regarding the usage of minasa functions. What I would like to do basically is to find the optimal angles (alpha, beta, gamma) that a segment has to be rotated in order to minimize a distance from a given point. So i have tried to modify the code from the examples as follow:

**Code:**

alglib.minasa.minasastate state = new alglib.minasa.minasastate();

alglib.minasa.minasareport report = new alglib.minasa.minasareport();

double[] initialAngles = new double[3];

double[] lowerBounds = new double[3];

double[] upperBounds = new double[3];

for(int i=0; i<3; i++)

{

initialAngles[i] = 0.0;

lowerBounds[i] = -Math.PI;

upperBounds[i] = Math.PI;

}

alglib.minasa.minasacreate(3, initialAngles, lowerBounds, upperBounds, state);

alglib.minasa.minasasetcond(state, 0.0, 0.0, 0.00001, 0);

alglib.minasa.minasasetxrep(state, true);

alglib.minasa.minasasetstpmax(state, 0.2);

while(alglib.minasa.minasaiteration(state))

{

if(state.needfg)

{

// Estimate the new position of the segment tip

Matrix3f rotation = Matrix3f.FromEulerAnglesXYZ(state.x[0], state.x[1], state.x[2]);

Vector3f length = new Vector3f(segments[0].length, 0, 0);

point2 = bodyRotation * length + point1;

// Calculate distance between the point we want to reach and the current point

double distance = Vector3f.euclideanDistance(coordinates, point2);

// Here is the problem how to estimate the values of these parameters??????

state.f = distance; // Needs fixing?

state.g[0] = ?

state.g[1] = ?

state.g[2] = ?

}

}

// Get the results

alglib.minasa.minasaresults(state, initialAngles, report);

double a = initialAngles[0];

double b = initialAngles[1];

double c = initialAngles[2];

Any help whould be appreciated. I have managed to get the results with MATLAB's lsqnonlin function (which does not require gradients), but I would like to do the same thing in C#. Is it possible to achieve that with the minasa functions?