Full Version: Apollonius circles tangent to circles

From: bemfarmer [#1]
 9 Oct
To: ALL

HI Michael
I'm doing a script called _ApolloniusCircles, which, given 3 circles with non-collinear centers selected by the user, using code from LineWeb.
This would place tangent circles/spheres inside a Ring Dupin Cyclide, and do "gaskets."

It is necessary to find the center of the circles using script.
BoundingBoxCenter works, but the question is, can the center of a circle be found like the following var x1 = code which does not work:

// Select 3 xy circles: Good code from LineWeb:
var ObjectPicker = moi.ui.createObjectPicker();
// ObjectPicker.allowStandaloneCurves(); //From LineWeb.
if ( !GetObjects( ObjectPicker ) )
return;

var circles = ObjectPicker.objects;
circles.sortBySelectionOrder();
if ( circles.length < 3 )
return;

// Get circle centers and radii.
var c1 = circles.item(0); //OK
var c2 = circles.item(1); //OK
var c3 = circles.item(2); //OK

// radius seems to work.
var r1 = c1.radius; OK?>>>>>Bad code:

var x1 = c1.frame.center.x;
var x1 = c1.frame.x;
var x1 = c1.getCenterPt.x;
var x1 = c1.pt.x;
var x1 = c1.getCenterPt.x;
var x1 = c1.center.pt.x;
var x1 = c1.centerpt().x;
var x1 = c1.centerpt.x;
var x1 = c1.centerPt.x;
var x1 = c1.center.x
var x1 = c1.getCenterPt().x
var x1 = c1.getCenter().x
var x1 = c1.getcenterPt().x;

Second question, is the c1.radius code OK?

Third question, is a circle just another curve, or is there objectpicker code to restrict selection to circles?

Thank you
- Brian

Edit: Looks like I'll pursue the var bbox = objects.getHighAccuracyBoundingBox(); var pt = bbox.center;
http://moi3d.com/forum/index.php?webtag=MOI&msg=5440.1

Reply


From: Karsten (KMRQUS) [#2]
 9 Oct
To: ALL

Hello Brian,

you remember the CCC script. In the script is a function called csp. This function calculates the Center of a Curveseg by 3 given pointcurves. You can check it by switching the script in radius mode and set the scalefactor to 1 applied to a circle. The 3 Points you can get by using the startpoint and make a arraycurve. The script calculates the curvature / radius Center locally. If you have a circle or an arc anyway - the result is the same.

Have a nice day
Karsten

Reply


From: bemfarmer [#3]
 9 Oct
To: ALL

Thank you Karsten.

Reply


From: Michael Gibson [#4]
 9 Oct
To: ALL

Hi Brian, by the way the Draw curves > Circles > Tangent command can generate a circle tangent to 3 other curves currently.

> but the question is, can the center of a circle be found like the following var x1 = code which does not work:

Sorry no, currently there isn't anything set up for returning circle properties to script, the only things exposed specific to curves currently are:

crv.isClosed property,
crv.getFacesOfEdge()
crv.getUVCurvesOfEdge()
crv.getStartPt()
crv.getEndPt()
crv.getLength()


> Second question, is the c1.radius code OK?

I don't think so - I'd think it is returning "undefined".


> Third question, is a circle just another curve, or is there objectpicker
> code to restrict selection to circles?

Sorry no there isn't currently, the current ones are just by more general object type than that:
allowCurves();
allowStandaloneCurves();
allowEdgeCurves();
allowFaces();
allowBReps();
allowPointObjects();
allowEditPoints();
allowTopLevelObjects();

Probably a good way to add a more flexible one would be to let you pass in a function that the objectpicker would then call to decide if an object should be allowed to be picked or not.

Those are some things that I can add in for you in v4 once it's underway. Not too much longer...

- Michael

Reply


From: bemfarmer [#5]
 9 Oct
To: ALL

Thank you very much Michael!

BoundingBox center should do nicely.

Looking forward to MoI4.

- Brian

Well CircleTan command does create the desired tangent circle.

Reply


From: bemfarmer [#6]
 9 Oct
To: ALL

I think that the CircleTan command has the Apollonius algebra built in.
- Brian

Reply


From: Michael Gibson [#7]
 9 Oct
To: ALL

Hi Brian,

re:
> I think that the CircleTan command has the Apollonius algebra built in.

CircleTan uses an iterative solver technique - that's when given some "seed points" to start with it takes little steps on each curve and sees which directions are getting closer to a good result. Then smaller and smaller steps to converge in on the answer.

The tricky part with that kind of solver is getting good seed points, it tends to work well when you can guide it by picks in the general region where you think the answer should be.

The good part about it is that it's very general purpose, it can find a circle tangent to 3 general curves, not just 3 circles:


- Michael

Image Attachments:
circle_tangent_to_3_curves.jpg 

Reply


Reply to All

Back to thread list | Login

© 2017 Project Beehive Forum