Skip to content

Instantly share code, notes, and snippets.

@nojima
Created May 8, 2021 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nojima/9d0a9a3dd45b64107d165fcb33dd1b85 to your computer and use it in GitHub Desktop.
Save nojima/9d0a9a3dd45b64107d165fcb33dd1b85 to your computer and use it in GitHub Desktop.
\documentclass[dvipdfmx,uplatex]{jsarticle}
\usepackage{tikz}
\usetikzlibrary{intersections, calc, arrows.meta, angles, quotes}
\usepackage{tkz-euclide}
\newcommand{\axis}[1]{\mathrm{#1}}
\begin{document}
\begin{tikzpicture}
% 視錐台を描く
\coordinate (O) at (0, 7.5);
\coordinate (CameraAxisZ) at (12, 7.5);
\coordinate (FrustumFarT) at (10, 12.5);
\coordinate (FrustumFarB) at (10, 2.5);
\draw[->] (O)--(CameraAxisZ);
\draw [name path=FrustumT] (O)--(FrustumFarT);
\draw [name path=FrustumB] (O)--(FrustumFarB);
\draw (O) node[left] {O};
\draw (CameraAxisZ) node[right] {$ \axis{z} $};
% サーフィスを描く
\coordinate (SurfaceL) at (6, 7.5);
\coordinate (SurfaceR) at (8.5, 9.5);
\draw (SurfaceL) node[below] {$ z $};
\draw [very thick] (SurfaceL)--(SurfaceR) node[midway,auto=right,sloped]{$ \Delta A $};
\coordinate (SurfaceZProjR) at ($ (O)!(SurfaceR)!(CameraAxisZ) $);
\draw (SurfaceZProjR) node[below] {$ z + \Delta z $};
\draw [dashed] (SurfaceZProjR)--(SurfaceR);
% シャドウマップの軸を描く
\coordinate (ShadowMapAxisL) at (0, 11);
\coordinate (ShadowMapAxisR) at (9, 14);
\draw[->] (ShadowMapAxisL)--(ShadowMapAxisR);
\draw (ShadowMapAxisR) node[right] {$ \axis{u} $};
% シャドウマップ上のピクセルを描く
\coordinate (ShadowMapPixelL) at ($ (ShadowMapAxisL)!(SurfaceL)!(ShadowMapAxisR) $);
\coordinate (ShadowMapPixelR) at ($ (ShadowMapAxisL)!(SurfaceR)!(ShadowMapAxisR) $);
\draw [dashed] (SurfaceL)--(ShadowMapPixelL);
\draw [dashed] (SurfaceR)--(ShadowMapPixelR);
\draw [very thick] (ShadowMapPixelL) node[above]{$ S(z) $} -- node[midway,above,sloped]{$ \Delta S $} node[at end,above]{$ S(z + \Delta z) $} (ShadowMapPixelR);
% NearPlane を描く
\coordinate (NearPlaneP) at (3, 7.5);
\draw (NearPlaneP) node[below] {$ z_n $};
\path [name path=NearPlane0] (3, 10)--(3, 0);
\path [name intersections={of=NearPlane0 and FrustumT}];
\coordinate (NearPlaneT) at (intersection-1);
\path [name intersections={of=NearPlane0 and FrustumB}];
\coordinate (NearPlaneB) at (intersection-1);
\draw [name path=NearPlane, dashed] (NearPlaneT)--(NearPlaneB);
% カメラ上のピクセルを描く
\draw [dashed, name path=RayT] (O)--(SurfaceR);
\path [name intersections={of=RayT and NearPlane}];
\coordinate (PixelT) at (intersection-1);
\draw [very thick] (NearPlaneP)--(PixelT) node[midway,auto=left]{$ \Delta P $};
\end{tikzpicture}
\begin{tikzpicture}[scale=2]
% 視錐台を描く
\coordinate (O) at (4, 7.5);
\coordinate (CameraAxisZ) at (10, 7.5);
\draw[->] (O)--(CameraAxisZ);
\draw (O) node[left] {O};
\draw (CameraAxisZ) node[right] {$ \axis{z} $};
% サーフィスを描く
\coordinate (SurfaceL) at (6, 7.5);
\coordinate (SurfaceR) at (8.5, 9.5);
\draw [very thick] (SurfaceL)--(SurfaceR) node[midway,auto=left,sloped]{$ \Delta A $};
\coordinate (SurfaceZProjR) at ($ (O)!(SurfaceR)!(CameraAxisZ) $);
\draw [dashed] (SurfaceZProjR)--(SurfaceR);
\draw [gray] (SurfaceZProjR) .. controls +(30:4mm) and +(-30:4mm) .. (SurfaceR) node[black,midway,fill=white]{$ \Delta y $};
\draw [gray] (SurfaceL) .. controls +(-45:4mm) and +(-135:4mm) .. (SurfaceZProjR) node[black,midway,fill=white]{$ \Delta z $};
% 補助線
\coordinate (H) at ($ (SurfaceL)!0.75!90:(SurfaceR) $);
\draw [dashed] (SurfaceL)--(H);
\tkzMarkRightAngle[size=0.15](SurfaceR,SurfaceL,H);
\draw pic ["$\theta$",draw,angle radius=5mm,angle eccentricity=1.75]{angle = H--SurfaceL--O};
\draw pic ["$90^\circ-\theta$",draw,angle radius=5mm,angle eccentricity=2.5]{angle = CameraAxisZ--SurfaceL--SurfaceR};
\draw pic ["$\theta$",draw,angle radius=5mm,angle eccentricity=1.75]{angle = SurfaceL--SurfaceR--SurfaceZProjR};
\end{tikzpicture}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment