// Normalize normalizes the vector. func (v Vec3) Normalize() { d := 1.0 / math32.Sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]) v[0] *= d v[1] *= d v[2] *= d }
// Dist2D derives the distance between v and v2 on the xz-plane. // // The vectors are projected onto the xz-plane, so the y-values are ignored. func (v Vec3) Dist2D(v1 Vec3) float32 { dx := v1[0] - v[0] dz := v1[2] - v[2] return math32.Sqrt(dx*dx + dz*dz) }
// LenSqr derives the scalar scalar length of the vector. (len) func (v Vec3) Len() float32 { return math32.Sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]) }
// Dist returns the distance between v and v1. d = dist(v, v2) func (v Vec3) Dist(v1 Vec3) float32 { dx := v1[0] - v[0] dy := v1[1] - v[1] dz := v1[2] - v[2] return math32.Sqrt(dx*dx + dy*dy + dz*dz) }
// Dist returns the distance between v and v1. d = dist(v, v2) func (v Vec2) Dist(v1 Vec2) float32 { dx := v1[0] - v[0] dy := v1[1] - v[1] return math32.Sqrt(dx*dx + dy*dy) }