rot 3d

Rotates a 3d coordinate by an angle theta.
Author: Sputnki
License: BSD
Github: sptnk/math/rot 3d.axo

Inlets

frac32 angle of rotation (64 = 2pi)

frac32buffer x

frac32buffer y

frac32buffer z

Outlets

frac32buffer x

frac32buffer y

frac32buffer z

Parameters

frac32.s.map angle of rotation (64 = 2pi)

Attributes

combo rotation axis

Declaration
void rotate(int32_t x, int32_t y, int32_t z, int32_t costheta, int32_t sintheta,
            int32_t *x_out, int32_t *y_out, int32_t *z_out) {
#if (attr_axis == 0) // rotation around x
  *x_out = x;
  *y_out = ___SMMLA(y, costheta, ___SMMUL(z, -sintheta)) << 1;
  *z_out = ___SMMLA(y, sintheta, ___SMMUL(z, costheta)) << 1;
#elif (attr_axis == 1) // rotation around y
  *x_out = ___SMMLA(x, costheta, ___SMMUL(z, sintheta)) << 1;
  *y_out = y;
  *z_out = ___SMMLA(x, -sintheta, ___SMMUL(z, costheta)) << 1;
#elif (attr_axis == 2) // rotation around z
  *x_out = ___SMMLA(x, costheta, ___SMMUL(y, -sintheta)) << 1;
  *y_out = ___SMMLA(x, sintheta, ___SMMUL(y, costheta)) << 1;
  *z_out = z;
#endif
}
Control Rate
int32_t costheta;
int32_t sintheta;
SINE2TINTERP((inlet_theta + param_theta << 5) + (1 << 30), costheta);
SINE2TINTERP((inlet_theta + param_theta << 5), sintheta);
Audio Rate
rotate(inlet_x, inlet_y, inlet_z, costheta, sintheta, &outlet_x, &outlet_y,
       &outlet_z);

Privacy

© 2024 Zrna Research