0
$\begingroup$

I make a circle with radius as below

Ctest = Table[{0.05*Cos[Theta*Degree], 0.05*Sin[Theta*Degree]}, {Theta, 1, 360}] // N;

And herewith is my list of data points

pts = {{0., 0.}, {0.00493604, -0.00994539}, {0.00987001, -0.0198918}, {0.0148019, -0.0298392}, {0.0197318, -0.0397877}, {0.0246596, -0.0497372}, {0.0295853, -0.0596877}, {0.0345089, -0.0696392}, {0.0394305, -0.0795918}, {0.04435, -0.0895453}, {0.0492675, -0.0994999}, {0.0541829, -0.109456}, {0.0590962, -0.119412}, {0.0640075, -0.12937}, {0.0689166, -0.139328}, {0.0738238, -0.149288}, {0.0787288, -0.159249}, {0.0836318, -0.169211}, {0.0885327, -0.179173}, {0.0934316, -0.189137}, {0.0983284, -0.199102}, {0.103223, -0.209068}, {0.108116, -0.219034}, {0.113006, -0.229002}, {0.117895, -0.238971}, {0.122781, -0.248941}, {0.127666, -0.258912}};

I would like to know the intersection between a circle and list data point as shown by figure below. How to make its program automatically? I mean that if one day I would like to change the radius of circle, the program would still work.

enter image description here

$\endgroup$
  • 3
    $\begingroup$ Unclear what is wanted here. Suppose none of the data points are on the circle? What is intended by "intersection"? $\endgroup$ – Daniel Lichtblau Mar 6 '18 at 15:17
  • $\begingroup$ Intersection[cTest, l] is what I get from your question, but I assume you mean something else? $\endgroup$ – SuTron Mar 6 '18 at 15:20
  • $\begingroup$ @Daniel Lichtblau, I want to know the intersection point between a circle and a curve. I used Mathematica v10.3 $\endgroup$ – SelfA Mar 6 '18 at 15:33
  • 3
    $\begingroup$ What I see from your code is a list of points that lie on a circle, and another list of point. Could you specify exactly what you would like? To find the point of intersection of two interpolating curves? $\endgroup$ – anderstood Mar 6 '18 at 15:40
  • $\begingroup$ @anderstood, I want to know the point of intersection between the points of the circle with the points of the curve. $\endgroup$ – SelfA Mar 7 '18 at 3:35
1
$\begingroup$
$Version

(* "10.3.1 for Mac OS X x86 (64-bit) (December 9, 2015)" *)

Ctest = Table[{0.05*Cos[Theta*Degree], 
     0.05*Sin[Theta*Degree]}, {Theta, 1, 360}] // N;

pts = {{0., 
    0.}, {0.00493604, -0.00994539}, {0.00987001, -0.0198918}, \
{0.0148019, -0.0298392}, {0.0197318, -0.0397877}, {0.0246596, \
-0.0497372}, {0.0295853, -0.0596877}, {0.0345089, -0.0696392}, \
{0.0394305, -0.0795918}, {0.04435, -0.0895453}, {0.0492675, \
-0.0994999}, {0.0541829, -0.109456}, {0.0590962, -0.119412}, \
{0.0640075, -0.12937}, {0.0689166, -0.139328}, {0.0738238, \
-0.149288}, {0.0787288, -0.159249}, {0.0836318, -0.169211}, \
{0.0885327, -0.179173}, {0.0934316, -0.189137}, {0.0983284, \
-0.199102}, {0.103223, -0.209068}, {0.108116, -0.219034}, {0.113006, \
-0.229002}, {0.117895, -0.238971}, {0.122781, -0.248941}, {0.127666, \
-0.258912}};

reg = RegionIntersection[Line[Ctest], Line[pts]]

(* Point[{{0.0222112, -0.0447938}}] *)

START EDIT: As requested in comment

coord = reg[[1, 1]]

(* {0.0222112, -0.0447938} *)

END EDIT

Graphics[{Thick, Blue, Line[Ctest], Gray, Line[pts], Red, 
  AbsolutePointSize[5], reg}, Axes -> True]

enter image description here

$\endgroup$
  • $\begingroup$ Thank you for your help. I get it. Anyway, How to take the number only (delete word "Point") $\endgroup$ – SelfA Mar 6 '18 at 15:58
1
$\begingroup$

Here is another solution, which does not interpolate and search for the intersection, but instead finds the next nearest points of the circle data and the data from the list pts:

Ctest = Table[{0.05*Cos[Theta*Degree], 
    0.05*Sin[Theta*Degree]}, {Theta, 1, 360}];

pts = {{0., 
    0.}, {0.00493604, -0.00994539}, {0.00987001, -0.0198918}, \
{0.0148019, -0.0298392}, {0.0197318, -0.0397877}, {0.0246596, \
-0.0497372}, {0.0295853, -0.0596877}, {0.0345089, -0.0696392}, \
{0.0394305, -0.0795918}, {0.04435, -0.0895453}, {0.0492675, -0.0994999}, 
{0.0541829, -0.109456}, {0.0590962, -0.119412}, {0.0640075, -0.12937}, 
{0.0689166, -0.139328}, {0.0738238, -0.149288}, {0.0787288, -0.159249}, 
{0.0836318, -0.169211}, {0.0885327, -0.179173}, {0.0934316, -0.189137}, 
{0.0983284, -0.199102}, {0.103223, -0.209068}, {0.108116, -0.219034}, 
{0.113006, -0.229002}, {0.117895, -0.238971}, {0.122781, -0.248941}, 
{0.127666, -0.258912}};

nearestFromCircle = Flatten[Nearest[
    Ctest -> {"Element", "Distance"}, pts, {1, Infinity}], 1];

circlePoint = 
  Select[nearestFromCircle, #[[2]] == 
     Min[nearestFromCircle[[All, 2]]] &];

nearestFromPts = Flatten[Nearest[
    pts -> {"Element", "Distance"}, Ctest, {1, Infinity}], 1];

ptsPoint = 
  Select[nearestFromPts, #[[2]] == Min[nearestFromPts[[All, 2]]] &];

alldata = Partition[Flatten[{Ctest, pts}], 2];

{xmin, xmax} = MinMax[alldata[[All, 1]]];
{ymin, ymax} = MinMax[alldata[[All, 2]]];

g1 = ListPlot[pts, PlotStyle -> Blue];
g2 = ListPlot[Ctest, PlotStyle -> Red];

Show[g1, g2, 
 Epilog -> {{PointSize[Large], Blue, 
    Point[ptsPoint[[1, 1]]]}, {{PointSize[Large], Red, 
     Point[circlePoint[[1, 1]]]}}}, AspectRatio -> Automatic, 
 PlotRange -> {{xmin, xmax}, {ymin, ymax}}]

enter image description here

The two nearest points are:

circlePoint[[1, 1]]
{0.021918557339453873`, -0.044939702314958356`}

and

ptsPoint[[1, 1]]
{0.0246596`, -0.0497372`}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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