Apollonius circles tangent to circles

Next
 From:  bemfarmer
8618.1 
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

EDITED: 9 Oct by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Karsten (KMRQUS)
8618.2 In reply to 8618.1 
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 Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
8618.3 In reply to 8618.2 
Thank you Karsten.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
8618.4 In reply to 8618.1 
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 Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
8618.5 In reply to 8618.4 
Thank you very much Michael!

BoundingBox center should do nicely.

Looking forward to MoI4.

- Brian

Well CircleTan command does create the desired tangent circle.

EDITED: 9 Oct by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
8618.6 In reply to 8618.5 
I think that the CircleTan command has the Apollonius algebra built in.
- Brian
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  Michael Gibson
8618.7 In reply to 8618.6 
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

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All