I'm trying to produce this simple 3d picture,

enter image description here

but, since it's the first time I draw a 3d pic, I'm not sure about how to get the plane passing through the line X. The following code shows a first attempt. I tried to use \filldraw, with random points, but I'm sure this is not the best way to do that.




    \coordinate (O) at (0, 0, 0);
    \coordinate (A) at (2,3,1);
    \draw[thick,->] (O) --++ (4.5,0,0) node[anchor=north east]{spot 0};     
    \draw[thick,->] (O) --++ (0,4.5,0) node[anchor=north east]{spot 1};     
    \draw[thick,->] (O) --++ (0,0,6) node[anchor=east]{spot 2};
    \draw[->] (O)--(A) node[anchor=west]{$\Phi$};
    \draw [thick] ($(O)!4cm!270:(A)$) -- ($(O)!3cm!90:(A)$)                                       node[anchor=east]{$X$};
    \filldraw[fill=blue!10, opacity=0.6] (2.5,-2.5,1) -- (2.5,1,1) --  (4,3,1) -- (4,-0.5,1) -- (2.5,-2.5,1);


The plane H should intersect X and be perpendicular to p, which is why I defined first p, and then its orthogonal line X. Maybe should I define some coordinates on X , and then define somehow H? I'd like to get the "projection" of p also, as in the figure. That's not a projection in fact, it is there just to highlight that p is a vector of R3.

  • 1
    Note that calc does not support "real" 3d computations. Also the projection of p on the plane requires a prescription. Since p is the normal the naive projection is zero. What kind of projection do you have in mind? What is the relation between between your point A and p? – user121799 May 7 '19 at 23:27
  • I think it's clear to you now, anyway I edited the question so that it's more clear what p is. – Nenne May 8 '19 at 8:22

I'd like to recommend tikz-3dplot for that.

  \begin{scope}[canvas is xy plane at z=0]
   \fill[gray,fill opacity=0.3] (-2,-3) rectangle (2,3); 
   \draw[very thick] (-2,0) -- (2,0);
   \path (-150:2) coordinate (H) (-1.5,0) coordinate(X);
   \draw[very thick,-stealth,gray] (0,0) -- (-30:1.5);
  \draw[stealth-] (H) -- ++ (-1,0,0.2) node[pos=1.3]{$H$};
  \draw[stealth-] (X) -- ++ (0,1,0.2) node[pos=1.3]{$X$};
  \draw[very thick,-stealth] (0,0,0) coordinate (O) -- (0,0,3) node[right]{$p$};
 \draw[-stealth]  (O)-- (2.5*\Radius,0,0) node[pos=1.15] {spot $0$};
 \draw[-stealth] (O) -- (0,3.5*\Radius,0) node[pos=1.15] {spot $2$};
 \draw[-stealth] (O) -- (0,0,2.5*\Radius) node[pos=1.05] {spot $1$};

enter image description here

| improve this answer | |
  • thank you! that's perfect, but when I try to run my code the gray plane doesn't get out. why? is that a problem of updating again? I tried to run it on the online LaTeX Editor too, but still the plane is not there. If I change the coordinates, it draws a rectangle, but that's not the plane in your figure. – Nenne May 8 '19 at 8:34
  • 1
    @Nenne Yes, there was a bug in the 3d library that got fixed not so long ago. So you may want to update your TeX installation. If that's not an option, you can add this fix. – user121799 May 8 '19 at 13:54
  • I prefer not to update my installation for the moment, since I've been warned that many commands could no longer work and I've to handle my bachelor thesis very soon. if something goes wrong, I would not be able to fix the problem by myself. so what part of the code you linked me should I add? – Nenne May 8 '19 at 14:41
  • 1
    @Nenne Add \usetikzlibrary{3d}\makeatletter \tikzoption{canvas is xy plane at z}[]{% \def\tikz@plane@origin{\pgfpointxyz{0}{0}{#1}}% \def\tikz@plane@x{\pgfpointxyz{1}{0}{#1}}% \def\tikz@plane@y{\pgfpointxyz{0}{1}{#1}}% \tikz@canvas@is@plane } \makeatother right before \begin{document}. – user121799 May 8 '19 at 14:44
  • 1
    @Nenne No, only if you using the 3d library and specifically the xy plane. All other planes are fine yx, xz, zx, yz and zy. One can always rewrite a code made for the xy plane to work with the yx plane but this is a bit counter-intuitive. – user121799 May 8 '19 at 14:58

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.