tikz에서 비틀림 프리즘 빔을 그리는 방법은 무엇입니까?

tikz에서 비틀림 프리즘 빔을 그리는 방법은 무엇입니까?

저는 Tikz를 처음 접했지만 다음 개체를 그리고 싶습니다. 여기에 이미지 설명을 입력하세요

누구든지 좋은 조언이나 도움을 줄 수 있습니까?

답변1

단면이 강체처럼 동작한다는 가정을 사용하면 다음과 같습니다.

\documentclass{article}
\usepackage{pgfplots}

\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}[
    declare function={squarex(\t) =
        (\t < 0.25) ? 1 : (
            (\t < 0.5) ? (1 - (\t-0.25) * 8) : (
                (\t < 0.75) ? -1 : (-1 + (\t - 0.75) * 8)
        )
    ;},
    declare function={squarey(\t) =
        (\t < 0.25) ? (-1 + \t*8) : (
            (\t < 0.5) ? 1 : (
                (\t < 0.75) ? (1 - (\t - 0.5) * 8) : -1
        )
    ;}
]
\begin{axis}[
    axis equal image, 
    z buffer=sort,
    hide axis, 
    domain=0:1, y domain = 0:10, samples y = 25,
    ylabel =y, xlabel=x,
    clip=false
]

\addplot3 [
    z buffer=none, domain=0:330, samples y=1,
    ultra thick, black, -latex] (
    -0.5,
    {sin(x)*1.5},
    {cos(x)*1.5}
);

\addplot3 [surf, shader=flat, fill=yellow!50, draw=black] (
    y,
    {squarex(x) * cos(y*9) - squarey(x) * sin(y*9)},
    {squarex(x) * sin(y*9) + squarey(x) * cos(y*9)}
);

\addplot3 [z buffer=auto, fill=yellow!50, draw=black] table {
x y z
10 -1 -1
10 1 -1
10 1 1
10 -1 1
10 -1 -1
};

\addplot3 [
    z buffer=auto, domain=-60:270, samples y=1,
    ultra thick, black, latex-] (
    10.5,
    {sin(x)*1.5},
    {cos(x)*1.5}
);
\end{axis}
\end{tikzpicture}
\end{document}

관련 정보