<commit_before>//
//  vec2.swift
//  SwiftVector
//
//  Created by <NAME> on 10/5/14.
//  Copyright (c) 2014 SoFIE Studios. All rights reserved.
//

import UIKit

/// 2 Dimensional vector structure with simple vector operations. Operations that manipulate the
/// vector return a new vector.
public struct vec2: Equatable, Printable {
  public let x: Double
  public let y: Double

  // For purposes of comparisons and scaling operations, any magnitude less than this value is
  // considered to be 0. Note: it's not a good idea to use this value directly when comparing
  // (e.g. fabs(a - b) < EPSILON). See http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
  // for more info.
  internal let EPSILON = 1.0e-14;

  public var asCGVector: CGVector {
    get {
      return CGVector(dx: x, dy: y)
    }
  }

  public var length: Double {
    get {
      return sqrt(x*x + y*y)
    }
  }

  public var angle: Double {
    return atan2(y, x)
  }

  public var angleDegrees: Double {
    return self.angle * 180 / M_PI
  }

  public var description: String {
    return "(\(x),\(y))"
  }

  /// Initialize the vector with  a pair of doubles
  ///
  ///  :param: x The x value
  ///  :param: y The y value
  ///
  public init(_ x: Double, _ y:Double) {
    self.x = x;
    self.y = y;
  }

  /// Create a vector which represents the offset between two points. The magnitude
  /// of the vector will be the distance between the points and the direction will
  /// be the direction from the first to the second.
  ///
  ///  :param: from The starting point
  ///  :param: to   The end point
  ///
  public init(from p1: CGPoint, to p2: CGPoint) {
    x = Double(p2.x - p1.x)
    y = Double(p2.y - p1.y)
  }

  public init(vector v:CGVector) {
    self.x = Double(v.dx)
    self.y = Double(v.dy)
  }<commit_msg>Update vec2.swift<commit_after>//
//  vec2.swift
//  SwiftVector
//
//  Created by <NAME> on 10/5/14.
//  Copyright (c) 2014 SoFIE Studios. All rights reserved.
//

import UIKit

/// 2 Dimensional vector structure with simple vector operations. Operations that manipulate the
/// vector return a new vector.
public struct vec2: Equatable, Printable {
  public let x: Double
  public let y: Double

  // For purposes of comparisons and scaling operations, any magnitude less than this value is
  // considered to be 0. Note: it's not a good idea to use this value directly when comparing
  // (e.g. fabs(a - b) < EPSILON). See http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
  // for more info.
  internal let EPSILON = 1.0e-14;

  public var asCGVector: CGVector {
    get {
      return CGVector(dx: x, dy: y)
    }
  }

  public var length: Double {
    get {
      return sqrt(x*x + y*y)
    }
  }

  public var angle: Double {
    return atan2(y, x)
  }

  public var angleDegrees: Double {
    return self.angle * 180 / M_PI
  }

  public var description: String {
    return "(\(x),\(y))"
  }

  /// Initialize the vector with  a pair of doubles
  ///
  ///  :param: x The x value
  ///  :param: y The y value
  ///
  public init(_ x: Double, _ y:Double) {
    self.x = x;
    self.y = y;
  }

  /// Create a vector which represents the offset between two points. The magnitude
  /// of the vector will be the distance between the points and the direction will
  /// be the direction from the first to the second.
  ///
  ///  :param: from The starting point
  ///  :param: to   The end point
  ///
  public init(from p1: CGPoint, to p2: CGPoint) {
    x = Double(p2.x - p1.x)
    y = Double(p2.y - p1.y)
  }

  /// Create a vector from a CGVector.
  ///
  /// :param: vector the CGVector
  ///
  public init(vector v:CGVector) {
    self.x = Double(v.dx)
    self.y = Double(v.dy)
  }
{'fraction_non_alphanumeric': 0.11909212283044059, 'fraction_numerical': 0.014686248331108143, 'mean_word_length': 2.3209219858156027, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3810943', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1232, 'n_words': 457}