pgf-tikz / pgf

A Portable Graphic Format for TeX
https://pgf-tikz.github.io/
1.14k stars 108 forks source link

Adding a simple way to do axial symmetry (or mirror or reflection) of a path #1015

Open quark67 opened 3 years ago

quark67 commented 3 years ago

Brief outline of the proposed feature

It seems that to do an axial symmetry with Tikz, it is pain (unless the axe of symmetry is the x-axis our the y-axis). Here are code I found to do this: https://tex.stackexchange.com/questions/119914/can-we-mirror-a-part-in-tikz

It's a very complicated code with use of low internal commands (tikz@scan@one@point, \pgfextract@process etc.): https://tex.stackexchange.com/a/142491/132405

Usage example

The syntax used in the code gave in the previous link seems user friendly (with (@1) and (@2) the points which define the axe of the symmetry):

\begin{scope}[mirror=(@1)--(@2)]
  \draw[thick, blue] (1,1) -- (0,0) -- (1,2);
  \path[transform shape] (@1) -- node[above,sloped] {Mirror} (@2);
\end{scope}

Or have I forget a package for Tikz which provide this?

ilayn commented 3 years ago

Search for spath3 from Andrew Stacey. Save the path and reuse it with flipped scales. Note that you can always mirror on x- or y-axis and rotate the scope the paths are in.

quark67 commented 3 years ago

What is then the code for mirror an object relative to the line between the points A(2,1) and B(5,3)? What combination of x-axis mirror, y-axis mirror and rotation with what angle must I use?

I don't have find the relation beetween axis symmetry relative to an arbitrary line, and the spath3 package. Where is the documentation ? I only found a pdf about Calligraphy (?) and knots (???). Where are the scolar symmetry?

ilayn commented 3 years ago

You save the path. You open another scope. You set xscale=-1 you reuse the path. That gives the exact result you provided above.

Now you tell me how to mirror without a pain with respect to arbitrary axis. Where is the specification? What is your use case? Why can't you do it yourself? What else offers this? Did you even search online the usage of spath? There are like 100 cases in Tex.SX

As you can see our tone on a back and forth matters a lot. So it is quite mirrored if you excuse the pun.

quark67 commented 3 years ago

You use rude words :(.