答案1
使用 Ti 的(或多或少)可定制的解决方案钾Zperspective
和calc
库。第一个修复了 3D 视图,第二个有助于放置一些坐标。
我的代码:
\documentclass[border=2mm,tikz]{standalone}
\usetikzlibrary{calc,perspective}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,
3d view={120}{25},
scale=2]
% dimensions
\def\xx{2} % interxection plane -- OX, >0
\def\yy{3} % interxection plane -- OY, >0
\def\zz{3} % interxection plane -- OZ, >0
\def\nl{2.5} % normal vector length
\def\px{0.2} % P, coordinate x
\def\py{0.8} % P, coordinate y
\def\qx{0.4} % P0, coordinate x
\def\qy{1.6} % P0, coordinate y
\pgfmathsetmacro\pz{\zz*(1-\px/\xx-\py/\yy)} % P, coordinate z
\pgfmathsetmacro\qz{\zz*(1-\qx/\xx-\qy/\yy)} % P0, coordinate z
% coordinates
\coordinate (O) at (0,0,0);
\coordinate (A) at (\xx,0,0);
\coordinate (B) at (0,\yy,0);
\coordinate (C) at (0,0,\zz);
\coordinate (P) at (\px,\py,\pz);
\coordinate (P0) at (\qx,\qy,\qz);
\coordinate (N0) at ($(P0)+(1/\xx,1/\yy,1/\zz)$); % normal vector (end point)
\coordinate (N) at ($(P0)!\nl cm!(N0)$); % normal vector (end point),
% axes with the desired length
\foreach\i/\j in {A/x,B/y,C/z}
{
\draw[dashed] (O) -- (\i);
\draw[-latex] (\i) -- ($(\i)!-1cm!(O)$);
\node at ($(\i)!-1.2cm!(O)$) {$\j$};
}
% showing that the points are in the plane (not in the original picture)
\draw[gray] (\px,\py,0) -- (P);
\draw[gray] (\px,0,\pz) -- (P);
\draw[gray] (0,\py,\pz) -- (P);
\draw[gray] (\qx,\qy,0) -- (P0);
\draw[gray] (\qx,0,\qz) -- (P0);
\draw[gray] (0,\qy,\qz) -- (P0);
% plane
\draw[green!50!black,thick,fill=green,fill opacity=0.4] (A) -- (B) -- (C) -- cycle;
% points
\fill (P) circle (1pt) node[above] {$P(x,y,z)$};
\fill (P0) circle (1pt) node[right] {$P_0(x_0,y_0,z_0)$};
\fill (N) circle (1pt) node[above] {$(a,b,c)$};
% vectors
\draw[very thick,latex-latex,teal!70!blue]
(P) -- (P0) -- (N) node [black,midway,below right] {$\mathbf{n}$};
% right angle
\coordinate (AUX) at ($($(P0)!0.5cm!(P)$)!0.5!($(P0)!0.5cm!(N)$)$); % right angle vertex
\draw[red] ($(P0)!0.25cm!(P)$) -- (AUX) -- ($(P0)!0.25cm!(N)$);
\end{tikzpicture}
\end{document}
答案2
首先的建议是:
\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\renewcommand{\baselinestretch}{2}
\begin{document}
\begin{tikzpicture}
%z axis
\draw[-stealth] (0,1) -- (0,2) node[above] {\textit{z}};
\draw[dashed] (0,0) -- (0,1);
%y axis
\draw[-stealth] (1,0) -- (2,0) node[above] {\textit{y}};
\draw[dashed] (0,0) -- (1,0);
%y axis
\draw[dashed] (0,0) -- (-0.5,-0.5);
\draw[-stealth] (-0.5,-0.5) -- (-1,-1) node[below] {\textit{x}};
%triangle
\draw[fill=green!30,draw=green!30,opacity=0.2] (-0.5,-0.5) node[anchor=north]{}
-- (0,1) node[anchor=north]{}
-- (1,0) node[anchor=south]{}
-- cycle;
%arrows
\filldraw[blue] (0.4,0.2) circle (1pt);
\node[fill,circle,inner sep=0pt,minimum size=2pt,blue] (A) at (0.3,0.8) {};
\node[fill,circle,inner sep=0pt,minimum size=2pt,blue] (B) at (0.8,0.4) {};
\draw[-stealth,blue] (0.4,0.2) -- (A);
\draw[-stealth,blue] (0.4,0.2) -- (B);
\end{tikzpicture}
\end{document}