Graphics, Figures & TablestikZ | Intersection Points

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

tikZ | Intersection Points

Post by ghostanime2001 »

How do you create an arc from two points of intersections between a straight line and the x axis (see example below the circles are the points of intersection between the straight line and the arc.

Code: Select all

\documentclass[fleqn]{article} 
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amstext}
\usepackage{amsthm}
\usepackage{array}
\usepackage{auto-pst-pdf}
\usepackage{bigstrut}
\usepackage{booktabs}
\usepackage{bpchem}
\usepackage{calc}
\usepackage{cancel}
\usepackage{chemfig}
\usepackage{chemmacros}
\usepackage[shortlabels,inline]{enumitem}
\usepackage{fix-cm}
\usepackage[T1]{fontenc}
\usepackage{fouridx}
\usepackage{fourier}
\usepackage{fullpage} 
\usepackage[margin=1in]{geometry} 
\usepackage{graphics}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{lewis}
\usepackage{lmodern}
\usepackage{microtype}
\usepackage{makebox}
\usepackage[version=3]{mhchem}
\usepackage{multienum}
\usepackage{multirow}
\usepackage{nccboxes}
\usepackage{pbox}
\usepackage{pgfkeys}
\usepackage{pifont}
\usepackage{pst-math}
\usepackage{pst-node}
\usepackage{pst-plot}
\usepackage{pstricks}
\usepackage{tensor}
\usepackage{tikz}
\usetikzlibrary{matrix,calc,intersections,through,backgrounds,arrows,decorations.pathmorphing}
\usepackage{textcomp}
\usepackage{type1cm}
\usepackage{ulem}
\usepackage{wasysym}
\usepackage{xcolor}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt}
\setlength{\mathindent}{0pt}
\allowdisplaybreaks
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}
\draw [name path=xaxis] (-0.5,0) -- (2,0);
\draw [name path=yaxis] (0,-0.5) -- (0,1);
\path [name path=force,draw] (0:0) -- (30.9:2cm);
\path [name path=arc,draw] (0.4,0) arc (0:40:0.4cm);
\draw [name intersections={of=arc and xaxis, by=x}] (x) circle (1pt);
\draw [name intersections={of=arc and force, by=y}] (y) circle (1pt);
\end{tikzpicture}
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

Re: tikZ | Intersection Points

Post by ghostanime2001 »

bump
Last edited by ghostanime2001 on Tue Jan 08, 2013 6:31 pm, edited 3 times in total.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

tikZ | Intersection Points

Post by Stefan Kottwitz »

It's good that you post an example. However, it's much larger than needed. I may require that the reader installs some packages to compile it. Or to clean the preamble himself - there's a lot of packages which are not related to the question.

I mean it just constructive. Otherwise we might commonly get huge documents for small problems. Of course I tried your code to help, but I got an error when I compiled:

Code: Select all

! No room for a new \dimen .
\ch@ck ...\else \errmessage {No room for a new #3}
                                                  \fi 
l.148 \newdimen\UL@pixel
                         \UL@pixel=1in \divide\UL@pixel 300
It's caused by the ulem package and can be fixed by omitting it (here it's not required) or by loading the etex package.

However, I don't like it much to fix other not asked unnecessary problems before coming to the real question, so perhaps shorten your code and try posting complete examples which are as short as possible in the future, that would be great. And improving a question or adding information is a better way to bump than to just bump without.

Stefan
LaTeX.org admin
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

tikZ | Intersection Points

Post by ghostanime2001 »

What I meant to say is how do you join points of intersection between
1. the diagonal line and circle
2. the horizontal line and circle
with an arc in between these two intersections ?

cleaned up code :

Code: Select all

    
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
\draw [name path=axis] (-1,0) -- (1,0);
\draw [name path=line] (-0.2,-0.2) -- (0.5,0.5);
\path [name path=circle,draw] (0,0) circle (0.4cm);
\draw [name intersections={of=circle and axis, by=x}] (x) circle (1pt);
\draw [name intersections={of=circle and line, by=y}] (y) circle (1pt);
\end{tikzpicture}
\end{document}
note: my code is compiled with xelatex
Post Reply