MCPcopy
hub / github.com/g3n/engine / DistanceToPoint

Method DistanceToPoint

math32/box2.go:190–195  ·  view source on GitHub ↗

DistanceToPoint returns the distance from this box to the specified point.

(point *Vector2)

Source from the content-addressed store, hash-verified

188
189// DistanceToPoint returns the distance from this box to the specified point.
190func (b *Box2) DistanceToPoint(point *Vector2) float32 {
191
192 v1 := NewVector2(0, 0)
193 clampedPoint := v1.Copy(point).Clamp(&b.min, &b.max)
194 return clampedPoint.Sub(point).Length()
195}
196
197// Intersect sets this box to the intersection with other box.
198// Returns pointer to this updated bounding box.

Callers

nothing calls this directly

Calls 5

CopyMethod · 0.95
NewVector2Function · 0.85
ClampMethod · 0.45
LengthMethod · 0.45
SubMethod · 0.45

Tested by

no test coverage detected