Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
lwx228
Level VII

How does JSL calculate whether the fourth point is on the same circle as the first three points?

See a method of Craige_Hales: Smallest Covering Circle 
But I still haven't learned.
My need is to determine a circle by the first three points.
And then determine if the fourth point is on the circle.

2020-02-21_07-31.png

So how to write JSL?

Thanks Experts!

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
ian_jmp
Staff

Re: How does JSL calculate whether the fourth point is on the same circle as the first three points?

@Craige_Hales solution at your link above does all the hard work, and it calculates 'center' and 'radius' for the circle. So, if you want to test a specific point, you could add something like this to his code:

// Test if a specific point is on the circle (in this case, the origin)
myPoint = Transpose([0, 0]);
myPointShifted = myPoint - center;
myDistance = Sqrt(myPointShifted[1]^2 + myPointShifted[2]^2);
tol = 1E-6;
if(abs(myDistance - radius) <= tol,
	Print("Point is on the circle"),
	Print("Point is not on the circle")
	);

View solution in original post

Highlighted
Craige_Hales
Staff (Retired)

Re: How does JSL calculate whether the fourth point is on the same circle as the first three points?

6 REPLIES 6
Highlighted
ian_jmp
Staff

Re: How does JSL calculate whether the fourth point is on the same circle as the first three points?

@Craige_Hales solution at your link above does all the hard work, and it calculates 'center' and 'radius' for the circle. So, if you want to test a specific point, you could add something like this to his code:

// Test if a specific point is on the circle (in this case, the origin)
myPoint = Transpose([0, 0]);
myPointShifted = myPoint - center;
myDistance = Sqrt(myPointShifted[1]^2 + myPointShifted[2]^2);
tol = 1E-6;
if(abs(myDistance - radius) <= tol,
	Print("Point is on the circle"),
	Print("Point is not on the circle")
	);

View solution in original post

Highlighted
lwx228
Level VII

Re: How does JSL calculate whether the fourth point is on the same circle as the first three points?

Yes, thanks to Craige_Hales for doing so much work.
Thanks for ian help!

I tried to modify the code to change the number of points generated in line 1 to three.
I found that this code only drew the circle with the largest diameter.

 

2020-02-21_21-31.png

 

I really don't know how to modify it so that the circle is determined by A, B and C at the same time.
So I still need help.

Thanks Experts!

Highlighted
Craige_Hales
Staff (Retired)

Re: How does JSL calculate whether the fourth point is on the same circle as the first three points?

Highlighted
lala
Level III

Re: How does JSL calculate whether the fourth point is on the same circle as the first three points?

That's a good question.
I tried the new method provided by @Craige_Hales ( Circle through three points ) , combined with the ian_jmp'code. But it doesn't get the job done.

 

Can @ian_jmp  modify the following code according to the new code of Craige_Hales?Thank you very much!

Highlighted
ian_jmp
Staff

Re: How does JSL calculate whether the fourth point is on the same circle as the first three points?

As mentioned in my post, the first post from @Craige_Hales calculates the variables 'center' and 'radius' and my code snippet above uses these.

 

His new code contains these lines (near the very end):

// choose distance to A, could use B or C too...
Circle( {xc, yc}, Sqrt( (xc - ax) ^ 2 + (yc - ay) ^ 2 ) );

Looking in 'Help > Scripting Guide' for 'Circle', you will see that '{xc, yc}' are the coordinates of the center and the result of the 'Sqrt()' operation is the radius (of the circle that's currently drawn).

Highlighted
lala
Level III

Re: How does JSL calculate whether the fourth point is on the same circle as the first three points?

OK、Thanks!

Circle( {20, 20}, 4, 7, 10/* no fill for concentric circles */ );
Article Labels

    There are no labels assigned to this post.