I am trying to draw a complicated form that is loosely based on a half cylinder. I am using tikz-3dplot
to be able to accurately draw arcs in planes other than the xy
-plane and to nicely set the viewing angle.
Now I need to find the tangent on that cylinder to be able to fill the front area that can be seen. Based on the accepted answer in this question, I tried to compute the angle at which the arc has its maximum in the direction perpendicular to the cylinder axis (here y
). Unfortunately, I can not use this angle to draw the arc in the rotated coordinate system, since I would need to transform it before...
The following code should make things more clear. It draws axes for the normal and rotated coordinate systems and one arc of my cylindrical shape. I need to find the tangent to that arc to extrude the shape in direction of the y
-axis.
\documentclass[tikz]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{55}{40}
\begin{tikzpicture}[tdplot_main_coords]
% find directions of projection
\path (1,0,0);
\pgfgetlastxy{\axisxx}{\axisxy}
\path (0,1,0);
\pgfgetlastxy{\axisyx}{\axisyy}
\path (0,0,1);
\pgfgetlastxy{\axiszx}{\axiszy}
% angle of tangent
\pgfmathsetmacro{\tangang}{atan(-\axisyy/\axisyx)+180}
\draw[->] (0, 0, 0) -- (4, 0, 0) node (x) [anchor=north] {x};
\draw[->] (0, 0, 0) -- (0, 4, 0) node (y) [anchor=north] {y};
\draw[->] (0, 0, 0) -- (0, 0, 4) node [anchor=east] (z) {z};
%set theta plane to xz-plane
\tdplotsetthetaplanecoords{0}
\draw[tdplot_rotated_coords, red, ->] (0, 0, 0) -- (2, 0, 0) node [anchor=east] (xx) {x'};
\draw[tdplot_rotated_coords, red, ->] (0, 0, 0) -- (0, 2, 0) node [anchor=north] (yy) {y'};
\draw[tdplot_rotated_coords] (0, 0, 0) + (90:5) arc (90:270:5);
\draw[red, ->] (0, 0) -- ++(7*\axisyy, -7*\axisyx);
\draw[tdplot_rotated_coords, red, dashed, ->] (0, 0, 0,) -- ++(\tangang:5);
\end{tikzpicture}
\end{document}
As you can see in the output of this code, the computed angle finds the position of the tangent nicely (red line), but if that angle is used in the rotated coordinate system, I do not get the right place to draw the tangent (dashed red line).
Does anybody know how to find the tangent while working with tikz-3dplot
?