Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to shade from the line QV to the edge of the ellipse. How can I do this?

\documentclass[11pt]{article}
\usepackage{amsmath, amssymb, eucal, yfonts, setspace, sectsty, enumitem, amscd, caption, tikz, tikz-qtree, mathtools, inconsolata, pgfplots, tikz-3dplot, pxfonts, xcolor}
\usepackage[margin=0.75in]{geometry}

\usetikzlibrary{arrows,decorations.markings,calc,fadings,decorations.pathreplacing, patterns, decorations.pathmorphing, positioning}
\allsectionsfont{\sffamily\raggedright\underline}
\begin{document}

\begin{center}
\begin{tikzpicture}
\draw (-3.25,0) -- (5,0) node[scale = .8, fill = white] at (-1.625,0) {$a$};
\draw (0,-3.25) -- (0,3.25) node[scale = .8, fill = white] at (0,1.25) {$b$};
\draw[red] (0,0) circle (3cm);
\draw[blue] (0,0) ellipse (3cm and 2.5cm);
\draw (0,0) -- (2.59808,1.5) node[scale = .8, fill = white] at (1.29904,0.75) {$a$};
\filldraw (-3,0) circle (.07cm) node[scale = .8] at (-3.2,-0.25) {$A$};
\filldraw (3,0) circle (.07cm) node[scale = .8] at (3.2,-0.25) {$P$};
\filldraw (0,-2.5) circle (.07cm) node[scale = .8] at (-0.25,-2.7) {$D$};
\filldraw (0,2.5) circle (.07cm) node[scale = .8] at (-0.25,2.7) {$B$};
\filldraw (1.75,0) circle (.07cm) node[scale = .8] at (1.5,-0.25) {$F$};
\filldraw (2.59808,1.5) circle (.07cm) node[scale = .8] at (2.84808,1.75) {$Q$}; 
\filldraw (0,0) circle (.07cm) node[scale = .8] at (-0.25,-0.25) {$O$};
\draw (2.59808,1.5) -- (2.59808,0);
\filldraw (2.59808,0) circle (.07cm) node[scale = .8] at (2.34808,-0.25) {$V$};
\filldraw[inner color = pink!70!, outer color = blue!40!black] (0,0) -- (0.875,0) arc (0:30:0.875cm);
\node[scale = .8, fill = white] at (0.875,0) {$ae$};
\node[scale = .8] at (1,0.28) {$E$};
\end{tikzpicture}
\end{center}
\end{document}
share|improve this question
    
Perhaps this answer to a related question can be useful here. –  JLDiaz Mar 8 '13 at 22:10
    
How can I find the intersection of line VQ with the ellipse? –  dustin Mar 8 '13 at 22:38
    
Welcome to TeX.SE. @Qrrbrbirlbel: Is this perhaps s/w generated code? –  Peter Grill Mar 8 '13 at 23:13
    
@dustin If you find that an answer best solves your problem for you, you can show your appreciation through accepting the answer by clicking on the check mark. This shows that the problem was already solved. –  hpesoj626 Mar 10 '13 at 3:37
add comment

2 Answers

up vote 4 down vote accepted

You only need to clip the ellipse. You can get some coordinate with intersections library if you want.

\documentclass[11pt]{article}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}

\draw[red] (0,0) circle (3cm);
\draw[blue] (0,0) ellipse (3cm and 2.5cm); 
\begin{scope}
    \clip (0,0) ellipse (3cm and 2.5cm); 
    \fill[blue!15] (2.59808,1.5) rectangle (3,0);  
\end{scope}
\draw (2.59808,1.5) -- (2.59808,0);  
\draw (-3.25,0) -- (5,0) node[scale = .8, fill = white] at (-1.625,0) {$a$};
\draw (0,-3.25) -- (0,3.25) node[scale = .8, fill = white] at (0,1.25) {$b$};   

\filldraw (3,0) circle (.07cm) node[scale = .8] at (3.2,-0.25) {$P$};
\filldraw (2.59808,1.5) circle (.07cm) node[scale = .8] at (2.84808,1.75) {$Q$}; 
\filldraw (2.59808,0) circle (.07cm) node[scale = .8] at (2.34808,-0.25) {$V$};

\end{tikzpicture}    
\end{document}

enter image description here

share|improve this answer
    
Very simple and intuitive solution. +1 –  hpesoj626 Mar 10 '13 at 3:34
add comment

You can use the intersections library to find the coordinate where the ellipse and the line from V to Q intersect.

  1. Name the paths you want to intersect:

    \draw[name path=ellipse, blue] (0,0) ellipse (3cm and 2.5cm);
    \draw[name path=line VQ] (2.59808,1.5) -- (2.59808,0);
    
  2. Use the name intersections key to find the intersection. (It will be available as (Q'-1), in case of more than one intersection, TikZ append -<number of intersection> at the name.)

    name intersections={of=line VQ and ellipse, name=Q'}
    
  3. Calculate the angle of that point with the calc library. (As the center of the ellipse is (0,0) we get directly the angle from the center.)

    let \p{Q'} = (Q'-1),
        \n{Q'} = {atan2(\x{Q'}/3cm,\y{Q'}/2.5cm)}
    in
    

    In the following path you can use \n{Q'} for the angle of the intersection point.

  4. Draw/fill/pattern/… the path between V, P and the intersection Q'.

    (2.59808,0) -- (3cm,0cm)                                                 % from V to P
    arc[x radius = 3cm, y radius = 2.5cm, start angle = 0, end angle=\n{Q'}] % from P to Q'
    -- cycle;                                                                % back to V
    

Code

Or in one entire path:

% Preamble:
\usetikzlibrary{intersections}

% TikZ picture:
\draw[name path=ellipse, blue] (0,0) ellipse (3cm and 2.5cm);
\draw[name path=line VQ] (2.59808,1.5) -- (2.59808,0);

\path[name intersections={of=line VQ and ellipse, name=Q'}]
    let \p{Q'} = (Q'-1),
        \n{Q'} = {atan2(\x{Q'}/3cm,\y{Q'}/2.5cm)}
    in [
        draw=green,
        fill=green!50
    ] (2.59808,0) -- (3cm,0cm)
      arc[x radius = 3cm, y radius = 2.5cm, start angle = 0, end angle=\n{Q'}]
      -- cycle;

Output

enter image description here

Use named coordinates and not hard-coded numbers, and let TikZ/TeX do the calculations for you.

Take a look at the following code. I have used named coordinates that get labeled semi-automatically. These named coordinates are used throughout the whole TikZ picture.

Hopefully, the comments in the code are helpful enough.

Code

\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.markings,calc,fadings,intersections}
\tikzset{
    mark at/.style args={#1 with #2}{
        decoration={
            markings,
            mark connection node=n#2,
            mark=at position #1 with {\node[font=\footnotesize\strut] (n#2) {$#2$};}
        },
        decorate
    }
}

\newcommand*{\myXradius}{3cm}
\newcommand*{\myYradius}{2.5cm}
\newcommand*{\myOverlap}{0.25cm}
\begin{document}
\begin{tikzpicture}[every node/.append style={font=\small}]
% Step 1: Place coordinates and label them.
\foreach \p/\x/\y/\pos in {%
    O/          0/          0/below left,
    A/-\myXradius/          0/below left,
    B/          0/ \myYradius/above left,
    D/          0/-\myYradius/below left,
    P/ \myXradius/          0/below right%
}   \coordinate[label={[name=n\p]\pos:$\p$}] (\p) at (\x,\y);

% Step 1': Place special coordinates and label them (same syntax as before)
\coordinate                      [label={[name=nQ]above right:$Q$}] (Q) at (30:\myXradius);
\path let \p{Q}=(Q) in coordinate[label={[name=nV]below      :$V$}] (V) at (\x{Q},0); % V is Q projected on the x axis

% Step 2: Draw the lines
\draw[mark at=1.625cm with a] (O) -- (180:\myXradius + \myOverlap);
\draw[mark at=1.625cm with b] (O) -- (  0:\myXradius + \myOverlap);
\draw                         (90:\myXradius + \myOverlap) -- (270:\myXradius + \myOverlap);
\draw[mark at=.5 with a]      (O) -- (Q);
\draw[name path=line VQ]      (V) -- (Q);

% Step 3: Draw the ellipses
\draw[                    red] (O) circle  [  radius = \myXradius                       ];
\draw[name path=ellipse, blue] (O) ellipse [x radius = \myXradius, y radius = \myYradius];

% Step 4: Find the intersection of the ellipse and the line between V and Q ...
\path[name intersections={of=line VQ and ellipse, name=Q'}]
    let \p{Q'} = (Q'-1),
        \n{Q'} = {atan2(\x{Q'}/\myXradius,\y{Q'}/\myYradius)}
    in [
        draw=green,
        fill=green!50
    ]
% ... and draw/fill it ...
    (V) -- (P)
    arc[x radius = \myXradius, y radius = \myYradius, start angle = 0, end angle=\n{Q'}]
    -- cycle
% ... and define a special name to it, as (Q'-1) will be lost after the path.
    coordinate (Q') at (Q'-1);

% Step 5: Draw little circles where the coordinates are.
\foreach \p in {O,A,B,D,P,Q,V,Q'} \fill (\p) circle [radius=1.5pt];

% Step X: I have not changes this.
\filldraw[inner color = pink!70!, outer color = blue!40!black] (0,0) -- (0.875,0) arc (0:30:0.875cm);
\node[scale = .8, fill = white] at (0.875,0) {$ae$};
\node[scale = .8] at (1,0.28) {$E$};
\end{tikzpicture}
\end{document}

Output

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.