<commit_before>//
//  CGPoint+Ruler.swift
//  SwiftGraphics
//
//  Created by <NAME> <https://github.com/rhcad> on 15/1/14.
//  Copyright (c) 2014 schwa.io. All rights reserved.
//

import CoreGraphics


// MARK: Relative point calculation methods like ruler tools

public extension CGPoint {
    /**
     * Calculate a point along the direction from this point to 'dir' point.
     *
     * @param dir the direction point.
     * @param dx the distance from this point to the result point.
     *           The negative value represents along the opposite direction.
     *
     * @return the point relative to this point.
     */
    func rulerPoint(dir:CGPoint, dx:CGFloat) -> CGPoint {
        let len = distanceTo(dir)
        if len == 0 {
            return CGPoint(x:x + dx, y:y)
        }
        let d = dx / len<commit_msg>Add polarPoint() of CGPoint.<commit_after>//
//  CGPoint+Ruler.swift
//  SwiftGraphics
//
//  Created by <NAME> <https://github.com/rhcad> on 15/1/14.
//  Copyright (c) 2014 schwa.io. All rights reserved.
//

import CoreGraphics


// MARK: Relative point calculation methods like ruler tools

public extension CGPoint {
    
    /**
     * Calculate a point with polar angle and radius based on this point.
     *
     * @param angle polar angle in radians.
     * @param radius the length of the polar radius
     *
     * @return the point relative to this point.
     */
    func polarPoint(angle:CGFloat, radius:CGFloat) -> CGPoint {
        return CGPoint(x: x + radius * cos(angle), y: y + radius * sin(angle));
    }
    
    /**
     * Calculate a point along the direction from this point to 'dir' point.
     *
     * @param dir the direction point.
     * @param dx the distance from this point to the result point.
     *           The negative value represents along the opposite direction.
     *
     * @return the point relative to this point.
     */
    func rulerPoint(dir:CGPoint, dx:CGFloat) -> CGPoint {
        let len = distanceTo(dir)
        if len == 0 {
            return CGPoint(x:x + dx, y:y)
        }
        let d = dx / len
{'fraction_non_alphanumeric': 0.10181644359464627, 'fraction_numerical': 0.009560229445506692, 'mean_word_length': 2.1760242792109254, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, 'https://': 2, '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': '6253704', 'n_tokens_mistral': 648, 'n_tokens_neox': 605, 'n_words': 228}