0

This code draws a certain plot:

\documentclass{minimal}                                                                                                                                                                                     
\usepackage{tikz}                                                                                                                                                                                           
\usepackage{amsmath}                                                                                                                                                                                        
\begin{document}                                                                                                                                                                                            
\begin{tikzpicture}[x=2cm/2]                                                                                                                                                                                
  \newcommand\phiprim{60}                                                                                                                                                                                   
  \newcommand\x0{0.5}                                                                                                                                                                                       
  \newcommand\y0{0.5}                                                                                                                                                                                       
  \pgfplothandlerlineto                                                                                                                                                                                     
  \pgfplotfunction{\r}{0, 0.01, ..., 1}
{\pgfpointxy{\r*(cos(\phiprim)*\x0 + sin(\phiprim)*\y0)}
{\r*(-sin(\phiprim)*\x0 + cos(\phiprim)*\y0}}   %this line could be redefined with matrix multiplication 
  \pgfusepath{stroke}                                                                                                                                                                                       
\end{tikzpicture}                                                                                                                                                                                           
\end{document}

I could make my code nicer if I could define in tikz matrices

enter image description here

and perform operations with them

enter image description here

How matrices can be defined and how can one perform matrix operations in tikz. Here I am interested in matrices only as mathematical objects with no intention to display them.

Viesturs
  • 7,895
  • Some ways of creating matrices are listed in Where is the \matrix command?. Or Tikzpicture and matrix – Bobyandbob Nov 03 '17 at 19:17
  • If a matrix is big enough to NEED matrix operations, you really don't want to use pgfmath! – John Kormylo Nov 03 '17 at 19:27
  • 1
    Related, though not the same: https://tex.stackexchange.com/questions/112599/ https://tex.stackexchange.com/questions/73543 There is some support for array-like structures, see section 89.3 in the manual, but I don't think anything like what you're asking for is built in. – Torbjørn T. Nov 03 '17 at 20:08
  • In a case where complicated mathematical expressions are needed to draw a plot, what would one use? – Viesturs Nov 03 '17 at 20:54
  • 1
    I am not sure --- are you looking for using a generic transformation matrix on the tikz coordinates? There is a \pgftransformcm{a}{b}{c}{d }{point} that do that. See the tikz manual, pag. 1047 in my copy, section 102.2.2 "commands for relative coordinates transformation": – Rmano Nov 03 '17 at 21:13
  • Hmmm... \def\x0{0.5} doesn't do what you suspect. \y0 is not a valid TeX macro name. – Rmano Nov 03 '17 at 21:19
  • @JohnKormylo TikZ maybe (in a path), but TeX no... in the OP snippet, \x and \y ar both 0, and \x0 is the string 00. Try to put this into the tikzpicture: \newcommand\x0{0.5}\newcommand\y0{0.5} \node {\x0,\y0}; (To be exact, in the path let operation, where \x is a kind-of a command that takes an argument...) – Rmano Nov 04 '17 at 10:51

0 Answers0