public double addPoint(Point p, double angle, double THRESHOLD2)
    {
        if (angle != ConnectedComponent.ANGLE_UNDEFINED)
        {
            // test point is not a corner
            double diff = angleDiff(angle, prevAngle);
            
            // if the sign of angle change is reversed
            if (sign(diff) != dirChange)
            {
                // corner detected
                if (accumChange >= THRESHOLD1)
                {
                    return angleDiff(angle, approximateAngle());
                }
                
                // reset cummulated results
                if (diff != 0)
                {
                    accumChange = Math.abs(diff);
                    dirChange = sign(diff);
                }
            }
            else
            {
                accumChange += Math.abs(diff);
                if (accumChange >= THRESHOLD2)
                    return angleDiff(angle, approximateAngle());
            }
            prevAngle = angle;
        }
        _prevEnd = _end;
        _end = p;
        
        return 0;
    }