I would like to create a cone model where the dimension (radius and height) are variable. The problem with my current model is that the dashed circle is not covered by the gray figure when the height is too small. Any idea how to solve this problem?
%%%%%%%%%%%%%%%%%% INTRODUCTION %%%%%%%%%%%%%%%%%%
\documentclass[border=10pt]{standalone}
%%%%%%%%%%%%%%%%%% PACKAGE %%%%%%%%%%%%%%%%%%
\usepackage{tikz, tkz-euclide}% permet de dessiner des figures, des graphiques
\usepackage{adjustbox}% permet de déterminer une taille de fenêtre
%% FONT
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tgadventor}% paquet de police de caractère TGadventor
\usepackage{sansmath}% Copie-colle la police active dans
% \sfdefault (/!\ N'EST PAS UNE POLICE DE CARACTÈRES)
\usepackage{xcolor}
%%%%%%%%%%%%%%%%%% INPUT %%%%%%%%%%%%%%%%%%
%\input{preamble}
%\input{parameters}
%\input{types/f3d_fig}
%%%%%%%%%%%%%%%%%% SETUP %%%%%%%%%%%%%%%%%%
\tikzset{volum3D/.style={font={\sansmath\sffamily\large}, line width=0.4mm, line cap=round, line join=round, >=latex,}}
%%%%%%%%%%%%%%%%%%%%%%%% SPHERE RADIUS LABEL %%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\tikzset{pics/cone radlab/.style={code={%
\tikzset{cone radlab/.cd,#1}%
\def\pv##1{\pgfkeysvalueof{/tikz/cone radlab/##1}}
\pgfmathsetmacro{\myan}{atan2(\pgf@zx,\pgf@xx)}
\begin{scope}[local bounding box=sph]
\path[cone radlab/corps]
%%% Patrie supérieur
plot[smooth,variable=\t,samples=19,domain=\myan:{-1*sign(\myan)*180+\myan}]
(0,
\pv{height},
0)
--
%%% Patrie Inférieur
plot[smooth,variable=\t,samples=19,domain=\myan:{-1*sign(\myan)*180+\myan}]
({\pv{ray}*\pv{scale}*cos(\t)},
0,
{\pv{ray}*\pv{scale}*sin(\t)})
-- cycle
;
\draw[thick, densely dashed]
%%% Arc Avant
plot[smooth,variable=\t,samples=19,domain={-1*sign(\myan)*180+\myan}:\myan]
({\pv{ray}*\pv{scale}*cos(\t)},
0,
{\pv{ray}*\pv{scale}*sin(\t)})
%%% Arc Arrière
plot[smooth,variable=\t,samples=19,domain={sign(\myan)*180+\myan}:\myan]
({\pv{ray}*\pv{scale}*cos(\t)},
0,
{\pv{ray}*\pv{scale}*sin(\t)})
;
\end{scope}
%% Dot (0,0)
\draw
(0,0,0) node[circle, fill=black, inner sep=1pt] {} coordinate (o)
(\pv{ray},0,0) coordinate (r)
;
%% Barre de mesure du rayon
\draw[densely dashed, <->]
(o) --
(r) node[midway, below, inner sep=6pt] {\pv{lab}}
;
}},
cone radlab/.cd,
ray/.initial=5,
height/.initial=10,
lab/.initial=5 cm,
scale/.initial=1,
corps/.style={draw,fill=black!15},
}
\makeatother
%%%%%%%%%%%%%%%%%% DOCUMENT %%%%%%%%%%%%%%%%%%
\begin{document}
\begin{tikzpicture}[volum3D, x={(0:1cm)}, y={(90:1cm)}, z={(89:0.4cm)}]
% calibration cross
%\pic at (5,0,0) {calcross};
% Figures
\pic{cone radlab};
\node[below, yshift= -36pt, text=orange] at (0,0,0) {D};
\end{tikzpicture}
\end{document}
wouldn't be possible to solve this with an equation feed by the height? So the part would be: 'green part -- left blue part -- left red part -- right red part -- right blue part -- cycle'