MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / normalize

Method normalize

src/common/overlay/levelRenderer/Vector.js:195–205  ·  view source on GitHub ↗

* @function LevelRenderer.Tool.Vector.prototype.normalize * @description 向量归一化。 * * @param {Vector2} out - 基础向量。 * @param {Vector2} v - 向量 v。 * @return {Vector2} 结果。

(out, v)

Source from the content-addressed store, hash-verified

193 * @return {Vector2} 结果。
194 */
195 normalize(out, v) {
196 var d = this.len(v);
197 if (d === 0) {
198 out[0] = 0;
199 out[1] = 0;
200 } else {
201 out[0] = v[0] / d;
202 out[1] = v[1] / d;
203 }
204 return out;
205 }
206
207 /**
208 * @function LevelRenderer.Tool.Vector.prototype.distance

Callers

nothing calls this directly

Calls 1

lenMethod · 0.95

Tested by

no test coverage detected