MCPcopy
hub / github.com/yeemachine/kalidokit / distance

Method distance

src/utils/vector.ts:110–115  ·  view source on GitHub ↗

* Find the distance between this and another vector. * @param {Vector} v: Vector to find distance to * @param {2 | 3} d: 2D or 3D distance * @returns {number} Distance

(v: Vector, d: 2 | 3 = 3)

Source from the content-addressed store, hash-verified

108 * @returns {number} Distance
109 */
110 distance(v: Vector, d: 2 | 3 = 3) {
111 //2D distance
112 if (d === 2) return Math.sqrt(Math.pow(this.x - v.x, 2) + Math.pow(this.y - v.y, 2));
113 //3D distance
114 else return Math.sqrt(Math.pow(this.x - v.x, 2) + Math.pow(this.y - v.y, 2) + Math.pow(this.z - v.z, 2));
115 }
116 /**
117 * Lerp between this vector and another vector.
118 * @param {Vector} v: Vector to lerp to

Callers 5

pupilPosFunction · 0.95
calcMouthFunction · 0.95
calcHeadFunction · 0.80
eyeLidRatioFunction · 0.80
calcHipsFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected