spherical2cartesian

Converts a set of spherical coordinates into cartesian.
Author: Sputnki
License: BSD
Github: sptnk/math/spherical2cartesian.axo

Inlets

frac32 radius

frac32 inclination: angle with the z axis (0 = 0 degrees; 64 = 180 degrees)

frac32 azimuth: angle with the x axis on the xy projection (0 = 0 degrees; 64 = 360 degrees)

Outlets

frac32 x coordinate

frac32 y coordinate

frac32 z coordinate

Control Rate
int32_t sintheta;
int32_t costheta;
int32_t sinphi;
int32_t cosphi;

SINE2TINTERP((inlet_theta << 4) + (1 << 30), costheta);
SINE2TINTERP(inlet_theta << 4, sintheta);
SINE2TINTERP((inlet_phi << 5) + (1 << 30), cosphi);
SINE2TINTERP(inlet_phi << 5, sinphi);

outlet_x = ___SMMUL(inlet_radius << 2, ___SMMUL(sintheta, cosphi));
outlet_y = ___SMMUL(inlet_radius << 2, ___SMMUL(sintheta, sinphi));
outlet_z = ___SMMUL(inlet_radius << 1, costheta);

Privacy

© 2024 Zrna Research