MCPcopy Create free account
hub / github.com/ByteArena/box2d / Normalize

Method Normalize

CommonB2Math.go:117–130  ·  view source on GitHub ↗

Convert this vector into a unit vector. Returns the length.

()

Source from the content-addressed store, hash-verified

115
116/// Convert this vector into a unit vector. Returns the length.
117func (v *B2Vec2) Normalize() float64 {
118
119 length := v.Length()
120
121 if length < B2_epsilon {
122 return 0.0
123 }
124
125 invLength := 1.0 / length
126 v.X *= invLength
127 v.Y *= invLength
128
129 return length
130}
131
132/// Does this vector contain finite coordinates?
133func (v B2Vec2) IsValid() bool {

Callers 15

B2DistanceFunction · 0.45
InitializeMethod · 0.45
B2TimeOfImpactFunction · 0.45
SolveC2Method · 0.45
MakeB2PrismaticJointFunction · 0.45
InitializeMethod · 0.45
B2CollidePolygonsFunction · 0.45
SetMethod · 0.45
RayCastMethod · 0.45
InitializeMethod · 0.45

Calls 1

LengthMethod · 0.95

Tested by

no test coverage detected