Skip to content

Commit be9e9b5

Browse files
authored
Merge pull request #430 from munsocket/master
Optimize angle(v1, v2)
2 parents fccd5f7 + 07e80bf commit be9e9b5

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/vec3.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -675,9 +675,7 @@ export function angle(a, b) {
675675
bx = b[0],
676676
by = b[1],
677677
bz = b[2],
678-
mag1 = Math.sqrt(ax * ax + ay * ay + az * az),
679-
mag2 = Math.sqrt(bx * bx + by * by + bz * bz),
680-
mag = mag1 * mag2,
678+
mag = Math.sqrt((ax * ax + ay * ay + az * az) * (bx * bx + by * by + bz * bz)),
681679
cosine = mag && dot(a, b) / mag;
682680
return Math.acos(Math.min(Math.max(cosine, -1), 1));
683681
}

0 commit comments

Comments
 (0)