classdef fourcenters2d
    
    properties
        scale
        al_t
    end
    
    methods
        % constructor
        function obj = fourcenters2d(Scale, Al_t)
            if nargin > 0
                obj.scale = Scale;
            else
                obj.scale = 1;
            end
                
            if nargin > 1
                obj.al_t = Al_t;
            else
                obj.al_t = 1;
            end
        end
        
        % Samples the vector field of the four centers flow
        function [u, v] = sample(obj, x, y, t)
            u = exp(-y * y - x * x)*(obj.al_t*y*exp(y*y + x * x) - 6 * obj.scale*cos(obj.al_t*t)*sin(obj.al_t*t)*y*y*y + (12 * obj.scale*(cos(obj.al_t*t)*cos(obj.al_t*t)) - 6 * obj.scale)*x*y*y + (6 * obj.scale*cos(obj.al_t*t)*sin(obj.al_t*t)*x*x + 6 * obj.scale*cos(obj.al_t*t)*sin(obj.al_t*t))*y + (3 * obj.scale - 6 * obj.scale*(cos(obj.al_t*t)*cos(obj.al_t*t)))*x);
			v = -exp(-y * y - x * x)*(obj.al_t*x*exp(y*y + x * x) - 6 * obj.scale*cos(obj.al_t*t)*sin(obj.al_t*t)*x*y*y + ((12 * obj.scale*(cos(obj.al_t*t)*cos(obj.al_t*t)) - 6 * obj.scale)*x*x - 6 * obj.scale*(cos(obj.al_t*t)*cos(obj.al_t*t)) + 3 * obj.scale)*y + 6 * obj.scale*cos(obj.al_t*t)*sin(obj.al_t*t)*x*x*x - 6 * obj.scale*cos(obj.al_t*t)*sin(obj.al_t*t)*x);
        end
        
        % Samples the x-partial of the vector field of the four centers flow
        function [u, v] = sample_dx(obj, x, y, t)
            u = 3 * obj.scale*(4 * cos(obj.al_t*t)*sin(obj.al_t*t)*x*y*y*y - 8 * (cos(obj.al_t*t)*cos(obj.al_t*t)) * x*x * y*y + 4 * x*x * y*y + 4 * (cos(obj.al_t*t)*cos(obj.al_t*t)) * y*y - 2 * y*y - 4 * cos(obj.al_t*t)*sin(obj.al_t*t)*x*x*x * y + 4 * (cos(obj.al_t*t)*cos(obj.al_t*t)) * x*x - 2 * x*x - 2 * (cos(obj.al_t*t)*cos(obj.al_t*t)) + 1)*exp(-y * y - x * x);
			v = -exp(-y * y - x * x)*(obj.al_t*exp(y*y + x * x) + 12 * obj.scale*cos(obj.al_t*t)*sin(obj.al_t*t)*x*x * y*y - 6 * obj.scale*cos(obj.al_t*t)*sin(obj.al_t*t)*y*y - 24 * obj.scale*(cos(obj.al_t*t)*cos(obj.al_t*t)) * x*x*x * y + 12 * obj.scale*x*x*x * y + 36 * obj.scale*(cos(obj.al_t*t)*cos(obj.al_t*t)) * x*y - 18 * obj.scale*x*y - 12 * obj.scale*cos(obj.al_t*t)*sin(obj.al_t*t)*x*x*x*x + 30 * obj.scale*cos(obj.al_t*t)*sin(obj.al_t*t)*x*x - 6 * obj.scale*cos(obj.al_t*t)*sin(obj.al_t*t));
        end
        
        % Samples the y-partial of the vector field of the four centers flow
        function [u, v] = sample_dy(obj, x, y, t)
            u = exp(-y * y - x * x)*(obj.al_t*exp(y*y + x * x) + 12 * obj.scale*cos(obj.al_t*t)*sin(obj.al_t*t)*y*y*y*y - 24 * obj.scale*(cos(obj.al_t*t)*cos(obj.al_t*t)) * x*y*y*y + 12 * obj.scale*x*y*y*y - 12 * obj.scale*cos(obj.al_t*t)*sin(obj.al_t*t)*x*x * y*y - 30 * obj.scale*cos(obj.al_t*t)*sin(obj.al_t*t)*y*y + 36 * obj.scale*(cos(obj.al_t*t)*cos(obj.al_t*t)) * x*y - 18 * obj.scale*x*y + 6 * obj.scale*cos(obj.al_t*t)*sin(obj.al_t*t)*x*x + 6 * obj.scale*cos(obj.al_t*t)*sin(obj.al_t*t));
			v = -3 * obj.scale*(4 * cos(obj.al_t*t)*sin(obj.al_t*t)*x*y*y*y - 8 * (cos(obj.al_t*t)*cos(obj.al_t*t)) * x*x * y*y + 4 * x*x * y*y + 4 * (cos(obj.al_t*t)*cos(obj.al_t*t)) * y*y - 2 * y*y - 4 * cos(obj.al_t*t)*sin(obj.al_t*t)*x*x*x * y + 4 * (cos(obj.al_t*t)*cos(obj.al_t*t)) * x*x - 2 * x*x - 2 * (cos(obj.al_t*t)*cos(obj.al_t*t)) + 1)*exp(-y * y - x * x);
        end
        
        % Samples the t-partial of the vector field of the four centers flow
        function [u, v] = sample_dt(obj, x, y, t)
            u = 6 * obj.al_t*obj.scale*((sin(obj.al_t*t)*sin(obj.al_t*t)) * y*y*y - (cos(obj.al_t*t)*cos(obj.al_t*t)) * y*y*y - 4 * cos(obj.al_t*t)*sin(obj.al_t*t)*x*y*y - (sin(obj.al_t*t)*sin(obj.al_t*t)) * x*x * y + (cos(obj.al_t*t)*cos(obj.al_t*t)) * x*x * y - (sin(obj.al_t*t)*sin(obj.al_t*t)) * y + (cos(obj.al_t*t)*cos(obj.al_t*t)) * y + 2 * cos(obj.al_t*t)*sin(obj.al_t*t)*x)*exp(-y * y - x * x);
			v = -6 * obj.al_t*obj.scale*((sin(obj.al_t*t)*sin(obj.al_t*t)) * x*y*y - (cos(obj.al_t*t)*cos(obj.al_t*t)) * x*y*y - 4 * cos(obj.al_t*t)*sin(obj.al_t*t)*x*x * y + 2 * cos(obj.al_t*t)*sin(obj.al_t*t)*y - (sin(obj.al_t*t)*sin(obj.al_t*t)) * x*x*x + (cos(obj.al_t*t)*cos(obj.al_t*t)) * x*x*x + (sin(obj.al_t*t)*sin(obj.al_t*t)) * x - (cos(obj.al_t*t)*cos(obj.al_t*t)) * x)*exp(-y * y - x * x);
        end
    end
    
end

