如何像该图一样在 3D 几何图形中制作直角标记?

如何像该图一样在 3D 几何图形中制作直角标记?

我想标记直角。我在 Geogebra 中尝试过

\documentclass{standalone}
\usepackage{pstricks-add}
\begin{document}
\psset{xunit=1.0cm,yunit=1.0cm,algebraic=true,dotstyle=*,dotsize=3pt 0,linewidth=0.8pt,arrowsize=3pt 2,arrowinset=0.25}
\begin{pspicture*}(-2.37,-0.3)(6.25,4.31)
\psline(1.56,0.36)(4.66,1.76)
\psline(0.68,1.36)(2.68,0.87)
\psline(0.68,3.92)(2.68,0.87)
\psline(2.49,1.15)(2.82,1.3)
\psline(2.82,1.3)(3.01,1.01)
\psline(1.82,0.8)(2.28,0.69)
\psline(1.82,0.8)(2.22,0.98)
\psline(0.68,3.92)(0.68,1.36)
\psline(0,2)(-2,0)
\psline(0,2)(6,2)
\psline(6,2)(4,0)
\psline(4,0)(-2,0)
\parametricplot{0.0}{0.7853981633974483}{1*0.91*cos(t)+0*0.91*sin(t)+-2|0*0.91*cos(t)+1*0.91*sin(t)+0}
\psline(-2,0)(4,0)
\psline(1,1.58)(0.68,1.66)
\psline(1,1.58)(1,1.28)
\rput[tl](2.69,0.79){H}
\rput[tl](0.51,1.27){K}
\psdots(1.56,0.36)
\rput[bl](1.7,0.15){$A$}
\psdots(4.66,1.76)
\rput[bl](4.7,1.5){$B$}
\psdots(0.68,3.92)
\rput[bl](0.74,3.99){$M$}
\rput[bl](-1.53,0.12){$\beta$}
\end{pspicture*} 
\end{document}

在此处输入图片描述 我怎样才能用另一种方式绘画?

答案1

这是通过 实现的一种可能解决方案tikz-3dplot。这里使用数字进行标记,以方便编程。代码中添加了解释性注释。xy 平面上的直角是通过intersections of grid lines概念找到的,即找到与d5-d6和平行的平行线的交点d7-d8在此处输入图片描述

代码

\documentclass[border=2pt]{standalone}
%\usepackage[utf8]{inputenc} 
\usepackage{tikz,tikz-3dplot}
\usetikzlibrary{calc,positioning,intersections}
\tdplotsetmaincoords{70}{120}
\begin{document}
\begin{tikzpicture}[scale=2, tdplot_main_coords,axis/.style={->,dashed},thick]
% -- remove these 3 lines if no axis is preferred
\draw[axis] (-2, 0, 0) -- (5, 0, 0) node [right] {$X$};
\draw[axis] (0, 0, 0) -- (0, 5, 0) node [above] {$Y$};
\draw[axis] (0, 0, 0) -- (0, 0, 2) node [above] {$Z$};
% define points
\coordinate  (d1) at (0,0,0){};
\coordinate  (d2) at (4,0,0){};
\coordinate  (d3) at (4,4,0){};
\coordinate  (d4) at (0,4,0){};
\coordinate  (d5) at (3,2,0){};
\coordinate  (d6) at (1,3,0){};
\coordinate  (d7) at ($(d5)!0.7!(d6)$){};
\coordinate  (d8) at (1,1,0){}; 
\coordinate  (d9) at (1,1,2){}; 
\path  (d7) -- ($(d7)!-2cm!(d8)$) coordinate(e1);    % find the extended point e1
\path  (d5) -- ($(d5)! 3cm!(d6)$) coordinate(e2);    % find the extended point e2
% connect lines
\draw [] (d1)--(d2)--(d3)--(d4) -- (d1);                         
\draw [name path=line4] (d5) --(d6);
\draw [] (d7) --(d8) -- (d9)-- (d7);
\coordinate (a) at ($(d8)!0.2!(d7)$);                % find point a on the  line d8-d7
% draw vertical lines of length 0.3cm and form a right angle on z plane
\draw [red] (d8)  ++(0,0,0.3) -- ($(a)+(0,0,0.3)$)--(a);     
% auxiliary lines to find right corners via drawing parallel/grid lines
\path [name path=line1] ([xshift= 0.5cm]d8) -- ([xshift= 0.5cm]d7);
\path [name path=line2] ([xshift=-0.5cm]d8) -- ([xshift=-0.5cm]e1);
\path [name path=line3] ([xshift=-1cm]d5) -- ([xshift=-1cm]e2);
% find intersections corners
\path [name intersections={of=line1 and line3, by={D1}}];
\path [name intersections={of=line1 and line4, by={D2}}];
%
\path [name intersections={of=line2 and line3,by={E1}}];
\path [draw,name intersections={of=line2 and line4, by={E2}}];
\draw [red]  (D1) -- (D2)   (E1) -- (E2)  (E1) -- (D1);
% --- labels for vertices
\foreach \i in {1,2,...,9}
{
\draw[fill=black] (d\i) circle (0.1em) node[above left] {\i};
}
\draw (d2) -- ++(0,0.5,0) arc (90:150:1)node[below]{\Large $\beta$};

