<commit_before>/*	--------------------------------------------------- *\
		Global functions
\*	--------------------------------------------------- */
module Global{

    /*    --------------------------------------------------- *\
            [function] getScreenSize()
    
            * Return the screen size *
    
            Return: screenX, screenY
    \*    --------------------------------------------------- */
    export function getScreenSize(){
        return { width: window.innerWidth, height: window.innerHeight };
    }

	/*	--------------------------------------------------- *\
			[function] getDistanceBetween2Points(xA, xB, yA, yB)
	
			* Retourne la distance entre deux points *
	
			Return: distance
	\*	--------------------------------------------------- */
	export function getDistanceBetween2Points(aX : number, aY : number, bX : number, bY : number):number{
		return Math.sqrt(Math.pow((bY - aY), 2) + Math.pow((bX - aX), 2));
	}

    /*    --------------------------------------------------- *\
            [function] getPositionFromScreen(screeX, screenY, cam)
    
            * Retourne une position dans le world selon la position sur l'écran *
    
            Return: position
    \*    --------------------------------------------------- */
    export function getPositionFromScreen(screenX, screenY, cam){
        var camPosition = cam.getOrigin();
        var actual = { x: camPosition.x + screenX, y: camPosition.y + screenY };
        var p = {x: actual.x, y: actual.y};
        return { x: p.x, y: p.y };
    }

    /*    --------------------------------------------------- *\
            [function] getPositionFromWorld(worldX, worldY, cam)
    
            * Retourne une position dans le screen selon la position sur le world *
    
            Return: position
    \*    --------------------------------------------------- */
    export function getPositionFromWorld(worldX, worldY, cam){
        var camPosition = cam.getOrigin();
        return { x: worldX - camPosition.x, y: worldY - camPosition.y};
    }

    /*    --------------------------------------------------- *\
            [function] findRotation(x, y, x, y)
    
            * Find the rotation between two points *
    
            Return: rotation
    \*    --------------------------------------------------- */
    export function findRotation(x1,y1,x2,y2){
        var t = -(Math.atan2(x2 - x1, y2 - y1) * (180/Math.PI));
        if(t < 0){
            t += 360;
        }

        return t;
    }

    /*    --------------------------------------------------- *\
            [function] getRandom(min, max)
    
            * Retourne un nombre random entre min & max *
    
            Return: number
    \*    --------------------------------------------------- */
    export function getRandom(min : number, max : number):number{
        return Math.random() * (max - min) + min;
    }

    /*    --------------------------------------------------- *\
            [function] getTrunc(x)
    
            * Retourne une valeur tronqué d'un nombre décimal *
    
            Return: number
    \*    --------------------------------------------------- */
    export function getTrunc(x : number):number {
        return x < 0 ? Math.ceil(x) : Math.floor(x);
    }

    /*    --------------------------------------------------- *\
            [function] isAndroid()
    
            * Check si on tourne sous Android ou non *
    
            Return: true, false
    \*    --------------------------------------------------- */
    export function isAndroid(){
        if(navigator.userAgent.match(new RegExp("(Android|android)+", "g"))){
            return true;
        }
        else{
            return false;
        }
    } <commit_msg>Improvement: Use the cordova object to detect if it's Android or not.<commit_after>/*	--------------------------------------------------- *\
		Global functions
\*	--------------------------------------------------- */
module Global{

    /*    --------------------------------------------------- *\
            [function] getScreenSize()
    
            * Return the screen size *
    
            Return: screenX, screenY
    \*    --------------------------------------------------- */
    export function getScreenSize(){
        return { width: window.innerWidth, height: window.innerHeight };
    }

	/*	--------------------------------------------------- *\
			[function] getDistanceBetween2Points(xA, xB, yA, yB)
	
			* Retourne la distance entre deux points *
	
			Return: distance
	\*	--------------------------------------------------- */
	export function getDistanceBetween2Points(aX : number, aY : number, bX : number, bY : number):number{
		return Math.sqrt(Math.pow((bY - aY), 2) + Math.pow((bX - aX), 2));
	}

    /*    --------------------------------------------------- *\
            [function] getPositionFromScreen(screeX, screenY, cam)
    
            * Retourne une position dans le world selon la position sur l'écran *
    
            Return: position
    \*    --------------------------------------------------- */
    export function getPositionFromScreen(screenX, screenY, cam){
        var camPosition = cam.getOrigin();
        var actual = { x: camPosition.x + screenX, y: camPosition.y + screenY };
        var p = {x: actual.x, y: actual.y};
        return { x: p.x, y: p.y };
    }

    /*    --------------------------------------------------- *\
            [function] getPositionFromWorld(worldX, worldY, cam)
    
            * Retourne une position dans le screen selon la position sur le world *
    
            Return: position
    \*    --------------------------------------------------- */
    export function getPositionFromWorld(worldX, worldY, cam){
        var camPosition = cam.getOrigin();
        return { x: worldX - camPosition.x, y: worldY - camPosition.y};
    }

    /*    --------------------------------------------------- *\
            [function] findRotation(x, y, x, y)
    
            * Find the rotation between two points *
    
            Return: rotation
    \*    --------------------------------------------------- */
    export function findRotation(x1,y1,x2,y2){
        var t = -(Math.atan2(x2 - x1, y2 - y1) * (180/Math.PI));
        if(t < 0){
            t += 360;
        }

        return t;
    }

    /*    --------------------------------------------------- *\
            [function] getRandom(min, max)
    
            * Retourne un nombre random entre min & max *
    
            Return: number
    \*    --------------------------------------------------- */
    export function getRandom(min : number, max : number):number{
        return Math.random() * (max - min) + min;
    }

    /*    --------------------------------------------------- *\
            [function] getTrunc(x)
    
            * Retourne une valeur tronqué d'un nombre décimal *
    
            Return: number
    \*    --------------------------------------------------- */
    export function getTrunc(x : number):number {
        return x < 0 ? Math.ceil(x) : Math.floor(x);
    }

    /*    --------------------------------------------------- *\
            [function] isAndroid()
    
            * Check si on tourne sous Android ou non *
    
            Return: true, false
    \*    --------------------------------------------------- */
    export function isAndroid(){
        // Using Cordova element instead
        if(window.hasOwnProperty("cordova")){
            if(window['cordova'].platformId == "android"){
                return true;
            }
            else{
                return false;
            }
        }
        else{
            return false;
        }
    } 
{'fraction_non_alphanumeric': 0.32819383259911894, 'fraction_numerical': 0.005441824306815237, 'mean_word_length': 0.8753644314868805, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5727005', 'n_tokens_mistral': 1893, 'n_tokens_neox': 1811, 'n_words': 468}