MCPcopy Create free account
hub / github.com/axmolengine/axmol / normalize

Method normalize

core/math/Vec2.cpp:162–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160}
161
162void Vec2::normalize()
163{
164 float n = x * x + y * y;
165 // Already normalized.
166 if (n == 1.0f)
167 return;
168
169 n = std::sqrt(n);
170 // Too close to zero.
171 if (n < MATH_TOLERANCE)
172 return;
173
174 n = 1.0f / n;
175 x *= n;
176 y *= n;
177}
178
179Vec2 Vec2::getNormalized() const
180{

Callers 1

getNormalizedMethod · 0.45

Calls 1

sqrtFunction · 0.50

Tested by

no test coverage detected