Search code examples
matlabmatrixgeometrycoordinate-systemsrobotics

How to order one dimensional matrices base on values


I want to determine a point in space by geometry and I have math computations that gives me several theta values. After evaluating the theta values, I could get N 1 x 3 dimension matrix where N is the number of theta evaluated. Since I have my targeted point, I only need to decide which of the matrices is closest to the target with adequate focus on the three coordinates (x,y,z). Take a view of the analysis in the figure below:

Fig 1
Fig 1: Determining Closest Point with all points having minimal error

It can easily be seen that the third matrix is closest using sum(abs(Matrix[x,y,z])). However, if the method is applied on another figure given below, obviously, the result is wrong.

Fig 2
Fig 2: One Point has closest values with 2-axes of the reference point

Looking at point B, it is closer to the reference point on y-,z- axes but just that it strayed greatly on x-axis.

So how can I evaluate the matrices and select the closest one to point of reference and adequate emphasis will be on error differences in all coordinates (x,y,z)?


Solution

  • If your results is in terms of (x,y,z), why don't evaluate the euclidean distance of each matrix you have obtained from the reference point?

    Sort of matlab code:

    Ref_point = [48.98, 20.56, -1.44];
    Curr_point = [x,y,z];
    Xd = (x-Ref_point(1))^2 ;
    Yd = (y-Ref_point(2))^2 ;
    Zd = (z-Ref_point(3))^2 ;
    distance = sqrt(Xd + Yd + Zd);
    %find the minimum distance