三角网格的“冗余”坐标系

三角网格的“冗余”坐标系

如何在 tikz 中使用 (r,g,b)(或图中的 (c,b,a))“冗余”坐标系设置网格,然后绘制由给定颜色的 2 个坐标指定的单个三角形?
例如,如何在图中设置网格,然后以橙色绘制三角形 [r= +2​​, b= -1],或以紫色绘制三角形 [r= +2​​, g= -2]?
三角网格的“冗余”坐标

答案1

你可以像这样使用某物:

在此处输入图片描述

€dit:三角形。

%\documentclass[]{article}
\documentclass[margin=5pt, tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
\pgfmathsetmacro\xMax{8}
\pgfmathsetmacro\yMax{7}

\pgfmathsetmacro\s{2*sqrt(3)/3}
\begin{tikzpicture}[font=\footnotesize,
x={(1,0)}, y={(60:1)}, 
>=latex, 
Point/.style={draw=red, fill=white},
shape triangle/.style = {draw, thick, regular polygon, regular polygon sides=3, minimum height=\s cm, % anchor=center, 
inner sep=0pt, 
},
triangle/.style={shape triangle, shift={(0.5,0.25*\s cm)}},
triangle*/.style={shape triangle, shape border rotate=180, , shift={(0.5,-0.25*\s cm)}},
]
% Contents
\fill[purple] (0,3) -- (0,4) -- (4,0) -- (3,0) --cycle;

\node[triangle*, fill=green] at (4,4)  {$\downarrow$};
\node[triangle, fill=green!77!red] at (4,4)  {$\uparrow$};

\node[triangle, fill=red] at (2,5)  {a};
\node[triangle, fill=cyan] at (2,3)  {};
\node[triangle*, fill=yellow] at (0,7)  {};

% CoSy
\begin{scope}[very thin]
\clip[] (0,0) -- (\xMax,0) -- (\xMax cm+\pgflinewidth, \yMax) -- (\pgflinewidth,\yMax)  --cycle; 

% Contents - cliped
\fill[blue!33, opacity=0.7] (0,1) rectangle (\xMax,2);

\fill[purple!33, opacity=0.7] (6,0) -- (7,0)--(7,8)--(6,8)--cycle;

\foreach \y in {0,...,\yMax}{
\tikzset{  temp/.style={fill=pink, draw=none,opacity=0.1}   }
\node[triangle*, temp] at (6,\y)  {};
\node[triangle, temp] at (6,\y)  {};
}

% CoSy 1/2 - "grid"
\foreach \x in {0,...,\xMax}{
\draw[] (\x,0) -- (\x,\yMax); 
}
%
\pgfmathsetmacro\yMAX{2*\yMax}
\foreach \y in {0,...,\yMAX}{
\draw[] (0,\y) -- (\xMax,\y); 
\draw[] (0,\y) -- (\y,0); 
}
\end{scope}
% CoSy 2/2 - "axes"
\draw[thick,->] (0,0) -- (\xMax+0.5,0) node[below]{$x$};
\draw[thick,->] (0,0) -- (0,\yMax+0.5) node[left]{$y$};
\foreach \x in {0,...,\xMax}{
\draw[] (\x,2pt) -- (\x,-2pt) node[below] {\x}; 
}
\foreach \y in {0,...,\yMax}{
\draw[] (2pt,\y) -- (-2pt,\y) node[left] {\if\y 0 \else \y\fi}; 
}

% Contents - Points
\draw[Point, draw=green] (4,4) circle(2pt);

\draw[Point] (0,1) circle(2pt);
\draw[Point] (3,3.5) circle(2pt);
\draw[Point] (4,6) circle(2pt);
\end{tikzpicture}
\end{document}

相关内容