# Adding vectors and applying rotation matrix using quaternion

I have a problem and looking for help, see attached image. I have a number of points (x,y,z) which are treated as connected vectors (first point as first vector base, second point as first vector end AND second vector base, etc) and I need to know the minimal and maximal coordinate points of the whole connected structure. I only know that rotation matrix using quaternion should be applied in the process, but have no such experience. Any insights or links to similar example would be appreciated.

   auto rx = _coord_x.data(); auto ry = _coord_y.data(); auto rz = _coord_z.data();

// set up dimensions of coordinates

auto ncoords = number_of_vectors();

for (int32_t i = 0; i < ncoords; i++)
{
//normalization
float fact = 1.0f / std::sqrt(rx[i] * rx[i] + ry[i] * ry[i] + rz[i] * rz[i]);

rx[i] *= fact; ry[i] *= fact; rz[i] = fact;

// rotation matrix ??

}


} • Sorry I have hard times understanding the pictures that you shared (probably too many x,y and z). As I understand your question, you're looking to find the min and max x,y,z coordinates of a given set of vectors... but then the picture confuses me. – lvictorino Oct 7 '19 at 9:19
• Please ignore then the picture :) I am new in both fields, so I am having a trouble to express my problem correctly - but you just did this. Could you please share your insights? All I know for 100% that quaternion should be involved in the rotation matrix – Alexander S Oct 7 '19 at 10:04
• If you need to know the min and max coordinates of the whole point set... why not just looping through all your points, then, for every point, compare x,y, and z value to values you'd save? if the point x is lower than your saved min_x, then update min_x with this value. Do the same for max_x and for y and z with all other points. At the end your min_x,min_y,min_z and max_x,max_y,max_z will compose your min and max positions. It'll work, whatever the rotation involved. – lvictorino Oct 7 '19 at 11:18
• There are 3 vector sets for points: x, y, z, and these points are generated randomly. The new vector set - let's just name it vector B - is created based on these points, i.e. B1 is created from x1,y1,z1 , etc. And I need to find the coordinates of the last B vector. Therefore you can't use that function you stated because the last vector B would not necessarily contain the biggest or lowest possible x/y/z values. – Alexander S Oct 7 '19 at 16:48