I'm trying to write a \newcommand to draw a little stick-man in PGF. It isn't finished yet, but right now, it looks like this:
\newcommand{\man}[1] {
% #1 : The position of the head of the stick man
\coordinate (X) at (#1);
\coordinate (Y) at ($(#1)+(0,1mm)$);
\draw [black,fill=green,thin] ($(#1)+(290:2mm)$) arc (-70:240:2mm)--++(-3mm,0)--++(0,-1mm)
--++(3mm,0)--++(0,-3mm)--++(225:3mm)--++(315:1mm)coordinate(A)--++(45:1mm)coordinate(B)--
(intersection of A--B and X--Y)--
(#1)--cycle;
}
The function input #1 is the center of his head. The path starts off on the right side of his head, draws an arc (his head) to the left side, then traces his left arm, and the left side of his body. When it comes to his leg, I switch to using polar coordinates, because I want his leg to extend out at 45 degrees. The question arises on the way back from drawing his left leg. I want his crotch (for lack of a better word) to be directly below the center of his head. So I'm trying to find a way to define the point that lies on the intersection of the vertical line through (#1) and the line at 45 degrees through (A).
Right now I have to define coordinates (X) and (Y) ahead of time, which define the vertical line through the center of his head. and I have to define (A) and (B) on the path to define the line at 45 degrees along his leg. I can then use (intersection of A--B and X--Y). My question is, can I do this more elegantly without needing to define these extraneous coordinates (X), (Y) and (B)?
I tried things like
(intersection of A--$A+(45:1mm)$ and X--$X+(0,1mm)$)
but that didn't work.
As per Peter's comment, here is a minimum working example:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand{\man}[1] {
% #1 : The position of the head of the stick man
\coordinate (X) at (#1);
\coordinate (Y) at ($(#1)+(0,1mm)$);
\draw [black,fill=green,thin] ($(#1)+(290:2mm)$) arc (-70:240:2mm)--++(-3mm,0)--++(0,-1mm)
--++(3mm,0)--++(0,-3mm)--++(225:3mm)--++(315:1mm)coordinate(A)--++(45:1mm)coordinate(B)--
(intersection of A--B and X--Y)--
(#1)--cycle;
}
\begin{document}
\tikz{\man{3,3}}
\end{document}
\documentclass
and the appropriate packages so that those trying to help don't have to recreate it. – Peter Grill Jun 28 '13 at 6:51(intersection of A--[shift={(45:1mm)}]A and X--[shift={(0,1mm)}]X)
. Your originalcalc
supported way, works too, if you a) encloseA
andX
in parentheses and the whole in braces:(intersection of A--{$(A)+(45:1mm)$} and X--{$(X)+(0,1mm)$})
– Qrrbrbirlbel Jun 28 '13 at 7:23