MCPcopy Create free account
hub / github.com/SolarLune/masterplan / Unit

Method Unit

utils.go:215–223  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

213}
214
215func (point Vector) Unit() Vector {
216 l := point.Magnitude()
217 if l < 1e-8 || l == 1 {
218 // If it's 0, then don't modify the vector
219 return point
220 }
221 point.X, point.Y = point.X/l, point.Y/l
222 return point
223}
224
225func (point Vector) IsZero() bool {
226 return point.X == 0 && point.Y == 0

Callers 1

ThickLineFunction · 0.80

Calls 1

MagnitudeMethod · 0.95

Tested by

no test coverage detected