Search code examples
geometrycoordinatescross-product

Find perpendicular coordinates in 3D space using two 3D points


Let's suppose I have a six by six cube each with xyz coordinates.

Moving from the middle cube (0,0,0) to the other sides (let's say (0,1,0), I would like to find the other 4 components that are peperdicular to the middle cube following the direction of (0,1,0).

If we move one dimension, this is easy (and my brain can grasp it)... the components will be (-1,0,0),(+1,0,0), (0,0,+1), (0,0,-1).

Now, could somebody help me with moving to size where two (to (1,1,0) or three coordinates change (1,1,-1)?

Thanks, Rodrigo


Solution

  • Thank you, this is exactly what I did.

    Here is my solution:

    (in matlab) I created a number of all possibility unit values:

    pos_vals=[ 0 0 0 ; -1 0 0 ; 1 0 0 ; 0 1 0 ; 0 -1 0 ; -1 -1 0 ; 1 1 0 ; -1 1 0 ; 1 -1 0; 0 0 1 ; -1 0 1 ; 1 0 1 ; 0 1 1 ; 0 -1 1 ; -1 -1 1 ; 1 1 1 ; -1 1 1 ; 1 -1 1 ; 0 0 -1 ; -1 0 -1 ; 1 0 -1 ; 0 1 -1 ; 0 -1 -1 ; -1 -1 -1 ; 1 1 -1 ; -1 1 -1 ; 1 -1 -1];

    And then based on my reference coordinate [eg vec_ofinterest=(1,1,0) ] , I do the following:

    for idx_posvals=1:size(pos_vals,1) gg(idx_posvals)=dot(vec_ofinterest,pos_vals(idx_posvals,:)); if gg(idx_posvals) == 0 pos_vals(idx_posvals,:) end end

    Which give me 8 solutions (including the reciprocals you mentioned). -1 1 0 1 -1 0 0 0 1 -1 1 1 1 -1 1 0 0 -1 -1 1 -1 1 -1 -1

    It looks like this is solved. In case somebody find and error, please let me know. Rodrigo