\end{tikzpicture}
\end{document}

答案2

我们可以轻松地在 3D 空间中创建直角 ABC 的标记。

在此处输入图片描述

unitsize(1cm);
import three;
currentprojection=orthographic(dir(70,20),zoom=.95);
path3 p=plane(5X, 7Y,O);
draw(surface(p),lightgray+opacity(.5));
//draw(surface(p),lightgray+opacity(1));

draw(Label("$x$",EndPoint),O--6X,Arrow3);
draw(Label("$y$",EndPoint),O--8Y,Arrow3);
draw(Label("$z$",EndPoint),O--3Z,Arrow3);

triple A=(2,2,0), B=(4.5,3,0), C=(1,6,0);
triple H=(A+reflect(B,C,C+Z)*A)/2;
triple D=A+3Z;
draw(B--C^^D--A--H,blue);
dot("$A$",A,W);
dot("$B$",B,W);
dot("$C$",C,E);
dot("$H$",H,S,red);
dot("$D$",D,N);

// to mark right angle ABC in 3D space
void Rmark(triple A, triple B, triple C, real size=.5,pen p=currentpen){
triple Ba=B+size*unit(A-B);
triple Bc=B+size*unit(C-B);
triple Bt=Ba+Bc-B;
draw(Ba--Bt--Bc,p);  
};

Rmark(A,H,C,red);
Rmark(D,A,H,.6,orange);

附言 1:我喜欢标签BCH被 XY 平面淹没的方式 ^^

draw(surface(p),lightgray+opacity(1));

标签H已完全被淹没。

在此处输入图片描述

PS2 游戏标记 3D 直角的另一种方法是将标记视为path3,然后绘制它。

path3 Rmark(triple A, triple B, triple C, real size=.5){
triple Ba=B+size*unit(A-B);
triple Bc=B+size*unit(C-B);
triple Bt=Ba+Bc-B;
return Ba--Bt--Bc;  
};

draw(Rmark(A,H,C),red);
draw(Rmark(D,A,H,.6),orange);

答案3

另一个可能的解决方案是使用库在不同3d的平面上绘制。使用 tikz 键plane origin和设置新的原点和单位向量,并在定义的平面上开始绘制。plane xplane ycanvas is plane

