# TikZ Coordinate calculation - calculate coordinates separately

I'm trying to calculate coordinates based on existing coordinates but each coordinate individually.

The first thing which is unclear to me is how to define scalar variables. I can define coordinates using the \coordinate command, but what about scalars?

Looking through the manual I found the \pgfextractx command, but I don't know how to use it, is it possible to use it within a coordinate calculation like for example

\coordinate(blah) at ($(\pgfextractx{(centre)} + 2*cos(30), .. )$)


?

• What do you mean exactly with "calculate coordinates based on existing coordinates but each coordinate individually"? I have the feeling you use "coordinate" for both \coordinate and the X and Y part of it, which makes the question quite difficult to read. May 2, 2011 at 9:52
• Agree this was somewhat confusing, I just want to access the x and y part of it separately instead of, let's say just multiply the coordinate vector with a scalar.
– Nils
May 2, 2011 at 11:30
• You could define scalars with \newcommand. May 2, 2011 at 14:57

It is possible to do by means of let operation:

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}

• It's a bad idea to use \pgfmathresult inside a coordinate. This macro is overwritten by any pgfmath operation. It is much saver to use \pgfmathsetmacro\myresult{...} instead of \pgfmathparse{...} and then \myresult pt as X-coordinate. Note that \pgfmathresult is in pt but without the unit, so just using it alone will give you wrong results except when x=1pt is in affect. May 2, 2011 at 11:37
• @Dmitry: One can simply write ({\x1 + 2 * cos(30)}, \y1). (Note the additional braces and that \x1 already contains the unit pt.) May 2, 2011 at 14:48