Graphics, Figures & Tablesxy coordinates for a point

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
topsquark
Posts: 71
Joined: Wed Oct 05, 2022 10:30 pm

xy coordinates for a point

Post by topsquark »

I have a point, I0, that I have calculated through the intersection of two curves.
\path[name intersections={of=c0 and c1,by=I0}];

I can use the through library to put a circle through this point:
\node[draw,circle through={(I0)}] at (O) {};

This works fine. However, I find I'm in need of the radius of this circle. So I did something different. I found the xy coordinates of the point I0:
\path[transform canvas] (I0); \pgfgetlastxy{\x}{\y};

The problem is, the point (\x,\y) is not the same as the point I0. (The inner circle should be the same as the outer circle going through the intersection point.) What am I doing wrong?

Thanks!

-Dan

Addendum: Oh! When I did the square root there was some kind of size problem. I had to do a scaling. That's a whole other question.

Code: Select all

Code, edit and compile here:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections,through}
\begin{document}
\newcommand*{\myangle}{10}
\begin{tikzpicture}[scale=0.6]
\coordinate (O) at (0,0);
\path[name path=c0] (120:4) arc(-167.2:-219.2:10) arc(39.2:-12.8:10);
\draw (120:4) arc(-167.2:-219.2:10) arc(39.2:-12.8:10);
\path[name path=c1] (120+\myangle:4) arc(-167.2+\myangle:-219.2+\myangle:10) arc(39.2+\myangle:-12.8+\myangle:10);
\draw (120+\myangle:4) arc({-167.2+\myangle}:-219.2+\myangle:10) arc(39.2+\myangle:-12.8+\myangle:10);
\path[name intersections={of=c0 and c1,by=I0}];
\path[transform canvas] (I0); \pgfgetlastxy{\x}{\y};
\pgfmathsetmacro\radiusI{10*sqrt((\x/10)^2+(\y/10)^2)};
\draw (O) circle(\radiusI pt);
\node[draw,circle through={(I0)}] at (O) {};
\end{tikzpicture}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
TikZ book
rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

xy coordinates for a point

Post by rais »

Here, \pgfgetlastxy{\x}{\y} returns x,y for point I0 after scaling, that's why your calculated radius is only 60% of what it should have been:

Code: Select all

Code, edit and compile here:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections,through}
\newlength\myx
\newlength\myy
\begin{document}
\newcommand*{\myangle}{10}
\begin{tikzpicture}[scale=0.6]
\coordinate (O) at (0,0);
\draw[name path=c0] (120:4) arc(-167.2:-219.2:10) arc(39.2:-12.8:10);
\draw[name path=c1] (120+\myangle:4) arc(-167.2+\myangle:-219.2+\myangle:10) arc(39.2+\myangle:-12.8+\myangle:10);
\path[name intersections={of=c0 and c1,by=I0}];
\path[transform canvas] (I0); \pgfgetlastxy{\x}{\y}%;
\pgfmathsetmacro\radiusI{16.666667*sqrt((\x/10)^2+(\y/10)^2)}% 10/scale ...
\draw (O) circle(\radiusI pt);
\setlength\myx{\x}%
\setlength\myy{\y}%
\setlength\myx{1.666667\myx}% \myx / scale
\setlength\myy{1.666667\myy}%
\draw[black!30] (O) ++(-0.5,-0.5) -- ++(1,1) ++(-1,0) -- ++(1,-1);
\draw[green] (I0) -- ++(-\myx, 0) -- ++(0, -\myy) --cycle;
\node[draw,circle through={(I0)}] at (O) {};
\end{tikzpicture}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
BTW: neither \pgfgetlastxy nor \pgfmathsetmacro require a trailing `;' character; in fact, you should get a message like

Code: Select all

Missing character: There is no ; in font nullfont!
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
for both cases.

KR
Rainer
topsquark
Posts: 71
Joined: Wed Oct 05, 2022 10:30 pm

xy coordinates for a point

Post by topsquark »

rais wrote:Here, \pgfgetlastxy{\x}{\y} returns x,y for point I0 after scaling, that's why your calculated radius is only 60% of what it should have been:

Code: Select all

Code, edit and compile here:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections,through}
\newlength\myx
\newlength\myy
\begin{document}
\newcommand*{\myangle}{10}
\begin{tikzpicture}[scale=0.6]
\coordinate (O) at (0,0);
\draw[name path=c0] (120:4) arc(-167.2:-219.2:10) arc(39.2:-12.8:10);
\draw[name path=c1] (120+\myangle:4) arc(-167.2+\myangle:-219.2+\myangle:10) arc(39.2+\myangle:-12.8+\myangle:10);
\path[name intersections={of=c0 and c1,by=I0}];
\path[transform canvas] (I0); \pgfgetlastxy{\x}{\y}%;
\pgfmathsetmacro\radiusI{16.666667*sqrt((\x/10)^2+(\y/10)^2)}% 10/scale ...
\draw (O) circle(\radiusI pt);
\setlength\myx{\x}%
\setlength\myy{\y}%
\setlength\myx{1.666667\myx}% \myx / scale
\setlength\myy{1.666667\myy}%
\draw[black!30] (O) ++(-0.5,-0.5) -- ++(1,1) ++(-1,0) -- ++(1,-1);
\draw[green] (I0) -- ++(-\myx, 0) -- ++(0, -\myy) --cycle;
\node[draw,circle through={(I0)}] at (O) {};
\end{tikzpicture}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
BTW: neither \pgfgetlastxy nor \pgfmathsetmacro require a trailing `;' character; in fact, you should get a message like

Code: Select all

Missing character: There is no ; in font nullfont!
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
for both cases.

KR
Rainer
Actually, I figured out the scaling problem last night and was just coming in to report on it. Thank you!

As to the ; it was in the examples I found. I'll have to look those up again.

Thank you for the comments!

-Dan
Post Reply