classes

GeometryMath.as

Stiahnuť GeometryMath.as

package sk.yoz.math
{
    import flash.geom.Point;
    
    public class GeometryMath extends Object
    {
        public function GeometryMath()
        {
            super();
        }
        
        public static function isLine(point1:Point, point2:Point, 
            point3:Point, orderSensitive:Boolean = true):Boolean
        {
            var x1:Number = point1.x - point2.x;
            var x2:Number = point2.x - point3.x;
            var y1:Number = point1.y - point2.y;
            var y2:Number = point2.y - point3.y;
            
            if(orderSensitive && ((x1 > 0 && x2 < 0) || (x1 < 0 && x2 > 0) 
                || (y1 < 0 && y2 > 0) || (y1 < 0 && y2 > 0)))
                return false;
            else if(!y2)
                return !y1;
            else if(!x2)
                return !x1;
            else
                return x1 / x2 == y1 / y2;
        }
    }
}