将 TikZ 转换为 XAML

将 TikZ 转换为 XAML

我怎样才能将该绘图转换为 XAML?

\documentclass[12pt]{scrartcl}

\usepackage[utf8]{inputenc}  % ö,ä,ü möglich im Text

\usepackage{float} % damit Bilder fließen können
\usepackage{tikz} % Front-End für pgf. (Mit tikz kann man so geile Vektorgrafiken machen)
\usetikzlibrary{calc}
\usepackage{color} % um Farben zu definieren
\usepackage[nomessages]{fp}   %floating point calculations
\usepackage{amsmath}

\begin{document}
    \begin{figure}[H]%
        \centering
        \def\foreshortening{0.5}
        \def\rotationAngle{-15}
        \def\cabinetAngle{45}
        \begin{tikzpicture}[>=latex,
                            x = {({(cos(\rotationAngle)+cos(\cabinetAngle)*sin(\rotationAngle)*\foreshortening)*1cm},{sin(\rotationAngle)*sin(\cabinetAngle)*\foreshortening*1cm})},
                            y = {({(-sin(\rotationAngle)+cos(\cabinetAngle)*cos(\rotationAngle)*\foreshortening)*1cm}, {cos(\rotationAngle)*sin(\cabinetAngle)*\foreshortening*1cm})},
                            z = {(0cm,1cm)},
                            axis/.style={thick,->}]    

            % drawing the axes
            \coordinate (O) at (0, 4, 5);
            \draw[axis] (O) -- +(2, 0, 0) node [above] {$X$};
            \draw[axis] (O) -- +(0, 2, 0) node [above] {$Y$};
            \draw[axis] (O) -- +(0, 0, 2) node [above] {$Z$};

            \def\helplineLengthZ{0.6}
            \def\helplineLengthX{1}
            \def\helplineDistFactor{0.7}

            \def\maxX{10}
            \def\maxY{7.5}
            \def\substHeight{1.5}
            \def\distX{2}
            \def\distY{1.5}
            \def\rodHeight{2.5}
            \def\rodRadius{0.25}

            % drawing the substrate
            \definecolor{substrateColor}{rgb}{0,.6,1}
            \FPeval{\substMinX}{clip(-2*\rodRadius)}
            \FPeval{\substMaxX}{clip(\maxX + 2*\rodRadius)}
            \FPeval{\substMinY}{clip(-2*\rodRadius)}
            \FPeval{\substMaxY}{clip(\maxY + 2*\rodRadius)}

            \node at (0, 0, 0) {\substMinX};

            % vordere Seite
            \draw[black, shading = axis, top color = substrateColor, bottom color = substrateColor!50!white] (\substMinX, \substMinY, 0) -- (\substMaxX, \substMinY, 0) -- (\substMaxX, \substMinY, \substHeight) -- (\substMinX, \substMinY, \substHeight) -- cycle;
            % rechte Seite
            \draw[black, shading = axis, top color = substrateColor, bottom color = substrateColor!50!white] (\substMaxX, \substMinY, 0) -- (\substMaxX, \substMaxY, 0) -- (\substMaxX, \substMaxY, \substHeight) -- (\substMaxX, \substMinY, \substHeight) -- cycle;
            %% hintere Seite
            %\draw[black, shading = axis, top color = substrateColor, bottom color = substrateColor!50!white] (\substMinX, \substMaxY, 0) -- (\substMaxX, \substMaxY, 0) -- (\substMaxX, \substMaxY, \substHeight) -- (\substMinX, \substMaxY, \substHeight) -- cycle;
            %% linke Seite
            %\draw[black, shading = axis, top color = substrateColor, bottom color = substrateColor!50!white] (\substMinX, \substMinY, 0) -- (\substMinX, \substMaxY, 0) -- (\substMinX, \substMaxY, \substHeight) -- (\substMinX, \substMinY, \substHeight) -- cycle;


            % sichtbare Seite des Substrates
            \draw[black, fill = substrateColor] (\substMinX, \substMinY, \substHeight) -- (\substMaxX, \substMinY, \substHeight) -- (\substMaxX, \substMaxY, \substHeight) -- (\substMinX, \substMaxY, \substHeight) -- cycle;

            % drawing the rods
            \def\verkleinerungsFaktor{0.01}
            \foreach \x in {0, \distX, ..., \maxX}
            {
                \foreach \y in {0, \distY, ..., \maxY}
                {   
                    % invert the y (nicht von 0 bis \maxY sonder von \maxY bis 0)
                    \FPeval{\rody}{clip(\maxY - \y)}
                    \node       at (\x, \rody, {0.5*\rodHeight+\substHeight}) [rectangle, rounded corners = {0.5cm*(2*\rodRadius-\verkleinerungsFaktor*\rody)}, thick, inner sep=0pt, minimum width={(2*\rodRadius-\verkleinerungsFaktor*\rody)*1cm}, minimum height={(\rodHeight-\verkleinerungsFaktor*\rody)*1cm}, shade, shading=ball, ball color=orange, draw=black, thin] {};
                }
            }

            % mark distance in x
            \coordinate (topOfRodForDX) at ({3*\distX}, \maxY, {\substHeight+\rodHeight-0.5*\verkleinerungsFaktor*\maxY});
            % help lines
            \draw[thick] (topOfRodForDX) -- ++(0, 0, \helplineLengthZ);
            \draw[thick] ($(topOfRodForDX)+(\distX, 0, 0)$) -- ++(0, 0, \helplineLengthZ);
            % distance line
            \draw[<->] ($(topOfRodForDX)+(0, 0, {\helplineLengthZ*\helplineDistFactor})$) -- ++(\distX, 0, 0) node[midway, above] {$d_x$};

            % mark distance in y
            \coordinate (bottomOfRodForDY) at (\maxX, {3*\distY}, \substHeight+\verkleinerungsFaktor*1.5);
            % help lines
            \draw[thick, line cap = round] (bottomOfRodForDY) -- ++(\helplineLengthX, 0, 0);
            \draw[thick, line cap = round] ($(bottomOfRodForDY)+(0, \distY, 0)$) -- ++(\helplineLengthX, 0, 0);
            % distance line
            \draw[<->] ($(bottomOfRodForDY)+({\helplineLengthX*\helplineDistFactor}, 0, 0)$) -- ++(0, \distY, 0) node[midway, right] {$d_y$};

            % mark the diameter
            \def\helplineDistFactor{0.8}
            \coordinate (middleOfRodForDiameter) at ({2*\distX}, \maxY, {\substHeight+\rodHeight-\rodRadius});
            \FPeval{\negRotAngle}{clip(-\rotationAngle)}
            \FPeval{\minRodRadius}{clip(0.5*(2*\rodRadius-\verkleinerungsFaktor*\maxY))}
            \coordinate (rotationCorrectedWidthInXOfRodForDiameter) at (\negRotAngle:\minRodRadius);
            \coordinate (rotationCorrectedLeftUpperEdgeOfRodForDiameter) at ($(middleOfRodForDiameter)-(rotationCorrectedWidthInXOfRodForDiameter)$);
            \coordinate (rotationCorrectedRightUpperEdgeOfRodForDiameter) at ($(middleOfRodForDiameter)+(rotationCorrectedWidthInXOfRodForDiameter)$);
            \draw[thick, line cap = round] (rotationCorrectedLeftUpperEdgeOfRodForDiameter) -- ++(0, 0, \helplineLengthZ);
            \draw[thick, line cap = round] (rotationCorrectedRightUpperEdgeOfRodForDiameter) -- ++(0, 0, \helplineLengthZ);

            % diameter line
            \draw[<->] ($(rotationCorrectedLeftUpperEdgeOfRodForDiameter)+(0, 0, {\helplineLengthZ*\helplineDistFactor})$) -- 
                       ($(rotationCorrectedRightUpperEdgeOfRodForDiameter)+(0, 0, {\helplineLengthZ*\helplineDistFactor})$) node[midway, above] {$2\cdot r$};    
    \end{tikzpicture}
  \end{figure}
\end{document}

得出以下数字: 平均能量损失

相关内容