3
$\begingroup$

I have three vectors that are lying down in the 111 plane

Module[{origR = {0.5, 0.5, 0}, origB = {0, 0.5, 0.5}, 
  origG = {0.5, 0, 0.5}, red0 = 0.2 {2, -2, 0}, 
  blue0 = 0.2 {-2, 0, 2}, green0 = 0.2 {0, 2, -2}}, 
 Graphics3D[{{Opacity[0.7], Gray, EdgeForm[None], 
    Polygon[{{1, 0, 0}, {0, 1, 0}, {-0.5, 0.5, 1}, {0.5, -0.5, 1}}]}, 
   Red, Arrow[{origR, origR + red0}], Blue, 
   Arrow[{origB, origB + blue0}], Green, 
   Arrow[{origG, origG + green0}]}, ImageSize -> 300, 
  FaceGrids -> {Left, Back, Bottom}, FaceGridsStyle -> GrayLevel[0.5],
   Axes -> False, Boxed -> False, AxesLabel -> {"x", "y", "z"}, 
  PlotRange -> {{-0.5, 1}, {-0.5, 1}, {0, 1}}]]      

enter image description here

How can I get the coordinate of these vectors with respect to the 111 plane, in the new {x',y',0} coordinate? which should look like this

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ The simplest way of achieving this 2D plot is probably to add ViewPoint->{∞,∞,∞} as an option to Graphics3D. $\endgroup$
    – Roman
    Sep 14, 2022 at 7:59

2 Answers 2

3
$\begingroup$

Your plane is given by $x+y+z=1$, so we can define the $z'$-axis as

zp = {1, 1, 1}/Sqrt[3];

The red arrow defines the $-x'$ direction:

xp = {-1, 1, 0}/Sqrt[2];

Finally, the $y'$-axis is defined by the cross product of the other axes,

yp = Cross[zp, xp]
(*    {-1/Sqrt[6], -1/Sqrt[6], Sqrt[2/3]}    *)

Now we can transform all vectors into the $(x',y',z')$ representation:

M = {xp, yp, zp};

origR = {0.5, 0.5, 0};
origB = {0, 0.5, 0.5};
origG = {0.5, 0, 0.5};
red0 = 0.2 {2, -2, 0};
blue0 = 0.2 {-2, 0, 2};
green0 = 0.2 {0, 2, -2};

M . origR
(*    {0., -0.408248, 0.57735}    *)

M . red0
(*    {-0.565685, 0., 0.}    *)

meaning that $\text{origR} = 0x'-0.408248y'+0.57735z'$ and $\text{red0} = -0.565685x'+0y'+0z'$, and similarly for the green and blue arrows.

We can now define a transformation from $(x,y,z)$ to planar $(x',y')$ space:

T[{x_, y_, z_}] = Most[M . {x, y, z}] // FullSimplify
(*    {(y - x)/Sqrt[2], -(x + y - 2 z)/Sqrt[6]}    *)

in terms of which the 2D plot becomes

Module[{origR = {0.5, 0.5, 0}, origB = {0, 0.5, 0.5}, 
        origG = {0.5, 0, 0.5}, red0 = 0.2 {2, -2, 0}, 
        blue0 = 0.2 {-2, 0, 2}, green0 = 0.2 {0, 2, -2}}, 
  Graphics[{Red, Arrow[T /@ {origR, origR + red0}],
            Blue, Arrow[T /@ {origB, origB + blue0}],
            Green, Arrow[T /@ {origG, origG + green0}]},
           FrameLabel -> {"x'", "y'"}, Frame -> True]

enter image description here

$\endgroup$
3
$\begingroup$

Roman gave a perfect transformation to 2D coordinates. However, if you want to keep 3D and only transform the coordinates to the x/y plane, you may proceed as:

We choose arbitrarily a new origin: origR and turn the coordinate system so that the old {1,1,1} axes will point along {0,0,1} in the new axes.

First we set the coordinates, define our points and the new origin

{origR = {0.5, 0.5, 0}, origB = {0, 0.5, 0.5}, origG = {0.5, 0, 0.5}, 
  red0 = 0.2 {2, -2, 0}, blue0 = 0.2 {-2, 0, 2}, 
  green0 = 0.2 {0, 2, -2}}; (*set the coordinates*)
orig1 = origR;
pts0 = {origR, origR + red0, origB, origB + blue0, origG, origG + green0};

Then we define a transformation that shifts the origin to origR and rotate the coordinate system. With this transfromation we transfrom our points from pts0 to pts1:

transform = RotationMatrix[{{1, 1, 1}, {0, 0, 1}}] . (# - orig1) &;

pts1 = {origR, origB, origG, red0, blue0, green0} = transform /@ pts0;

With the new points we can draw the graphics:

Graphics3D[{Red, Arrow[pts1[[;; 2]]], Blue, Arrow[pts1[[3 ;; 4]]], 
  Green, Arrow[pts1[[5 ;;]]]}, ImageSize -> 300, 
 FaceGrids -> {Left, Back, Bottom}, FaceGridsStyle -> GrayLevel[0.5], 
 Axes -> True, Boxed -> True, AxesLabel -> {"x", "y", "z"}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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