MCPcopy Create free account
hub / github.com/ThatOpen/engine_clay / getNormal

Method getNormal

packages/clay/src/utils/vector.ts:14–23  ·  view source on GitHub ↗
(points: number[][])

Source from the content-addressed store, hash-verified

12 }
13
14 static getNormal(points: number[][]) {
15 const a = Vector.subtract(points[0], points[1]);
16 const b = Vector.subtract(points[1], points[2]);
17
18 const [x, y, z] = this.multiply(a, b);
19
20 const magnitude = Math.sqrt(x * x + y * y + z * z);
21
22 return [x / magnitude, y / magnitude, z / magnitude];
23 }
24
25 static dot(v1: number[], v2: number[]) {
26 return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];

Callers

nothing calls this directly

Calls 2

multiplyMethod · 0.95
subtractMethod · 0.80

Tested by

no test coverage detected