The first TikZ picture shows a rather sloppy idea to draw the parallel lines.
The second example shows a more automatic way of drawing secants (one could have used the \angle
value directly but I want do show how I’d do it, if the direction of the vector is not known to the user.
The second example also shows that calc
’s ($(<p1>)!(<p3>)!(<p2>)$)
isn’t very exact for
close (<p1>)
and (<p2>)
. Of course, there isn’t even a line when <p1> = <p2>
.
The intersections
library might be more precise in finding points where the orthogonal line to the vector and the secants intersect.
Code
\documentclass[tikz,convert=false]{standalone}
\usetikzlibrary{calc,through}
\tikzset{
m*/.style args={#1:#2}{
insert path={node [fill=green!50!black, outer sep=+0pt, shape=circle, inner sep=0pt, minimum size=+4pt,#1,label={#2}] {}}
},
m/.style={insert path={coordinate (#1)}},
parLines/.style={draw=red,,shorten <=+-.5cm,shorten >=-.5cm},
vertLines/.style={draw=purple,shorten >=.5\pgflinewidth},
@splitLine/.code args={#1 -- #2}{\def\tikztotargetA{#1}\def\tikztotargetB{#2}},
vert on/.style={
to path={
[@splitLine/.expanded={\tikztotarget}]
-- ($(\tikztotargetA)!(\tikztostart)!(\tikztotargetB)$) node[right angle node,rotate=90*#1] {}\tikztonodes
}
},
vert on/.default=0,
right angle node/.style={
at end,sloped,above,allow upside down,
anchor=south east,
shape=rectangle,
inner sep=0pt,
minimum size=3pt,
append after command={
\pgfextra\pgfinterruptpath\draw[right angle node path] (\tikzlastnode.south west) -- (\tikzlastnode.north west) -- (\tikzlastnode.north east);\endpgfinterruptpath\endpgfextra
}
},
right angle node path/.style={draw,thin,black,-,shorten >=.4pt},
secant/.style={
to path={
let \p{@dir}=(\tikztotarget), \n{@dir}={atan2(\x{@dir},\y{@dir})} in
(node cs: name=\tikztostart, anchor=#1) [m*={name=m#1}:#1] -- (node cs: name=\tikztostart, anchor={2*(\n{@dir}-90)-#1}) [m=m#1'] \tikztonodes
}
}
}
\begin{document}
\begin{tikzpicture}[thick]
\clip (-2.5,-2.5) rectangle (2.5,2.5);
\draw[thin, ->] (0,0) [m*={black,minimum size=+3pt,name=O}:] -- node [sloped,above,inner sep=+1pt,font=\scriptsize] {$\vec v$} ++(150:1) coordinate (d);
\draw[thin, ->] (0,0) -- ([rotate=90]d) [shorten >=-1.3cm];
\draw[thin, ->] (0,0) -- ([rotate=-90]d) [shorten >=-1.3cm];
\node [draw=blue, circle through={(2,0)}] (c) {};
\draw[parLines] (c.50) [m*={name=m1}:1] -- ++([scale=2] d) [m=m1'];
\draw[parLines] (c.140) [m*={name=m2}:2] -- ++([scale=-4] d) [m=m2'];
\draw[parLines] (c.-30) [m*={name=m3}:3] -- ++([scale=4.5] d) [m=m3'];
\draw[parLines] (c.210) [m*={name=m4}:4] -- ++([scale=-2.5] d) [m=m4'];
\draw[vertLines] (c.center) to[vert on] (m1 -- m1');
\draw[vertLines] (c.center) to[vert on] (m4' -- m4);
\end{tikzpicture}
\foreach \angle in {0,10,...,359}{% Careful, 36 pages!
\begin{tikzpicture}[thick]
\clip (-2.5,-2.5) rectangle (2.5,2.5);
\draw[thin, ->] (0,0) [m*={black,minimum size=+3pt,name=O}:] -- node [sloped,above,inner sep=+1pt,font=\scriptsize] {$\vec v$} ++(\angle:1) coordinate (d);
\draw[thin, ->] (0,0) -- ([rotate=90]d) [shorten >=-1.3cm];
\draw[thin, ->] (0,0) -- ([rotate=-90]d) [shorten >=-1.3cm];
\node [draw=blue, circle through={(2,0)}] (c) {};
\draw[parLines] (c) to[secant=30] (d);
\draw[parLines] (c) to[secant=140] (d);
\draw[parLines] (c) to[secant=-30] (d);
\draw[parLines] (c) to[secant=210] (d);
\draw[vertLines] (c.center) to[vert on] (m30 -- m30');
\draw[vertLines] (c.center) to[vert on] (m210' -- m210);
\end{tikzpicture}%
}
\end{document}
Output
Best Answer
It's a bit fiddly getting the non-linear transformation stuff working in
pgf
but it can more-or-less do what is required along with thespy
library: