File: point.go

package info (click to toggle)
golang-github-fogleman-gg 1.3.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 956 kB
  • sloc: makefile: 3
file content (25 lines) | stat: -rw-r--r-- 378 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package gg

import (
	"math"

	"golang.org/x/image/math/fixed"
)

type Point struct {
	X, Y float64
}

func (a Point) Fixed() fixed.Point26_6 {
	return fixp(a.X, a.Y)
}

func (a Point) Distance(b Point) float64 {
	return math.Hypot(a.X-b.X, a.Y-b.Y)
}

func (a Point) Interpolate(b Point, t float64) Point {
	x := a.X + (b.X-a.X)*t
	y := a.Y + (b.Y-a.Y)*t
	return Point{x, y}
}