Explanation of the problem:

I have a MATLAB program, which produces two vectors in a 3D coordinate system. The origin for both vectors is (0,0,0). The vector's endpoints are located on the unit sphere.

Picture of unit sphere with produced vectors, one color is always one vector-pair at a given time

Now, I choose the vector with the higher Y-Value (could possibly be a different criteria), to be my initial vector. Based on that vector I want to find three new vectors, which are pointing towards the vertices of a regular tetrahedron. Another condition condition should be, that one of the three new vectors lays in the plane spanned by the two original vectors. Since the angle between two vertices in a regular tetrahedron is always constant (acos(-1/3) ~= 109.5 deg) it is also the smallest possible angle to the second original vector.

Orange vectors are original ones, blue vectors are the three new vertices, the one orange vector is the fourth vertice

Attempts in solving the problem:

My first idea how to solve the problem was to define a matrix of the vertices as:

MT = [1, 1, -1, -1; 1, -1, 1, -1; 1, -1, -1, 1];

and then trying to rotate it into the right position, but my attempt did not work out.

My second idea was to define the second of the three new vectors as a linear combination of the two original vectors. I used the formula for finding an angle between two vectors and set the angle to acos(-1/3). After finding the second vector, I figured the two other ones would only be a multiplication with some kind of a transfer matrix. But I also got stuck on this attempt, since I never was able to find the second vector.

Now, I am running out of ideas. Please also note, that I would like the operations/ calculations in my program to be as high-performing as possible.

Thank you for your help. It is greatly appreciated.


  • 1
    $\begingroup$ I suggest you remove algebraic geometry and differential geometry from your tags since they are not related to your question. Maybe add analytic geometry instead. $\endgroup$ – Hamed Nov 17 '15 at 0:43
  • $\begingroup$ Thank you. I followed your suggestion :) $\endgroup$ – AMK Nov 17 '15 at 0:54

I think I figured it out. My solution as MATLAB code:

r = [.56, .5774, .5941]; %random vector 1
r2 = [-1,-1,1]; r2 = r2/norm(r2); %some vector 2

%% perpendicular vectors
b0 = cross(r, r2);
b1 = cross(r, -b0);
b2 = cross(r, b1);

%% normalize
u1 = b1/norm(b1);
u2 = b2/norm(b2);

%% find vertices
v1 = (-1/3)*r+(sqrt(8)/3)*1*u1;
v2 = (-1/3)*r+(sqrt(8)/3)*1*(-0.5*u1+(sqrt(3)/2)*u2);
v3 = (-1/3)*r+(sqrt(8)/3)*1*(-0.5*u1-(sqrt(3)/2)*u2);

%% four vertices of regular tetrahedron
MT = [r; v1; v2; v3]; MT = MT';

%% plot unit sphere
[sx,sy,sz] = sphere(20);
surface(sx,sy,sz,'FaceColor','none','EdgeColor', [0.8, 0.8, 0.8]);
hold on;
grid on;

%% plot matrix of vertices
plot3([MT(1,1), 0, MT(1,2), 0, MT(1,3), 0, MT(1,4)],...
  [MT(2,1), 0, MT(2,2), 0, MT(2,3), 0, MT(2,4)],...
  [MT(3,1), 0, MT(3,2), 0, MT(3,3), 0, MT(3,4)]);

%% plot starting vector
plot3([r(1), 0], [r(2), 0], [r(3), 0], 'r');

%% plot second starting vector
plot3([0, r2(1)], [0, r2(2)], [0, r2(3)], 'm');

%% plot perpendicular vectors (b1 and b2)
plot3([u1(1), 0, u2(1)], [u1(2), 0, u2(2)], [u1(3), 0, u2(3)], 'g');

Picture of the plot produced by the code

Hope this helps someone else :)



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.