10

I want to mark right angle. I tried in 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}

enter image description here How can I draw with anorher way?

Jesse
  • 29,686
minthao_2011
  • 4,534
  • 7
  • 36
  • 61

4 Answers4

6

This is one possible solution via tikz-3dplot. Here numbers are used for labeling for ease of programming. Explanatory comments are added in the code. The right angles on the xy plane are found via intersections of grid lines notion, that is, finding intersection points of parellel lines that are parallel to d5-d6 and d7-d8. enter image description here

Code

\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}
Jesse
  • 29,686
  • If 1234 is not a square, I think, we can not make a system of coordinates like that. – minthao_2011 Nov 25 '14 at 04:51
  • Points 1234 are on the same xy plane and that makes the coordinate system easier. If not, it would be much harder/complicated to draw. Agreed. – Jesse Nov 25 '14 at 05:23
1

We can easily create a mark for right angles ABC in 3D space.

enter image description here

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+sizeunit(A-B); triple Bc=B+sizeunit(C-B); triple Bt=Ba+Bc-B; draw(Ba--Bt--Bc,p);
};

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

PS 1: I like how the labels B, C, and H are flooded by the XY-plane ^^ With

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

the labels H is totally flooded.

enter image description here

PS 2 Another way to mark a 3D right angle is considering the mark as a path3, then draw it.

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);

Black Mild
  • 17,569
0

Another possible solution is to use the 3d library to draw in different plane. Use the tikz keys plane origin, plane x and plane y to set the new origin point and unit vectors, and canvas is plane to start drawing in the defined 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}

enter image description here

Note that in the proposed solution the angle M-H-B is drawn correctly.

0

Another, much simpler, solution for drawing right angles is to use the angle library:

\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}

enter image description here

The syntax is easy:

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

where point1, point2 and point3 are coordinates defining the angle, point2 being the vertex. If right angle is replaced by angle, the usual arc is drawn.

EDIT: Adding calculation of H and M points using coordinate systems defined at arbitrary planes (see section 40.2 of pgf manual v3.1) and intersection of perpendicular lines (see section 13.3.1):

EDIT 2: fix a bug in rotated XY plane

\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}

enter image description here

EDIT 3: Check calculation at differet view points.

\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}

enter image description here

Animation done using this solution.

  • Given A,B, and K. With 3d, can you construct the foot H, and M such that MK = 2 MH ? – Black Mild Oct 20 '21 at 04:54
  • Tikz is not a 3D CAD software, but you have tools for doing simple operations. In this case you can define different coordinate planes as needed and use "intersections of perpendicular lines" (syntax (A -| B)) in theses planes. See the edited answer. – Sergio Llorente Oct 20 '21 at 09:21
  • Unfornatunely, syntax (A-|B) only working in 2-dimension coordinates. In case of 3-dimension coordinates, it does not work (give wrong calculation!). It is said somewhere in pgfmanual – Black Mild Oct 20 '21 at 09:42
  • In this forum, there are some threads discuss on how the TikZ's 2D projection fails for 3D coordinates. I don't remember those links – Black Mild Oct 20 '21 at 09:49
  • My code has a bug: the rotated XY plane is not well defined. But I think that (A-|B) works perfectly in a general 2D plane, because is just a linear transform (I do not know in old versions). It is true that maybe it is not going to work as expected in xyz or spherical cs, but i am not using those. Give some minutes to show you an example. – Sergio Llorente Oct 20 '21 at 10:34
  • in a plane ($ (A)!1!90:(B) $) that is okay, because it is 2D! – Black Mild Oct 20 '21 at 11:58
  • Of course! I am working on 2D planes from the beginning! – Sergio Llorente Oct 20 '21 at 13:11
  • Thatis okay for this figure. However, in other non-coplanar cases, such as finding the common perpendicular segment of two given non-coplanar lines in R^3, then several things must be changed – Black Mild Oct 20 '21 at 14:10
  • That is a completely different problem that the one you asked in the first comment. – Sergio Llorente Oct 20 '21 at 14:19