示例#1
0
文件: math.go 项目: matiwinnetou/engi
// Returns the unit vector from a, and it's magnitude
func (a *Point) Normalize() (Point, float32) {
	mag := math.Sqrt(a.X*a.X + a.Y*a.Y)
	unit := Point{a.X / mag, a.Y / mag}

	return unit, mag
}
示例#2
0
文件: math.go 项目: matiwinnetou/engi
// Returns the squared euclidean distance from a point to a line *segment*
func (l *Line) PointDistance(point Point) float32 {
	return math.Sqrt(l.PointDistanceSquared(point))
}
示例#3
0
文件: math.go 项目: matiwinnetou/engi
func (p *Point) PointDistance(p2 Point) float32 {
	return math.Sqrt(p.PointDistanceSquared(p2))
}