1

given three points $v_1, v_2, v_3$ and a circle with center $v_1$ such that $v_2, v_3$ lie on its boundary, I want to remove the part of the circle not between $v_2$ and $v_3$. I know how to do this if the corresponding angles are known (for example in the code below I want to get the part of the circle between the angles 0 and 90). But I do not know how to compute this for not rectangular settings.

\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\path 
(0,0) coordinate (v1) node[below]{$v_1$}
(1,0) coordinate (v2) node[below]{$v_2$}
(0,1) coordinate (v3) node[below]{$v_3$};

\draw (v1)--(v2) (v1)--(v3);

\draw (v1) circle(1);

\foreach \p in {v1,v2,v3} \fill (\p) circle(2pt); \end{tikzpicture} \end{document}

samabu
  • 257
  • If you know the radius of the circle and polar angles, or know how to compute them from Cartesian coordinates, a mice solution is @Jake's answer to this question: https://tex.stackexchange.com/questions/123158/tikz-using-the-ellipse-command-with-a-start-and-end-angle-instead-of-an-arc – Jhor May 12 '22 at 11:33
  • Hello, thank you very much for your comment. I think my huge problem is that I do not know how to obtain the right angles. Given those I could simply use the arc command, but what I want to do is, to say start at $v(2)$ and run along the circle until you meet $(v3)$. – samabu May 12 '22 at 11:53
  • To compute te length and angles, see https://tex.stackexchange.com/questions/39293/coordinates-a-b-compute-b-a-and-angle-between-x-and-b-a – Jhor May 12 '22 at 11:56
  • You are asking about angles for "not rectangular settings". Please update your example to reflect this, so we can see what you mean. – hpekristiansen May 12 '22 at 12:20

3 Answers3

4

If you know the angles you can use an arc command:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\fill (0,0) coordinate[label=below:$v_1$] (v1) circle(2pt);
\fill (30:2cm) coordinate[label=right:$v_2$] (v2) circle(2pt);
\fill (95:2cm) coordinate[label=$v_3$] (v3) circle(2pt);

\draw (v3)--(v1)--(v2) arc[start angle=30, end angle=95, radius=2];

\end{tikzpicture}

\end{document}

enter image description here

if you don't know the angles, calc library can help:

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

\begin{document} \foreach \i in {1,2,3}{ \begin{tikzpicture} \fill (0,0) coordinate[label=below:$v_1$] (v1) circle(2pt); \fill (360rand:2cm) coordinate[label=right:$v_2$] (v2) circle(2pt); \fill (360rand:2cm) coordinate[label=$v_3$] (v3) circle(2pt);

\draw let \p1=($(v2)-(v1)$), \p2=($(v3)-(v1)$), \n1={veclen(\x1,\y1)}, \n2={atan2(\y1,\x1)}, \n3={atan2(\y2,\x2)} in (v3)--(v1)--(v2) arc[start angle=\n2, end angle=\n3, radius=\n1];

\end{tikzpicture}}

\end{document}

enter image description here

Ignasi
  • 136,588
  • Hello, thank you for the answer. I am familiar with the arc command, but I do not know how to get the right angles. Do you know how to elegantly compute them? – samabu May 12 '22 at 11:50
  • @samabu i don't know about its elegancy, but I've added a possible solution to my answer. – Ignasi May 12 '22 at 12:37
0

In your particular case the transform from cartesian coordinate to polar is very simple. By elementary geometry we know, that:

(0,1) --> (90:1)
(1,0) --> (0:1)

considering above the arc command is simple to define. So, your MWE can be changed to:

\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                calc,
                positioning}

\begin{document} \begin{tikzpicture}[ dot/.style = {circle, fill, inner sep=1pt, label=#1, node contents={}}, every label/.append style = {inner sep=2pt, font=\footnotesize} ] \draw (0,0) node[dot=below:$v_1$] -- (0,1) node[dot=above:$v_2$] arc(90:0:1) node[dot=below:$v_3$] -- cycle; \end{tikzpicture} \end{document}

enter image description here

At more general cartesian coordinate, you need first to calculate star t and the end angle using inverse trigonometric function. For example:

\alpha = acos{\frac{x}{x^2 + y^2}

where x and y are cartesian coordinates of a point on the $x,y$ plane.

Zarko
  • 296,517
0

You can do it with \clip, although it is a lot easier for short arcs (blue) than long arcs (red).

\documentclass{standalone}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\path 
(0,0) coordinate (v1) node[below]{$v_1$}
(1,0) coordinate (v2) node[below]{$v_2$}
(0,1) coordinate (v3) node[below]{$v_3$};

\draw (v1)--(v2) (v1)--(v3);

\begin{scope} \clip (v2) rectangle (v3); \draw[blue] (v1) circle(1); \end{scope}

\begin{scope}[local bounding box=Bob] \path (v1) circle(1); \clip (Bob.north west)--(v3)--(v1)--(v2)--(Bob.south east)-- (Bob.south west)--cycle; \draw[red] (v1) circle(1); \end{scope}

\foreach \p in {v1,v2,v3} \fill (\p) circle(2pt); \end{tikzpicture} \end{document}

demo

John Kormylo
  • 79,712
  • 3
  • 50
  • 120