<commit_before>// Copyright 2014 <NAME>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package twodee

import (
	"math"
)

type Point struct {
	X float32
	Y float32
}

func Pt(x, y float32) Point {
	return Point{x, y}
}

func (p Point) Scale(a float32) Point {
	return Point{p.X * a, p.Y * a}
}

func (p Point) Add(pt Point) Point {
	return Point{p.X + pt.X, p.Y + pt.Y}
}

func (p Point) DistanceTo(pt Point) float32 {
	var (
		dx = float64(pt.X - p.X)
		dy = float64(pt.Y - p.Y)
	)
	return float32(math.Sqrt(dx*dx + dy*dy))
}

type Rectangle struct {
	Min Point
	Max Point
}

func Rect(x1, y1, x2, y2 float32) Rectangle {
	return Rectangle{
		Min: Pt(x1, y1),
		Max: Pt(x2, y2),
	}
}

func (r Rectangle) Overlaps(s Rectangle) bool {
	return s.Min.X < r.Max.X && s.Max.X > r.Min.X &&
		s.Min.Y < r.Max.Y && s.Max.Y > r.Min.Y
}

// Returns true if r is intersection by the line a, b.
func (r Rectangle) IntersectedBy(a, b Point) bool {<commit_msg>Add a subtraction function for points.<commit_after>// Copyright 2014 <NAME>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package twodee

import (
	"math"
)

type Point struct {
	X float32
	Y float32
}

func Pt(x, y float32) Point {
	return Point{x, y}
}

func (p Point) Scale(a float32) Point {
	return Point{p.X * a, p.Y * a}
}

func (p Point) Add(pt Point) Point {
	return Point{p.X + pt.X, p.Y + pt.Y}
}

// Subtracts pt from p.
func (p Point) Sub(pt Point) Point {
	return Point{p.X - pt.X, p.Y - pt.Y}
}

func (p Point) DistanceTo(pt Point) float32 {
	var (
		dx = float64(pt.X - p.X)
		dy = float64(pt.Y - p.Y)
	)
	return float32(math.Sqrt(dx*dx + dy*dy))
}

type Rectangle struct {
	Min Point
	Max Point
}

func Rect(x1, y1, x2, y2 float32) Rectangle {
	return Rectangle{
		Min: Pt(x1, y1),
		Max: Pt(x2, y2),
	}
}

func (r Rectangle) Overlaps(s Rectangle) bool {
	return s.Min.X < r.Max.X && s.Max.X > r.Min.X &&
		s.Min.Y < r.Max.Y && s.Max.Y > r.Min.Y
}

// Returns true if r is intersection by the line a, b.
func (r Rectangle) IntersectedBy(a, b Point) bool {
{'fraction_non_alphanumeric': 0.1297208538587849, 'fraction_numerical': 0.02233169129720854, 'mean_word_length': 3.0940860215053765, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5120334', 'n_tokens_mistral': 1164, 'n_tokens_neox': 1111, 'n_words': 408}