\documentclass[tikz, border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{3d}
\usetikzlibrary{calc}

\tikzset{
  axis/.style = {color = blue,very thin,->,},
  % Set the axonometric 3d view that you prefer setting x, y, z unit vectors
  x={(-135:0.8cm)},
  y={(0:1cm)},
  z={(90:1cm)},
}

\begin{document}
\begin{tikzpicture}
    % -- add these 3 lines if axis is preferred
    %\draw[axis] (0, 0, 0) -- (5, 0, 0) node [right] {$X$};
    %\draw[axis] (0, 0, 0) -- (0, 5, 0) node [above] {$Y$};
    %\draw[axis] (0, 0, 0) -- (0, 0, 5) node [above] {$Z$};
    % define points
    \path 
    (0,0,0) coordinate (d1)
    (4,0,0) coordinate (d2)
    (4,4,0) coordinate (d3)
    (0,4,0) coordinate (d4)
    (3,2,0) coordinate[label=left:$A$] (d5) node [circle, fill=black, inner sep=1.5pt] {}
    (1,3,0) coordinate[label=right:$B$] (d6) node [circle, fill=black, inner sep=1.5pt] {}
    (1,1,0) coordinate[label=below:$K$] (d8)
    (1,1,2) coordinate[label=$M$] (d9) node [circle, fill=black, inner sep=1.5pt] {}
    ($(d5)!0.7!(d6)$) coordinate[label=below:$H$] (d7)
    ;

    % If you want to write on xy plane:
    \draw[canvas is xy plane at z=0] (d2) -- ++(0,0.5,0) arc (90:150:1)
    (d2) ++(-0.25,0.25) node[rotate=90, transform shape]{$\beta$};
    % If not
    %\draw (d2) -- ++(0,0.5,0) arc (90:150:1) 
    (d2) ++(-0.25,0.25) node {$\beta$};

    \draw (d1) -- (d2) -- (d3) -- (d4) -- cycle;
    \draw (d5) -- (d6);
    \draw (d8) -- (d7) -- (d9) -- cycle;

    % Draw right-angle marks in different planes
    
    \begin{scope}[
            plane origin = {(d7)},
            plane x = { ($(d7)!0.33cm!(d5)$) },
            plane y = { ($(d7)!0.33cm!(d8)$) },
            canvas is plane,
            red,
            thick
        ]
        \draw  (1,0) -- (1,1) -- (0,1);
    \end{scope}
    
    \begin{scope}[
            plane origin = {(d7)},
            plane x = { ($(d7)!0.33cm!(d6)$) },
            plane y = { ($(d7)!0.33cm!(d9)$) },
            canvas is plane,
            red,
            thick
        ]
        \draw  (1,0) -- (1,1) -- (0,1);
    \end{scope}

    \begin{scope}[
            plane origin = {(d8)},
            plane x = { ($(d8)!0.33cm!(d7)$) },
            plane y = { ($(d8)!0.33cm!(d9)$) },
            canvas is plane,
            red,
            thick
        ]
        \draw  (1,0) -- (1,1) -- (0,1);
    \end{scope}

\end{tikzpicture}
\end{document}

在此处输入图片描述

请注意,在提出的解决方案中,角度 MHB 绘制正确。

答案4

绘制直角的另一种更简单的解决方案是使用angle库:

\documentclass[tikz, border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{3d}
\usetikzlibrary{calc}
\usetikzlibrary{angles}

\tikzset{
  axis/.style = {color = blue,very thin,->,},
  % Set the axonometric 3d view that you prefer setting x, y, z unit vectors
  x={(-135:0.8cm)},
  y={(0:1cm)},
  z={(90:1cm)},
}

\begin{document}
\begin{tikzpicture}
    % -- add these 3 lines if axis is preferred
    %\draw[axis] (0, 0, 0) -- (5, 0, 0) node [right] {$X$};
    %\draw[axis] (0, 0, 0) -- (0, 5, 0) node [above] {$Y$};
    %\draw[axis] (0, 0, 0) -- (0, 0, 5) node [above] {$Z$};
    % define points
    \path 
    (0,0,0) coordinate (d1)
    (4,0,0) coordinate (d2)
    (4,4,0) coordinate (d3)
    (0,4,0) coordinate (d4)
    (3,2,0) coordinate[label=left:$A$] (d5) node [circle, fill=black, inner sep=1.5pt] {}
    (1,3,0) coordinate[label=right:$B$] (d6) node [circle, fill=black, inner sep=1.5pt] {}
    (1,1,0) coordinate[label=below:$K$] (d8)
    (1,1,2) coordinate[label=$M$] (d9) node [circle, fill=black, inner sep=1.5pt] {}
    ($(d5)!0.7!(d6)$) coordinate[label=below:$H$] (d7)
    ;

    \draw (d1) -- (d2) -- (d3) -- (d4) -- cycle;
    \draw (d5) -- (d6);
    \draw (d8) -- (d7) -- (d9) -- cycle;

    % common angle
    \pic [draw=blue, pic text={$\beta$} ] {angle = d3--d2--d1};
    
    % Right angle
    \pic [draw=red, angle radius=0.33cm ] {right angle = d5--d7--d8};
    \pic [draw=red, angle radius=0.33cm ] {right angle = d6--d7--d9};
    \pic [draw=red, angle radius=0.33cm ] {right angle = d7--d8--d9};

\end{tikzpicture}
\end{document}

在此处输入图片描述

语法很简单:

\pic[draw, *other_options*] {right angle= *point1* -- *point2* -- *point3*}

其中point1point2point3是定义角度的坐标,point2是顶点。如果right angle被 替换angle,则绘制通常的弧。

编辑:使用在任意平面定义的坐标系添加 H 和 M 点的计算(参见第 40.2 节pgf 手册v3.1) 和垂直线相交(参见 13.3.1 节):

编辑 2:修复旋转 XY 平面中的一个错误

\documentclass[tikz, border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{3d}
\usetikzlibrary{calc}
\usetikzlibrary{angles}

\tikzset{
  axis/.style = {color = blue,very thin,->,},
  % Set the axonometric 3d view that you prefer setting x, y, z unit vectors
  x={(-135:0.8cm)},
  y={(0:1cm)},
  z={(90:1cm)},
}

\begin{document}
\begin{tikzpicture}
    % -- add these 3 lines if axis is preferred
    %\draw[axis] (0, 0, 0) -- (5, 0, 0) node [right] {$X$};
    %\draw[axis] (0, 0, 0) -- (0, 5, 0) node [above] {$Y$};
    %\draw[axis] (0, 0, 0) -- (0, 0, 5) node [above] {$Z$};
    % define points
    \path 
    (0,0,0) coordinate (d1)
    (4,0,0) coordinate (d2)
    (4,4,0) coordinate (d3)
    (0,4,0) coordinate (d4)
    (3,2,0) coordinate[label=left:$A$] (A)  node [circle, fill=black, inner sep=1.5pt] {}
    (1,3,0) coordinate[label=right:$B$] (B) node [circle, fill=black, inner sep=1.5pt] {}
    (1,1,0) coordinate[label=below:$K$] (K) node [circle, fill=black, inner sep=1.5pt] {}
    ;

    \draw (d1) -- (d2) -- (d3) -- (d4) -- cycle;
    \draw (A) -- (B);

    % common angle
    \pic [draw=blue, pic text={$\beta$} ] {angle = d3--d2--d1};
   
    % Finding H.
    % The XY plane is rotated to adjust the X-axis to the A-B line.
    \draw[canvas is xy plane at z=0] ($ (A)!1!90:(B) $) coordinate (Bp);
    \draw[
      plane origin = { (A) },
      plane x = { (B) },
      plane y = { (Bp) },
      canvas is plane,
      red
    ] 
    (A -| K) coordinate[label=below:$H$] (H) node [circle, fill, inner sep=1.5pt] {}
    ;
    
    % Finding M.
    % Now the coordinate system has the unit vector X fixed on the line K-H, and the 
    % unit vector Y is the original unit vector Z.
    \draw[
      plane origin = { (K) },
      plane x = { (H) },
      plane y = { ($ (K) + (0,0,1) $) },
      canvas is plane,
      red
    ] 
    (0,0) -- (0,2) coordinate[label=above:$M$] (M) node [circle, fill, inner sep=1.5pt] {}
    ;

    \draw[red] (K) -- (H);
    \draw[red] (K) -- (M);
    \draw[red] (M) -- (H);

    % Right angle
    \pic [draw=red, angle radius=0.33cm ] {right angle = A--H--K};
    \pic [draw=red, angle radius=0.33cm ] {right angle = B--H--M};
    \pic [draw=red, angle radius=0.33cm ] {right angle = H--K--M};

\end{tikzpicture}
\end{document}

在此处输入图片描述

编辑 3:检查不同视点的计算。

\documentclass[tikz, border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{3d}
\usetikzlibrary{calc}
\usetikzlibrary{angles}
\usetikzlibrary{perspective}

\tikzset{
  axis/.style = {color = blue,very thin,->,},
  % Set the axonometric 3d view that you prefer.
  3d view={120}{20},
  % Caution about perspective library: Vanishing points will not work in this example
}

\begin{document}
\foreach \angle in {5,15,...,355}
{
\begin{tikzpicture}[3d view={\angle}{20}]
    % -- add these 3 lines if axis is preferred
    \draw[axis] (0, 0, 0) -- (5, 0, 0) node [right] {$x$};
    \draw[axis] (0, 0, 0) -- (0, 5, 0) node [above] {$y$};
    \draw[axis] (0, 0, 0) -- (0, 0, 3) node [above] {$z$};
    % define points
    \path 
    (0,0,0) coordinate (d1)
    (4,0,0) coordinate (d2)
    (4,4,0) coordinate (d3)
    (0,4,0) coordinate (d4)
    (3,2,0) coordinate (A)  node [circle, fill=black, inner sep=1pt] {}
    (1,3,0) coordinate (B) node [circle, fill=black, inner sep=1pt] {}
    (1,1,0) coordinate (K) node [circle, fill=black, inner sep=1pt] {}
    ;

    \draw (d1) -- (d2) -- (d3) -- (d4) -- cycle;
    \draw (A) -- (B);
    
    \draw[canvas is xy plane at z=0, help lines] (d1) grid (d3);

    % Finding H.
    % % The XY plane is rotated to adjust the X-axis to the A-B line.
    \path[canvas is xy plane at z=0] ($ (A)!1!90:(B) $) coordinate (Bp);
    \draw[
      plane origin = { (A) },
      plane x = { (B) },
      plane y = { (Bp) },
      canvas is plane,
      red
    ] 
    (A -| K) coordinate (H) node [circle, fill, inner sep=1pt] {}
    ;
    
    % Finding M.
    % Now the coordinate system has the unit vector X fixed on the line K-H, and the 
    % unit vector Y is the original unit vector Z.
    \draw[
      plane origin = { (K) },
      plane x = { (H) },
      plane y = { ($ (K) + (0,0,1) $) },
      canvas is plane,
      red
    ] 
    (0,0) -- (0,2) coordinate (M) node [circle, fill, inner sep=1pt] {}
    ;

    \draw[red] (K) -- (H);
    \draw[red] (K) -- (M);
    \draw[red] (M) -- (H);

    % Right angle
    \pic [draw=red, angle radius=0.2cm ] {right angle = A--H--K};
    \pic [draw=red, angle radius=0.2cm ] {right angle = B--H--M};
    \pic [draw=red, angle radius=0.2cm ] {right angle = H--K--M};
    \tikzset{x={(1cm,0)}, y={(0,1cm)}}
    \path (-6,-2.5) rectangle (6,4);

\end{tikzpicture}
}
\end{document}

在此处输入图片描述

动画使用此解决方案

相关内容