삼각형 그리드의 "중복" 좌표계

삼각형 그리드의 "중복" 좌표계

그림의 (r,g,b) 또는 (c,b,a) "중복" 좌표계를 사용하여 tikz에서 그리드를 설정하고 2개의 좌표로 지정된 단일 삼각형을 그리는 방법 특정 색상으로?
예를 들어 그림에서 그리드를 설정한 다음 삼각형 [r= +2, b= -1]을 주황색으로 그리거나 삼각형 [r= +2, g= -2]를 보라색으로 그리는 방법은 무엇입니까?
삼각형 그리드의 "중복" 좌표

답변1

sth를 사용할 수 있습니다. 이와 같이:

여기에 이미지 설명을 입력하세요

€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}

관련 정보