Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is it possible to get the x or y coordinate of a Point with tkz? Especially if I have two points A=(a_1,a_2) and B=(b_1,b_2) I want to have a Point C=(a_1,b_2).

This is related to Extract the x/y part from a coordinate in pgfplots. The difference is that I am asking for a way to to it in tkz.

share|improve this question
2  
TkZ points are just coordinate nodes. So you can use exactly the same solution. –  Caramdir May 24 '11 at 18:31
    
Thanks, but I don't get it, how to apply this exactly to my example above? –  student May 24 '11 at 18:52
1  
Side remark: Direct coordinate calculations seem to be against the spirit of tkz-euclide (hence the name). Maybe \tkzDefPointBy can do what you want. –  Caramdir May 24 '11 at 19:22
add comment

2 Answers

up vote 4 down vote accepted

TkZ points are just coordinate nodes. As such you can use and define them in the same way. For example:

\documentclass{article}

\usepackage{tkz-euclide}

\begin{document}
\begin{tikzpicture}
    \tkzDefPoint(0,0){A}
    \tkzDefPoint(2,2){B}
    \path let \p1=(A), \p2=(B) in (\x1,\y2) node[coordinate] (C) {};
    \tkzDrawPoints(A,B,C)
\end{tikzpicture}
\end{document}
share|improve this answer
    
Ye we can do that but I prefer to avoid the mix of syntaxes. I think it's preferable to create a new macro but this is possible ... –  Alain Matthes May 24 '11 at 21:08
add comment

You can use the tikz possibilities, don't forget that you can use tikz and pgf at the same time with tkz. Another possibility is to use (the next macro is in tkz)

\makeatletter
    \def\tkz@@extractxy#1{%
    \pgfextractx{\pgf@x}{\pgfpointanchor{#1}{center}}
    \pgfextracty{\pgf@y}{\pgfpointanchor{#1}{center}} 
    } 
\makeatother

For example but I don't test it :

\makeatletter
\def\tkzExchangeCoord(#1,#2)#3{% 
\tkz@@extractxy{#1}%
\pgf@xa=\pgf@x\relax
\tkz@@extractxy{#2}%
\pgf@yb=\pgf@y\relax 
\path[coordinate](\pgf@xa,\pgf@yb) coordinate (#3);}
\makeatother

or more in the spirit of tkz

\makeatletter
\def\tkzExchangeCoord(#1,#2){% 
\tkz@@extractxy{#1}%
\pgf@xa=\pgf@x\relax
\tkz@@extractxy{#2}%
\pgf@yb=\pgf@y\relax 
\path[coordinate](\pgf@xa,\pgf@yb) coordinate (tkzPointResult);}
\makeatother

You can use the point with :

\tkzExchangeCoord(A,B)
\tkzGetPoint{H}
share|improve this answer
    
Perhaps you can make something easier with some tikz macros –  Alain Matthes May 24 '11 at 19:19
    
Do you know why \draw let \p1=(A), \p2=(B) in \pgfextra{\tkzDefPoint(\x1,\y2){C}}; doesn't work? (It results in FP error: Illegal character p found in float number!) –  Caramdir May 24 '11 at 19:26
    
this is simple : \x1 and \y2 are lengths with pt or \tkzDefPoint uses numbers without units (by defaut the macro accepts only cm) so you need to remove pt –  Alain Matthes May 24 '11 at 20:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.