ichigo/geom/misc.go

26 lines
648 B
Go
Raw Normal View History

2021-09-08 20:08:57 +10:00
package geom
import "image"
// ---------- Some helpers for image.Point ----------
// CMul performs componentwise multiplication of two image.Points.
func CMul(p, q image.Point) image.Point {
return image.Point{p.X * q.X, p.Y * q.Y}
}
// CDiv performs componentwise division of two image.Points.
func CDiv(p, q image.Point) image.Point {
return image.Point{p.X / q.X, p.Y / q.Y}
}
// CFloat returns the components of an image.Point as two floats.
func CFloat(p image.Point) (x, y float64) {
return float64(p.X), float64(p.Y)
}
// Dot returns the Dot product of two image.Points.
func Dot(p, q image.Point) int {
return p.X*q.X + p.Y*q.Y
}