intersecciones 3d

intersecciones 3d

Como ejercicio, intento dibujar la intersección del prisma [0,2] x [0,4] x [0,6], y el plano x + y + z = 5.

ingrese la descripción de la imagen aquí

Mi resultado es:

\documentclass{article}

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}
    
\begin{tikzpicture}[x={(-0.45cm,-0.385cm)},y={(1cm,-0.1cm)},z={(0,1cm)}]
    \draw [->] (0,0,0) -- (6,0,0) node [below left] {$x$};
    \draw [->] (0,0,0) -- (0,6,0) node [right] {$y$};
    \draw [->] (0,0,0) -- (0,0,6) node [right] {$z$};
    
    \filldraw [thick, orange, fill opacity=0.3] (0,0,5) -- (0,4,1) -- (1,4,0) -- (2,3,0) -- (2,0,3) -- cycle;
    \filldraw [thick, blue, fill opacity=0.2] (2,3,0) -- (2,0,3) -- (5,0,0) -- cycle;
    \filldraw [thick, blue, fill opacity=0.2] (1,4,0) -- (0,5,0) -- (0,4,1) -- cycle;
    
    \filldraw [thick, orange, fill opacity=0.3] (2,3,0) -- (2,0,0) -- (2,0,3) -- cycle;
    \filldraw [thick, orange, fill opacity=0.3] (1,4,0) -- (0,4,0) -- (0,4,1) --cycle;
    
\end{tikzpicture}

\end{document}

ingrese la descripción de la imagen aquí

Tengo algunas preguntas ahora:

  • Creo que hay mucho código solo para representar un volumen matemático sencillo como [0,2] x [0,4] x [0,6]. ¿Existe alguna forma más eficiente de dibujarlo?
  • ¿Necesito calcular las intersecciones a mano y luego representarlas? ¿O hay algún método directo?
  • ¿Cómo puedo obtener el mismo resultado usando un axisentorno y \addplotcomandos en lugar de \draw? Lo he intentado pero soy nuevo en esto \addplot3y tengo problemas con la posición del eje ( view={}{}), colormapno tiene un color homogéneo, la superficie tiene una cuadrícula que dificulta la comprensión de la imagen y tengo la misma duda en las intersecciones. ¿Necesito calcularlos a mano?

El prisma completo es:

\draw [fill=orange, fill opacity=0.3] (0,0,6) -- (2,0,6) -- (2,4,6) -- (0,4,6) -- cycle ;
\draw [fill=orange, fill opacity=0.3] (2,0,0) -- (2,0,6) -- (2,4,6) -- (2,4,0) -- cycle ;
\draw [fill=orange, fill opacity=0.3] (2,4,0) -- (0,4,0) -- (0,4,6) -- (2,4,6) -- cycle ;

Respuesta1

Independientemente de lo que hagas, considera instalar una vista 3D de una manera más sistemática. Quizás la mejor manera de conseguirlo sea utilizar asymptote, que tiene herramientas para calcular intersecciones en 3D. Si quieres usar pgfplots, usa patch plots. Sin embargo, para ello es necesario calcular las intersecciones usted mismo. Este post es para mencionar algunos.Ti experimentalkbiblioteca Zque también permite calcular intersecciones en 3D.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{3dtools}%https://github.com/marmotghost/tikz-3dtools
\begin{document}
\pgfdeclarelayer{background} 
\pgfdeclarelayer{foreground}
\pgfdeclarelayer{behind}  
\pgfsetlayers{behind,background,main,foreground}   
\begin{tikzpicture}[>=stealth,
    3d/install view={theta=70,phi=110},
    line cap=round,line join=round,
    visible/.style={draw,thick,solid},
    hidden/.style={draw,very thin,cheating dash},
    3d/polyhedron/.cd,fore/.style={visible,fill opacity=0.6},
    back/.style={fill opacity=0.6,hidden,3d/polyhedron/complete dashes},
    fore layer=foreground,
    back layer=background
    ]
  \draw [->] (0,0,0) coordinate (O) -- (6,0,0) coordinate (ex) node [below left] {$x$};
  \draw [->] (0,0,0) -- (0,6,0) coordinate (ey) node [right] {$y$};
  \draw [->] (0,0,0) -- (0,0,6) coordinate (ez) node [right] {$z$};
  \path (5,0,0) coordinate (A) (0,5,0) coordinate (B) (0,0,5) coordinate (C)
   (2.5,0,0) coordinate (a) (0,3.5,0) coordinate (b) (0,0,2) coordinate (c) ;
  \path[3d/.cd,plane with normal={(ex) through (a) named px},
      plane with normal={(ey) through (b) named py},
      line through={(A) and (B) named lAB},
      line through={(A) and (C) named lAC},
      line through={(B) and (C) named lBC}];
  \path[3d/intersection of={lAB with px}] coordinate (pABx)
   [3d/intersection of={lAB with py}] coordinate (pABy)
   [3d/intersection of={lAC with px}] coordinate (pACx)
   [3d/intersection of={lBC with py}] coordinate (pBCy);
  \pgfmathsetmacro{\mybarycenterA}{barycenter("(A),(pABx),(pACx),(a)")} 
  \pgfmathsetmacro{\mybarycenterB}{barycenter("(B),(pABy),(pBCy),(b)")} 
  \tikzset{3d/polyhedron/.cd,O={(\mybarycenterA)},color=blue,
      draw face with corners={{(A)},{(pABx)},{(pACx)}},
      draw face with corners={{(A)},{(pABx)},{(a)}},
      draw face with corners={{(A)},{(a)},{(pACx)}},
      O={(\mybarycenterB)},
      draw face with corners={{(B)},{(pABy)},{(pBCy)}},
      draw face with corners={{(B)},{(pABy)},{(b)}},
      draw face with corners={{(B)},{(b)},{(pBCy)}},
      color=orange,O={(1,1,1)},
      draw face with corners={{(pABx)},{(pACx)},{(C)},{(pBCy)},{(pABy)}},
      draw face with corners={{(a)},{(pACx)},{(C)},{(O)}},
      draw face with corners={{(b)},{(pBCy)},{(C)},{(O)}},
      draw face with corners={{(b)},{(pABy)},{(pABx)},{(a)},{(O)}}
      }
\end{tikzpicture}
\end{document}

ingrese la descripción de la imagen aquí

Aún quedan muchos esfuerzos. Sin embargo, hay una ventaja: puedes cambiar la vista y seguir obteniendo el resultado correcto. Por ejemplo, 3d/install view={theta=70,phi=60},obtendrás

ingrese la descripción de la imagen aquí

Por supuesto, esto también es válido para las soluciones asymptotey patch plot(quizás excepto por la posibilidad de que las líneas ocultas se discontinuen automáticamente).

información relacionada