MCPcopy Create free account
hub / github.com/microsoft/SandDance / angle

Function angle

docs/app/js/sanddance-app.js:70032–70037  ·  view source on GitHub ↗
(a, b)

Source from the content-addressed store, hash-verified

70030 return out;
70031}
70032function angle(a, b) {
70033 var x1 = a[0], y1 = a[1], x2 = b[0], y2 = b[1], // mag is the product of the magnitudes of a and b
70034 mag = Math.sqrt(x1 * x1 + y1 * y1) * Math.sqrt(x2 * x2 + y2 * y2), // mag &&.. short circuits if mag == 0
70035 cosine = mag && (x1 * x2 + y1 * y2) / mag; // Math.min(Math.max(cosine, -1), 1) clamps the cosine between -1 and 1
70036 return Math.acos(Math.min(Math.max(cosine, -1), 1));
70037}
70038function zero(out) {
70039 out[0] = 0.0;
70040 out[1] = 0.0;

Callers 3

linePointFunction · 0.70
sanddance-app.jsFile · 0.70
azimuthalInvertFunction · 0.70

Calls 3

dotFunction · 0.70
minMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected