# Angle between lines in 3D space

In my following codes:

1. How can I create a beautiful mark angle for DCE angle?
2. How can I change position ALPHA in front of BAC angle in space?

\documentclass{article}
\usepackage{tikz,tikz-3dplot}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}
\tdplotsetmaincoords{60}{120}

\begin{tikzpicture}[
scale=3,
tdplot_main_coords,
axis/.style={->,blue,thick},
vector/.style={-stealth,red,very thick},
vector guide/.style={dashed,red,thick}
]

% standard tikz coordinate definition using x, y, z coords
\coordinate (O) at (0,0,0);
\coordinate (A) at (1,0,2);
\coordinate (B) at (.5,.86603,3);
\coordinate (C) at (0,0,1);
\coordinate (D) at (.5,.86603,0);
\coordinate (E) at (1,0,3);
\coordinate (F) at (0,0,3);
\coordinate (H) at (1,0,0);

% tikz-3dplot coordinate definition using r, theta, phi coords
\tdplotsetcoord{P}{.8}{55}{60}

% draw axes
\draw[axis] (0,0,0) -- (2,0,0) node[anchor=north east]{$x$};
\draw[axis] (0,0,0) -- (0,2,0) node[anchor=north west]{$y$};
\draw[axis] (0,0,0) -- (0,0,4) node[anchor=south]{$z$};

\fill[gray!20] (O) -- (H) -- (E) -- (F) -- cycle;
% \fill[green!50] (O) -- (D) -- (B) -- (F) -- cycle;
\fill[blue!20] (B) -- (E) -- (F) -- cycle;
\fill[blue!20] (O) -- (D) -- (H) -- cycle;

\fill[black] (O) circle (1pt) node[right] {$O$};
\fill[black] (A) circle (1pt) node[left] {$A$};
\fill[black] (B) circle (1pt) node[right] {$B$};
\fill[black] (C) circle (1pt) node[right] {$C$};
\fill[black] (D) circle (1pt) node[right] {$D$};
\fill[black] (E) circle (1pt) node[left] {$E$};
\fill[black] (F) circle (1pt) node[right] {$F$};
\fill[black] (H) circle (1pt) node[below] {$H$};

\draw[ultra thick] (O) -- (F);
\draw[thick] (O) -- (H);
\draw[thick] (O) -- (D);
\draw[thick] (D) -- (H);
\draw[thick] (H) -- (A);
\draw[thick] (A) -- (E);
\draw[thick] (F) -- (B);
\draw[thick] (B) -- (E);
\draw[thick] (E) -- (F);
\draw[thick,red] (B) -- (A);
\draw[thick,red] (A) -- (C);
\draw[thick,red] (C) -- (D);
\draw[thick] (B) -- (D);

\tkzMarkAngle[fill=orange,size=0.2cm,opacity=.4](C,A,B)
\tkzLabelAngle[above left,pos=0.3](C,A,B){$\alpha$}
\tkzMarkAngle[fill=orange,size=0.15cm,opacity=.4](A,C,D)
\tkzLabelAngle[above left,pos=0.3,font=\small](A,C,D){$\alpha$}
\end{tikzpicture}
\end{document}


My code's result.

Let me take the two subquestions in reverse order.

# Placing labels with \tkzLabelAngle

\tkzLabelAngle places labels on the line bisecting the angle. A pos argument gives the position of the label on that line as a proportion of the standard length. Additional arguments such as above are then relative to the point specified by the pos argument. To move the label further in the direction above you write something like above=5pt. Here is a right angle labelled at different pos values:

\documentclass{article}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}

\begin{tikzpicture}[scale=5]
\coordinate (A) at (1,0);
\coordinate (B) at (0,0);
\coordinate (C) at (0,1);
\draw (A) -- (B) -- (C);
\tkzMarkAngle[fill=orange,size=0.3,opacity=0.4](A,B,C);
\tkzLabelAngle[pos=0.1](A,B,C){$0.1$}
\tkzLabelAngle[pos=0.3](A,B,C){$0.3$}
\tkzLabelAngle[pos=0.5](A,B,C){$0.5$}
\tkzLabelAngle[pos=0.5,above](A,B,C){$0.5$ above}
\tkzLabelAngle[pos=0.5,above=20pt](A,B,C){$0.5$ above}
\tkzLabelAngle(A,B,C){$1$}
\end{tikzpicture}

\end{document}


Unfortunately tkz-euclide will sometimes get the wrong direction for the bisector:

\documentclass{article}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}

\begin{tikzpicture}[scale=5]
\coordinate (A) at (1,1);
\coordinate (B) at (0,0);
\coordinate (C) at (1,-1);
\draw (A) -- (B) -- (C);
\tkzMarkAngle[fill=orange,size=0.3,opacity=0.4](A,B,C);
\tkzLabelAngle[pos=0.1](A,B,C){$0.1$}
\tkzLabelAngle[pos=0.3](A,B,C){$0.3$}
\tkzLabelAngle[pos=0.5](A,B,C){$0.5$}
\tkzLabelAngle[pos=0.5,above](A,B,C){$0.5$ above}
\tkzLabelAngle[pos=0.5,above=20pt](A,B,C){$0.5$ above}
\tkzLabelAngle(A,B,C){$1$}
\end{tikzpicture}

\end{document}


This is what happen is in your angle at A. You can compensate for this by specifying negative arguments to pos instead. I would probably to just use ordinary tikz node placement for this, as in the code given below.

# Mark for angle DCE

You can use the same approach as for the other angles. However, there is a lot going at the node C, so positioning needs to be adjusted. I also suggest adding guide edges for the angle (dashed) and slightly rotating the view to help. Putting this together gives:

\documentclass{article}
\usepackage{tikz,tikz-3dplot}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}
\tdplotsetmaincoords{60}{125}

\begin{tikzpicture}[
scale=3,
tdplot_main_coords,
axis/.style={->,blue,thick},
vector/.style={-stealth,red,very thick},
vector guide/.style={dashed,red,thick}
]

% standard tikz coordinate definition using x, y, z coords
\coordinate (O) at (0,0,0);
\coordinate (A) at (1,0,2);
\coordinate (B) at (.5,.86603,3);
\coordinate (C) at (0,0,1);
\coordinate (D) at (.5,.86603,0);
\coordinate (E) at (1,0,3);
\coordinate (F) at (0,0,3);
\coordinate (H) at (1,0,0);

% tikz-3dplot coordinate definition using r, theta, phi coords
\tdplotsetcoord{P}{.8}{55}{60}

% draw axes
\draw[axis] (0,0,0) -- (2,0,0) node[anchor=north east]{$x$};
\draw[axis] (0,0,0) -- (0,2,0) node[anchor=north west]{$y$};
\draw[axis] (0,0,0) -- (0,0,4) node[anchor=south]{$z$};

\fill[gray!20] (O) -- (H) -- (E) -- (F) -- cycle;
\fill[blue!20] (B) -- (E) -- (F) -- cycle;
\fill[blue!20] (O) -- (D) -- (H) -- cycle;

\tkzMarkAngle[fill=orange,size=0.2cm,opacity=.4](C,A,B);
\draw (A) node[right=2pt,font=\small] {$\alpha$};
\tkzMarkAngle[fill=orange,size=0.15cm,opacity=.4](A,C,D);
\draw (C) node[below left,font=\small] {$\gamma$};
\tkzMarkAngle[fill=green,size=0.13cm,opacity=.6](D,C,E);
\draw (C) node[right,font=\small] {$\beta$};

\draw[ultra thick] (O) -- (F);
\draw[thick] (O) -- (H);
\draw[thick] (O) -- (D);
\draw[thick] (D) -- (H);
\draw[thick] (H) -- (A);
\draw[thick] (A) -- (E);
\draw[thick] (F) -- (B);
\draw[thick] (B) -- (E);
\draw[thick] (E) -- (F);
\draw[thick,red] (B) -- (A);
\draw[thick,red] (A) -- (C);
\draw[thick,red] (C) -- (D);
\draw[thick] (B) -- (D);
\draw[thin,dashed] (D) -- (C) -- (E);

\fill[black] (O) circle (1pt) node[above right] {$O$};
\fill[black] (A) circle (1pt) node[left] {$A$};
\fill[black] (B) circle (1pt) node[right] {$B$};
\fill[black] (C) circle (1pt) node[above right=7pt] {$C$};
\fill[black] (D) circle (1pt) node[right] {$D$};
\fill[black] (E) circle (1pt) node[left] {$E$};
\fill[black] (F) circle (1pt) node[above right] {$F$};
\fill[black] (H) circle (1pt) node[below] {$H$};

\end{tikzpicture}
\end{document}


You had two "alpha"s in your diagram, so I have renamed one of them "gamma". I have also change the printing order, so that the dot labels are uppermost in the diagram. As mentioned above, I decided not to use \tkzLabelAngle but just ordinary node placement for the labelling of the angles.

• Thanks. Realy I want that orange region of gamma's angle place in the plane that points A, C , D are on it. How?? Commented Jul 30, 2013 at 8:18
• tikz is not really 3d, it converts everything to their 2d projections at the start. You can fake it by passing an xscale option to \tkzLabelAngle making the marker elliptical on the paper rather than circular. Try e.g. xscale=0.9. Commented Jul 30, 2013 at 10:48