<commit_before>/*
 * Project ariana
 * File: draw.ts
 * Author: <NAME>
 * Date: June 3th, 2015
 * Description: this file contains a class to draw lines on a canvas.
 */

/*
 * Position2D class for addressing a point in the draw canvas.
 * TODO: pointInDirection should check if the distance != zero etc
 */
class Position2D {
    constructor (public x : number, public y : number) {

    }

    distanceTo (otherpoint : Position2D) : number {
        return Math.sqrt(Math.pow( otherpoint.x - this.x, 2) + Math.pow(otherpoint.y - this.y, 2));  
    }

    angleWith (otherpoint : Position2D) : number {
        return Math.atan2(otherpoint.x - this.x, otherpoint.y - this.y);
    }

    pointInDirection (otherpoint : Position2D, distance : number) : Position2D {
        var dx : number = otherpoint.x - this.x;
        var dy : number = otherpoint.y - this.y;

        var origDistance : number = this.distanceTo(otherpoint);

        if (distance == origDistance) {
            return otherpoint;
        }

        var fraction : number = distance / origDistance;

        var newX : number = this.x + fraction * dx;
        var newY : number = this.y + fraction * dy;

        return new Position2D(newX, newY);

    }<commit_msg>check if distance to other point is not zero<commit_after>/*
 * Project ariana
 * File: draw.ts
 * Author: <NAME>
 * Date: June 3th, 2015
 * Description: this file contains a class to draw lines on a canvas.
 */

/*
 * Position2D class for addressing a point in the draw canvas.
 */
class Position2D {
    constructor (public x : number, public y : number) {

    }

    distanceTo (otherpoint : Position2D) : number {
        return Math.sqrt(Math.pow( otherpoint.x - this.x, 2) + Math.pow(otherpoint.y - this.y, 2));  
    }

    angleWith (otherpoint : Position2D) : number {
        return Math.atan2(otherpoint.x - this.x, otherpoint.y - this.y);
    }

    pointInDirection (otherpoint : Position2D, distance : number) : Position2D {
        var dx : number = otherpoint.x - this.x;
        var dy : number = otherpoint.y - this.y;

        var origDistance : number = this.distanceTo(otherpoint);

        if (distance == origDistance) {
            return otherpoint;
        }
        if (distance == 0.0) {
            return otherpoint;
        }

        var fraction : number = distance / origDistance;

        var newX : number = this.x + fraction * dx;
        var newY : number = this.y + fraction * dy;

        return new Position2D(newX, newY);

    }
{'fraction_non_alphanumeric': 0.10853950518754989, 'fraction_numerical': 0.012769353551476457, 'mean_word_length': 2.3249336870026527, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1536743', 'n_tokens_mistral': 781, 'n_tokens_neox': 744, 'n_words': 240}