2010-05-10 4 views
3

큰 원의 아이디어를 설명하기 위해 PGF/TikZ의 구를 표시하려고합니다.PGF/TikZ의 타원이있는 교차점을 찾는 방법

내 현재의 결과에 대한 코드는 다음과 같습니다

\begin{tikzpicture} 

\tikzfading[name=fade right, 
left color=transparent!20, 
right color=transparent!90] 

\tikzfading[name=fade out, 
inner color=transparent!100, 
outer color=transparent!10] 

\tikzfading[name=fade right gc, 
left color=transparent!0, 
right color=transparent!70] 

\draw [<->, dashed] (0,-5) -- (0,5); % y-axis 
\draw [->, dashed] (0, 0) -- (20:5); % x-axis 
\draw [->, dashed] (0, 0) -- (200:5); % x-axis 
\draw [->, dashed] (0, 0) -- (340:5); % z-axis 
\draw [->, dashed] (0, 0) -- (160:5); % z-axis 

\fill [color=cyan, opacity=0.15, path fading=fade out] (0,0) circle (4cm); % bounding circle 
\fill [color=cyan, opacity=0.25, path fading=fade right, fading angle=90] (0,0) ellipse (4cm and 1cm); % x-y-axis area 

% great circle 1 
\draw [rotate=-40, color=red, path fading=fade right gc, fading angle=40] (0,0) ellipse (4cm and 1cm); 

% great circle 2 
\draw[rotate=5, color=red, path fading=fade right gc, fading angle=5] (0,0) ellipse (1.5cm and 4cm); 

\end{tikzpicture} 

내가

  1. 두 개의 빨간색 타원의 교점의 두 점을 어떻게 찾을 수 있습니까 (대원 1로 주석 2),
  2. (중심 (0,0)에서 시작하는) 선과 타원의 교차점을 찾고
  3. 작은 원형 또는 직사각형을 배치 하시겠습니까?

작은 원이나 사각형을 배치해도 문제가 없습니다. 대단히 감사합니다!

답변

1

섹션 4.1.4를 확인하십시오. TikZ and PGF manual의 "The Circles of The Circles"라는 제목으로 intersections 라이브러리를 사용해야하는데 \path [name intersections={of=path 1 and path 2}] ;과 같이 name intersections 키를 사용할 수 있습니다. 이것을 사용하려면 \draw [name path = y axis, <->, dashed] (0,-5) -- (0,5) ; % y-axis에서와 같이 name path 키를 사용해야합니다. 교차로에 액세스하는 것은 버전마다 다를 수 있습니다. 이 매뉴얼의 나의 로컬 카피는 내가 링크 한 것과는 다른 지시 사항을 가지고있다.

\begin{tikzpicture} 
    \tikzfading[ name  = fade right 
      , left color = transparent!20 
      , right color = transparent!90 ] 

    \tikzfading[name   = fade out 
      , inner color = transparent!100 
      , outer color = transparent!10 ] 

    \tikzfading[name   = fade right gc 
      , left color = transparent!0 
      , right color = transparent!70] 

    \draw [name path = y axis, <->, dashed] (0,-5) -- (0,5) ; % y-axis 
    \draw [name path = x- axis, ->, dashed] (0, 0) -- (20:5) ; % x-axis 
    \draw [name path = x+ axis, ->, dashed] (0, 0) -- (200:5) ; % x-axis 
    \draw [name path = z+ axis, ->, dashed] (0, 0) -- (340:5) ; % z-axis 
    \draw [name path = z- axis, ->, dashed] (0, 0) -- (160:5) ; % z-axis 

    % bounding circle 
    \fill [color=cyan, opacity=0.15, path fading=fade out] 
     (0,0) circle (4cm) ; 

    % x-y-axis area 
    \fill [color=cyan, opacity=0.25, path fading=fade right, fading angle=90] 
     (0,0) ellipse (4cm and 1cm); 

    % great circle 1 
    \draw [ name path = great circle 1 
     , rotate  = -40 
     , color  = red 
     , path fading = fade right gc 
     , fading angle = 40] 
     (0,0) ellipse (4cm and 1cm); 

    % great circle 2 
    \draw [ name path = great circle 2 
     , rotate  = 5 
     , color  = red 
     , path fading = fade right gc 
     , fading angle = 5] 
     (0,0) ellipse (1.5cm and 4cm); 

    % Intersections 
    \path [name intersections={of=great circle 1 and great circle 2}] ; 
    \foreach \i in {1,...,4} 
    \fill [color=red] (intersection-\i) circle (2pt) ; 

    \path [name intersections={of=y axis and great circle 1}] ; 
    \fill (intersection-1) circle (2pt) ; 
    \fill (intersection-2) circle (2pt) ; 
    \path [name intersections={of=y axis and great circle 2}] ; 
    \fill (intersection-1) circle (2pt) ; 
    \fill (intersection-2) circle (2pt) ; 

    \foreach \a in {x,z} { 
    \foreach \ss in {+,-} { 
     \def\s.{\ss} % Otherwise the space in `\a\s axis` would get gobbled. 
     \path [name intersections={of=\a\s. axis and great circle 1}] ; 
     \fill (intersection-1) circle (2pt) ; 
     \path [name intersections={of=\a\s. axis and great circle 2}] ; 
     \fill (intersection-1) circle (2pt) ; 
    } 
    } 
\end{tikzpicture} 

그러나, 적어도 내 버전에, 당신은 다음 예제에서 각 교차점에 원을 얻으려면 등 (intersection-1), (intersection-2)와 교차로에 접근 한 후, 나는 다음과 같이 당신의 코드를 변경할 것 다시 포맷팅 (가로 스크롤 막대를 피하기 위해) 이외에 기존 코드를 변경하면 축과 큰 원에 name path 키를 추가하는 것입니다. 나는 상대적으로 자명하다 교차로 코드를 추가했다. 먼저 \usetikzlibrary{intersections}을 기억하면 모든 것이 잘 작동합니다.

+1

자세한 답변을 보내 주셔서 감사합니다. 내가 이해하는 한 CVS의 최신 개발자 버전이 있어야합니다. 왜냐하면 교차로는 "일반"pgf-2.00.tar.gz에 포함되어 있지 않기 때문입니다. 설치 과정에서 몇 가지 문제가 발생하기 때문에 곧 작동 할 것입니다. – user327684

+0

이것은 (두 번째 게시물 = 첫 번째 답장) http://www.latex-community.org/forum/viewtopic.php?f=45&t=5687 다른 많은 MikTex를 실행하는 데 유용 할 수 있습니다. – user327684

+0

완벽하게 작동합니다! 정말 고마워! – user327684