File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+
12export function isArray ( arr ) {
23 return Array . isArray ( arr ) || ArrayBuffer . isView ( arr ) ;
34}
5+
6+ export function multQuatVec ( quat , vec ) {
7+ const {
8+ x, y, z
9+ } = vec ;
10+ const {
11+ x : qx , y : qy , z : qz , w : qw
12+ } = quat ;
13+
14+ const ix = qw * x + qy * z - qz * y ;
15+ const iy = qw * y + qz * x - qx * z ;
16+ const iz = qw * z + qx * y - qy * x ;
17+ const iw = - qx * x - qy * y - qz * z ;
18+ const rx = ix * qw + iw * - qx + iy * - qz - iz * - qy ;
19+ const ry = iy * qw + iw * - qy + iz * - qx - ix * - qz ;
20+ const rz = iz * qw + iw * - qz + ix * - qy - iy * - qx ;
21+ return new vec . constructor ( rx , ry , rz ) ;
22+ }
23+
24+ const angle180 = Math . PI ;
25+ const angle360 = Math . PI * 2 ;
26+
27+ export function normRad ( angle ) {
28+ let mod = angle % angle360 ;
29+ if ( mod < - angle180 ) {
30+ mod += angle360 ;
31+ } else if ( mod > angle180 ) {
32+ mod -= angle360 ;
33+ }
34+ return mod ;
35+ }
You can’t perform that action at this time.
0 commit comments