.NET에서 3D RGB 큐브를 그려야 합니다 asymptote
.
그 예를 찾을 수 있나요? 여기에서 몇 가지 예를 봤습니다.http://www.piprime.fr/files/asymptote/odoc/index.html, 하지만 RGB 큐브를 그리는 방법을 상상할 수 없습니다. (아래 사진은 예시입니다. PDF 파일로 변환할 수 있는 3D 모델이 필요합니다.)
답변1
점근선 접근법
세 개의 얼굴을 그렸습니다. 남은 일도 잘 마무리하시길 바랍니다.
import three;
int n=5;
int L=5;
for (int i=0;i<=n;++i){
for (int j=0;j<=n;++j){
pen p=rgb(i/n,j/n,0);
path3 q=scale3(L/n)*shift(i,j,0)*plane((1,0,0),(0,1,0),(0,0,0));
draw(surface(q),p,nolight);
}
}
for (int i=0;i<=n;++i){
for (int j=0;j<=n;++j){
pen p=rgb(i/n,0,j/n);
path3 q=scale3(L/n)*shift(i,0,j)*plane((1,0,0),(0,0,1),(0,0,0));
draw(surface(q),p,nolight);
}
}
for (int i=0;i<=n;++i){
for (int j=0;j<=n;++j){
pen p=rgb(0,i/n,j/n);
path3 q=scale3(L/n)*shift(0,i,j)*plane((0,1,0),(0,0,1),(0,0,0));
draw(surface(q),p,nolight);
}
}
pgfplot 접근 방식
솔직히 Asymptote가 이것을 할 수 있는지는 모르겠습니다. 하지만 확실히 다음을 사용하면 가능합니다.pgfplots패치.
\documentclass[border=9,tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\definecolor{000}{rgb}{0,0,0}
\definecolor{001}{rgb}{0,0,1}
\definecolor{010}{rgb}{0,1,0}
\definecolor{011}{rgb}{0,1,1}
\definecolor{100}{rgb}{1,0,0}
\definecolor{101}{rgb}{1,0,1}
\definecolor{110}{rgb}{1,1,0}
\definecolor{111}{rgb}{1,1,1}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis equal]
\addplot3[surf,shader=interp,patch,patch type=rectangle,mesh/color input=explicit]
coordinates{
(0,-.01,1)[color=001](1,-.01,1)[color=101]
(1,-.01,0)[color=100](0,-.01,0)[color=000]
(1.01,0,1)[color=101](1.01,1,1)[color=111]
(1.01,1,0)[color=110](1.01,0,0)[color=100]
(0,1,1.01)[color=011](1,1,1.01)[color=111]
(1,0,1.01)[color=101](0,0,1.01)[color=001]
}
;
\end{axis}
\end{tikzpicture}
\end{document}
답변2
내 또 다른 솔루션
import three;
size(500);
draw(surface((0,0,0)--(0,1,0)--(1,1,0)--(1,0,0)--cycle, new pen[] {black,blue,cyan,green}));
draw(surface((1,1,0)--(0,1,0)--(0,1,1)--(1,1,1)--cycle, new pen[] {cyan,blue,magenta,white}));
draw(surface((0,0,1)--(0,1,1)--(0,1,0)--(0,0,0)--cycle, new pen[] {red,magenta,blue,black}));
draw(surface((0,0,1)--(0,1,1)--(1,1,1)--(1,0,1)--cycle, new pen[] {red,magenta,white,yellow}));
draw(surface((1,0,1)--(0,0,1)--(0,0,0)--(1,0,0)--cycle, new pen[] {yellow,red,black,green}));
draw(surface((1,0,1)--(1,1,1)--(1,1,0)--(1,0,0)--cycle, new pen[] {yellow,white,cyan,green}));