\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{César Navarro (CesarANS)} \pdfinfo{ /Title (dibujar-objetos-3d-en-processing.pdf) /Creator (Cheatography) /Author (César Navarro (CesarANS)) /Subject (Dibujar objetos 3D en Processing Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{179EA3} \definecolor{LightBackground}{HTML}{F0F8F9} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Dibujar objetos 3D en Processing Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{César Navarro (CesarANS)} via \textcolor{DarkBackground}{\uline{cheatography.com/143077/cs/31329/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}César Navarro (CesarANS) \\ \uline{cheatography.com/cesarans} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 25th March, 2022.\\ Updated 25th March, 2022.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{{\bf{{\emph{Lienzo}}}}}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Establecer las dimensiones del lienzo con la instrucción {\bf{size()}} y el parámetro {\bf{P3D}} para trabajar en 3D: {\bf{size(x, y, P3D)}}} \tn % Row Count 3 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{{\bf{{\emph{Propiedades del lienzo}}}}}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Establecer color de fondo, un color para la línea y un color de relleno con: \{\{nl\}\}{\bf{background(color)}} \{\{nl\}\}{\bf{stroke(color)}} \{\{nl\}\}{\bf{fill(color)}}} \tn % Row Count 4 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{{\bf{{\emph{Definir lugar de dibujo}}}}}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Establecer el punto para dibujar, inicialmente el punto de dibujo se encuentra en posición {\bf{(0,0,0)}}, esquina superior izquierda del lienzo. Con la instrucción: \{\{nl\}\}{\bf{traslate(x, y, z)}} \{\{nl\}\}{\bf{traslate(x, y)}}\{\{nl\}\}Trasladamos el origen de coordenadas al punto indicado.} \tn % Row Count 6 (+ 6) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{{\bf{{\emph{Vista del dibujo}}}}}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Para tener una vista en perspectiva de la figura, imponemos una rotación en sus ejes como:\{\{nl\}\}{\bf{rotateX(angulo)}}\{\{nl\}\}{\bf{rotateY(angulo)}}\{\{nl\}\}{\bf{rotateZ(angulo)}}} \tn % Row Count 4 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{{\bf{{\emph{Dibujar 3D funciones box and sphere}}}}}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Hay instrucciones que permiten dibujar ya en 3D en processing, como: \{\{nl\}\} {\bf{box(x)}} -\textgreater{} Dibuja un cubo de longitud de sus lados {\bf{x}}\{\{nl\}\}{\bf{sphere(x)}} -\textgreater{} Dibuja una esfera con radio {\bf{x}}} \tn % Row Count 4 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{{\bf{{\emph{Dibujar figuras 3D personalizadas}}}}}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Las figuras personalizadas se dibujan mediante:\{\{nl\}\}{\bf{beginShape()}}\{\{nl\}\}{\bf{endShape()}}\{\{nl\}\}{\bf{vertex(x,y,z)}}\{\{nl\}\}Colocando varios poligonos uno al lado del otro, esto se realiza haciendo polígono por polígono o con un ciclo que nos permita realizar esto.} \tn % Row Count 6 (+ 6) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{{\bf{{\emph{Paso 1}}}}}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Definir el numero de lados de la base en una variable, \newline las el ángulo en que se recorrerá, la altura y el radio: \newline \newline int sides = 10; \newline float angle = 360 / sides; \newline float halfHeight = height / 2; \newline float r = 100;} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{{\bf{{\emph{Paso 2}}}}}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Dibujar bases de la figura usando ciclos \newline y las funciones {\bf{sin}} y {\bf{cos}}. \newline \newline Estos pasos se repiten para dibujar la base inferior \newline y superior con la diferencia de la variable halfHeight, \newline donde una es positiva y la otra negativa, \newline o se puede omitir una en caso de no ocuparla: \newline \newline beginShape(); \newline     for (int i = 0; i \textless{} sides; i++) \{ \newline       float x = cos( radians( i {\emph{ angle ) ) }} r; \newline       float y = sin( radians( i {\emph{ angle ) ) }} r;  \newline       vertex( x, y, (-)halfHeight); \newline     \} \newline     endShape(CLOSE);} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{{\bf{{\emph{Paso 3 }}}}}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Dibujar contorno de la figura, para realizar esto es \newline lo mismo de la anterior pero a diferencia se debe \newline especificar {\bf{QUAD\_STRIP}} en el beginShape para \newline dibujar rectángulos, y para vertex se debe definir \newline tanto negativo como positivo. \newline \newline beginShape(QUAD\_STRIP); \newline      for (int i = 0; i \textless{} sides + 1; i++) \{ \newline        float x = cos( radians( i {\emph{ angle ) ) }} r; \newline        float y = sin( radians( i {\emph{ angle ) ) }} r; \newline        vertex( x, y, halfHeight); \newline        vertex( x, y, -halfHeight); \newline     \} \newline     endShape(CLOSE); \newline \newline {\bf{Nota:}} Todos los parámetros de cada ciclo pueden \newline cambiar dependiendo de la figura deseada, \newline debido a que no todas presentan las mismas \newline características.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}