RE: [Flashcoders] Algorithm to find "center" of an irregular shape

2006-09-21 Thread Danny Kodicek
> In this particular application, the shapes are the areas between the
> lines created when graphing several time series on a chart (e.g., the
> price of several stocks, graphed over time)

It sounds to me like what you need is actually some kind of line of best fit
rather than a centre. The usual idea is to find a line (if you do want a
point, then this works for a point too) such that the squared distance of
all the points in your region from the line (or point) is minimised. You can
find this by using a correlation coefficient (a quick Google turned up this
page which sums up the process pretty well:
http://helios.bto.ed.ac.uk/bto/statistics/tress11.html). For data in more
than two dimensions you'll need to use a more complicated process called
principal components analysis.

Best
Danny

___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


RE: [Flashcoders] Algorithm to find "center" of an irregular shape

2006-09-21 Thread Mike Keesey
Look into MovieClip.getBounds() and MovieClip.getRect(). For example,
you could use:

import flash.geom.Point;
// ...
function getCenter(shape:MovieClip):Point {
var bounds:Object = shape.getBounds(this);
var center:Point = new Point();
center.x = (bounds.xMax - bounds.xMin) / 2;
center.y = (bounds.yMax - bounds.yMin) / 2;
return center;
}

(Assuming that the scope of this function is a movie clip timeline or a
subclass of MovieClip.)
―
Mike Keesey

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:flashcoders-
> [EMAIL PROTECTED] On Behalf Of matt stuehler
> Sent: Thursday, September 21, 2006 9:58 AM
> To: Flashcoders mailing list
> Subject: [Flashcoders] Algorithm to find "center" of an irregular
shape
> 
> All,
> 
> I'm not too handy with geometry, so I'm not even sure this is
> possible, but I'm looking for an algorithm that will determine the
> "center" of an irregular shape.
> 
> I'm not even sure there is a meaningful definition of a "center", but
> I'd like to at least find a point that is within the area of the
> shape. (I realize that with certain shapes, like a donut, this might
> be an intractible problem), so even some rough approximation would
> help.
> 
> In this particular application, the shapes are the areas between the
> lines created when graphing several time series on a chart (e.g., the
> price of several stocks, graphed over time)
> 
> Many thanks in advance for any advice or insights!
> 
> Cheers,
> Matt Stuehler
> ___
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> 
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com

___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com