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.

What I want:

Path to nodes with intersections

where the yellow line is the path to be transformed. The points inside the yelow line are the nodes after processing.

The only way I found to do this is the intersection between a path and itself. But it is an expensive solution in terms of processing and time. The code to generate the above image is here:

\documentclass[tikz]{standalone}

\usetikzlibrary{intersections}

\begin{document}
    \begin{tikzpicture} 

        \clip (-2.1, -1.1) rectangle (2.1, 1.1);
        \draw [yellow, ultra thick, name path = curve 1] (-2,-1) .. controls (8,-1) and (-8,1) .. (2,1);

        \path [name intersections = {%
            of = curve 1 and curve 1
            , name = i
            , total=\t
            , sort by = curve 1
        }] node {\xdef\totalone{\t}};

        \foreach \k in {1, ..., \totalone}
        {
            \node [
                circle
                , fill
                , inner sep = 0.25pt
                , minimum size = 0pt
            ] at (i-\k) {};
        }

    \end{tikzpicture}
\end{document}

Someone suggests another way of doing this?

share|improve this question
    
If you just want a black line through those nodes you can do: \draw [dotteddecoration = black, yellow, ultra thick][postaction={draw,black,thin}] (-2,-1) .. controls (8,-1) and (-8,1) .. (2,1); I am not quite sure, I know what your “big” goal is. –  Qrrbrbirlbel Oct 5 '12 at 6:42
    
My goal is to find optimized ways to create addressable points along paths. I really liked your proposal! I wonder if there are other ways to do this. –  tecepe Oct 5 '12 at 6:49
    
Given the four control points you can express the Bezier curve as a parameterized curve. Then for each value of the parameter you can plot a point on the curve. I don't know exactly how to do it with TikZ but it must be doable :) –  Dror Oct 5 '12 at 7:10

1 Answer 1

up vote 5 down vote accepted

You might want to check out the decorations.markins library.
(Adjust the step between dots (.5mm) and the radius of the dots (.25pt) as you wish.

Update

With this update you have the nodes (node0) to (node203), \themynodes gives you 204.
(It can start from 1 and end with 204, if you put \stepcounter{mynodes} before the \node command.)

Code

\documentclass[tikz]{standalone}

\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\newcounter{mynodes}

\tikzset{dotteddecoration/.style={
    postaction={
        decorate,
        decoration={
            markings,
            mark=between positions 0 and 1 step .5mm with {
                \node[text=black,font=\fontsize{5}{5}\selectfont] (node\themynodes) at (0,0) {\themynodes};\stepcounter{mynodes}}
}}}}
\begin{document}
    \begin{tikzpicture}[]
        \clip (-2.1, -1.1) rectangle (2.1, 1.1);
        \draw [dotteddecoration, yellow, ultra thick] (-2,-1) .. controls (8,-1) and (-8,1) .. (2,1);
    \end{tikzpicture}
\end{document}

Output

Output: Update

Old solution

Code

\documentclass[tikz]{standalone}

\usetikzlibrary{decorations.markings}

\tikzset{dotteddecoration/.style={
    postaction={
        decorate,
        decoration={
            markings,
            mark=between positions 0 and 1 step .5mm with {
                \fill[#1] (0,0) circle (.25pt);}}}}}
\begin{document}
    \begin{tikzpicture}[]
        \clip (-2.1, -1.1) rectangle (2.1, 1.1);
        \draw [dotteddecoration=black, yellow, ultra thick] (-2,-1) .. controls (8,-1) and (-8,1) .. (2,1);
    \end{tikzpicture}
\end{document}

Output

Output

share|improve this answer
1  
I thought the OP wanted to get a list of nodes that correspond to points on the path -- perhaps I misunderstood. –  Peter Grill Oct 5 '12 at 5:45
    
It's a much more optimized way of doing what I was trying to do. I'll edit my question with an adapted version of this response and wait a bit to see if someone has another good suggestion. Thanks @Qrrbrbirlbel. –  tecepe Oct 5 '12 at 6:06
1  
@PeterGrill He can still do … I'll update the answer. –  Qrrbrbirlbel Oct 5 '12 at 6:13
1  
@tecepe Instead of a counter, you could also use \pgfkeysvalueof{/pgf/decoration/mark info/sequence number} which is incremented for every node. –  Qrrbrbirlbel Jun 29 '13 at 14:28
    
thanks, Qrrbrbirlbel! Very good point. –  tecepe Jul 22 '13 at 23:13

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.