100+ results for 'quaternion'
Not the results you expected?
SkyBox.ec (https://github.com/redj/ecere-sdk.git) C · 215 lines
axisRotationMotion.C (https://gitlab.com/johnvarv/OpenFOAM-3.0.x) C · 108 lines
anim_keyread.c (https://bitbucket.org/vrrm/brl-cad-copy-for-fast-history-browsing-in-git.git) C · 167 lines
26 * The output table specifies the orientation in one of three ways:
27 *
28 * default - quaternions in the order x, y, z, w.
29 *
30 * -z option - Eulers angles, in the order xyz. The model axes are
53 #define YPR 0
54 #define XYZ 1
55 #define QUATERNION 2
57 #define DEGREES 0
73 int c;
75 mode = QUATERNION; /* default */
76 units = DEGREES;
colorSpheres.ec (https://github.com/redj/ecere-sdk.git) C · 228 lines
cpx_vec.c (https://gitlab.com/oytunistrator/QuIP) C · 389 lines
181 #ifdef QUATERNION_SUPPORT
183 /* Quaternions */
233 ASSIGN_QUAT(qdst,tmpq) )
235 // Quaternion division is like complex division: q1 / q2 = q1 * conj(q2) / maqsq(q2)
236 // Conjugation negates all three imaginary components...
271 /* float times quaternion */
273 // These appear to have a quaternion destination, but a real source,
ext-script.c (https://github.com/deldiablo/GodheadLips.git) C · 214 lines
87 module = liscr_script_get_userdata (args->script, LIEXT_SCRIPT_SOUND);
88 liscr_args_seti_quaternion (args, &module->listener_rotation);
89 }
90 static void Sound_set_listener_rotation (LIScrArgs* args)
91 {
92 LIExtModule* module;
93 LIMatQuaternion value;
95 if (liscr_args_geti_quaternion (args, 0, &value))
surfaceTransformPoints.C (https://gitlab.com/johnvarv/OpenFOAM-3.0.x) C · 198 lines
44 #include "transformField.H"
45 #include "Pair.H"
46 #include "quaternion.H"
47 #include "mathematicalConstants.H"
150 v *= pi/180.0;
152 quaternion R(v.x(), v.y(), v.z());
154 Info<< "Rotating points by quaternion " << R << endl;
170 scalar roll = v.z();
172 quaternion R = quaternion(vector(0, 0, 1), yaw);
173 R *= quaternion(vector(0, 1, 0), pitch);
174 R *= quaternion(vector(1, 0, 0), roll);
176 Info<< "Rotating points by quaternion " << R << endl;
stabilization_attitude_ref_quat_float.c (https://bitbucket.org/tamasszabo/paparazzi_mavlink.git) C · 151 lines
24 *
25 * Rotorcraft attitude reference generation.
26 * (quaternion float version)
27 *
28 */
100 #define DT_UPDATE (1./PERIODIC_FREQUENCY)
102 // default to fast but less precise quaternion integration
103 #ifndef STABILIZATION_ATTITUDE_REF_QUAT_INFINITESIMAL_STEP
104 #define STABILIZATION_ATTITUDE_REF_QUAT_INFINITESIMAL_STEP TRUE
116 struct FloatQuat delta_q;
117 FLOAT_QUAT_DIFFERENTIAL(delta_q, stab_att_ref_rate, DT_UPDATE);
118 /* compose new ref_quat by quaternion multiplication of delta rotation and current ref_quat */
119 struct FloatQuat new_ref_quat;
120 FLOAT_QUAT_COMP(new_ref_quat, delta_q, stab_att_ref_quat);
script-args.c (https://github.com/deldiablo/GodheadLips.git) C · 1144 lines
297 return 0;
298 index += self->args_start;
299 tmp = liscr_isdata (self->lua, index, LISCR_SCRIPT_QUATERNION);
300 if (tmp != NULL)
301 *result = *((LIMatQuaternion*) tmp->data);
830 if (self->output_mode != LISCR_ARGS_OUTPUT_TABLE)
831 {
832 quat = liscr_data_new_alloc (self->script, self->lua, sizeof (LIMatQuaternion), LISCR_SCRIPT_QUATERNION);
833 if (quat != NULL)
834 {
845 }
846 lua_pushnumber (self->lua, ++self->ret);
847 quat = liscr_data_new_alloc (self->script, self->lua, sizeof (LIMatQuaternion), LISCR_SCRIPT_QUATERNION);
848 if (quat != NULL)
849 {
anim_keyread.c (https://bitbucket.org/vrrm/brl-cad-copy-for-fast-history-browsing-in-git.git) C · 156 lines
6 * The output table specifies the orientation in one of three ways:
7 *
8 * default - quaternions in the order x, y, z, w.
9 *
10 * -z option - Eulers angles, in the order xyz. The model axes are
45 #define YPR 0
46 #define XYZ 1
47 #define QUATERNION 2
49 #define DEGREES 0
113 printf("%f\t%f\t%f\n",angle[X],angle[Y],angle[Z]);
114 }
115 else if (mode==QUATERNION){
116 mat2quat(quat,viewrot);
117 printf("%f\t%f\t%f\t%f\n",quat[X],quat[Y],quat[Z],quat[W]);
tabulated6DoFMotion.C (https://gitlab.com/johnvarv/OpenFOAM-3.0.x) C · 174 lines
ahrs_float_ekf.c (https://bitbucket.org/tamasszabo/paparazzi_mavlink.git) C · 164 lines
32 /* maintains a rotation matrix representation */
33 struct FloatEulers bafe_dcm;
34 /* time derivative of our quaternion */
35 struct FloatQuat bafe_qdot;
66 * Q is our estimate noise variance. It is supposed to be an NxN
67 * matrix, but with elements only on the diagonals. Additionally,
68 * since the quaternion has no expected noise (we can't directly measure
69 * it), those are zero. For the gyro, we expect around 5 deg/sec noise,
70 * which is 0.08 rad/sec. The variance is then 0.08^2 ~= 0.0075.
98 * bias_dot = 0
99 *
100 * Wxq is the quaternion omega matrix:
101 *
102 * [ 0, -p, -q, -r ]
vectbl.c (https://gitlab.com/oytunistrator/QuIP) C · 507 lines
tstack.c (https://github.com/josephzizys/plan-9.git) C · 169 lines
5 * t=popmat(t) pop matrix stack
6 * rot(t, a, axis) multiply stack top by rotation
7 * qrot(t, q) multiply stack top by rotation, q is unit quaternion
8 * scale(t, x, y, z) multiply stack top by scale
9 * move(t, x, y, z) multiply stack top by translation
54 ixform(t, m, inv);
55 }
56 void qrot(Space *t, Quaternion q){
57 Matrix m, inv;
58 int i, j;
septernion.C (https://github.com/xyuan/OpenFOAM-1.7.x.git) C · 83 lines
evas_3d_node.c (https://bitbucket.org/hchbaw/efl.git) C · 1460 lines
102 if (pd->orientation_inherit)
103 {
104 evas_vec4_quaternion_multiply(&pd->orientation_world,
105 orientation_parent, &pd->orientation);
106 }
120 {
121 evas_vec3_multiply(&pd->position_world, &pd->position, scale_parent);
122 evas_vec3_quaternion_rotate(&pd->position_world, &pd->position_world,
123 orientation_parent);
124 evas_vec3_add(&pd->position_world, &pd->position_world,
265 Evas_Vec3 rotate;
266 evas_vec3_set(&rotate, minmaxdata[0], minmaxdata[1], minmaxdata[2]);
267 evas_vec3_quaternion_rotate(&rotate, &rotate, &orientation);
268 vxmax = vxmin = minmaxdata[0] = rotate.x;
269 vymax = vymin = minmaxdata[1] = rotate.y;
quat.c (https://github.com/shadoof/CW2.git) C · 392 lines
Vector3D.ec (https://github.com/redj/ecere-sdk.git) C · 365 lines
param_parser.c (https://github.com/rhuitl/uClinux.git) C · 232 lines
test_vec.c (https://github.com/golems/amino.git) C · 161 lines
ahrs_quat_ukf.c (https://bitbucket.org/tamasszabo/paparazzi_mavlink.git) C · 123 lines
serial_bird.c (https://github.com/pd-l2ork/pd.git) C · 265 lines
sharpr.c (https://github.com/mattbornski/spice.git) C · 164 lines
100 /* Suppose that you have a rotation matrix that needs to be */
101 /* converted to a quaternion. The SPICE matrix to quaternion */
102 /* conversion routine M2Q performs error checks on the input */
103 /* matrix and signals an error if it does not meet the checks */
104 /* for a quaternion. By calling this routine you can ensure that */
105 /* your rotation matrix (provided it's non-singular) will pass */
106 /* the restrictions imposed by M2Q. */
vMath.c (https://github.com/vyasa/asteria.git) C · 184 lines
84 /* Dot product of 3D components, the scalar component of the intermediate *
85 * quaternion. */
86 GLfloat dot = -v3Dot( qTmp.xyz, v );
88 /* 3D component of quaternion conjugate. */
89 vec3 conj = v3Scale( -1.0f, qTmp.xyz );
91 /* Vector portion of the intermediate quaternion. */
92 vec3 intVec = v3Scale( qTmp.w, v ) + v3Cross( qTmp.xyz, v );
model-node.c (https://gitlab.com/xenodora/lipsofsuna) C · 575 lines
200 uint32_t type;
201 LIMatVector position;
202 LIMatQuaternion rotation;
204 /* Read header. */
445 LIMatVector* z)
446 {
447 *x = limat_quaternion_transform (self->rest_transform.global.rotation, limat_vector_init (1.0f, 0.0f, 0.0f));
448 *y = limat_quaternion_transform (self->rest_transform.global.rotation, limat_vector_init (0.0f, 1.0f, 0.0f));
449 *z = limat_quaternion_transform (self->rest_transform.global.rotation, limat_vector_init (0.0f, 0.0f, 1.0f));
450 }
ext-light.c (https://github.com/deldiablo/GodheadLips.git) C · 331 lines
math.c (https://github.com/devyn/wine.git) C · 401 lines
39 {
40 D3DXMATRIX m1, m2, m3, m4, m5;
41 D3DXQUATERNION rot;
42 D3DXVECTOR3 rot_center, trans;
76 D3DXMatrixTranslation(&m2, -rot_center.x, -rot_center.y, -rot_center.z);
77 D3DXMatrixTranslation(&m4, rot_center.x, rot_center.y, rot_center.z);
78 D3DXMatrixRotationQuaternion(&m3, &rot);
79 D3DXMatrixTranslation(&m5, trans.x, trans.y, trans.z);
90 * D3DXMatrixDecompose
91 */
92 HRESULT WINAPI D3DXMatrixDecompose(D3DXVECTOR3 *poutscale, D3DXQUATERNION *poutrotation, D3DXVECTOR3 *pouttranslation, D3DXMATRIX *pm)
93 {
94 D3DXMATRIX normalized;
quaternion.c (https://github.com/josephzizys/plan-9.git) C · 242 lines
166 return q;
167 }
168 Quaternion qmul(Quaternion q, Quaternion r){
169 Quaternion s;
174 return s;
175 }
176 Quaternion qdiv(Quaternion q, Quaternion r){
177 return qmul(q, qinv(r));
178 }
199 return sqrt(p.r*p.r+p.i*p.i+p.j*p.j+p.k*p.k);
200 }
201 Quaternion slerp(Quaternion q, Quaternion r, double a){
202 double u, v, ang, s;
203 double dot=q.r*r.r+q.i*r.i+q.j*r.j+q.k*r.k;
216 * Only works if qlen(q)==qlen(r)==1
217 */
218 Quaternion qmid(Quaternion q, Quaternion r){
219 double l;
220 q=qadd(q, r);
MATH.C (https://github.com/kondrak/dos3d.git) C · 314 lines
224 /* ***** */
225 mth_Quaternion mth_quatMul(const mth_Quaternion *q1, const mth_Quaternion *q2)
226 {
227 mth_Quaternion r;
236 /* ***** */
237 mth_Quaternion mth_quatConjugate(const mth_Quaternion *q)
238 {
239 mth_Quaternion r;
248 /* ***** */
249 mth_Vector4 mth_quatMulVec(const mth_Quaternion *q, const mth_Vector4 *v)
250 {
251 mth_Vector4 vn, r;
math_transform.c (https://github.com/r-lyeh/AVA.git) C · 96 lines
28 static m_inline vec3 transformq(const quat q, const vec3 v) { // !!! ok, i guess
29 // [src] https://gamedev.stackexchange.com/questions/28395/rotating-vector3-by-a-quaternion (laurent couvidou)
30 // Extract the vector part of the quaternion
31 vec3 u = vec3(q.x, q.y, q.z);
32 // Extract the scalar part of the quaternion
33 float s = q.w;
34 // Do the math
73 }
75 // A quaternion can describe both a rotation and a uniform scaling in 3D space
76 static m_inline quat transform_quat (const mat44 m, const quat q) {
77 vec3 s = scale3(transform_vector(m, q.xyz), det44(m) < 0 ? -1.f : 1.f);
quat_setpoint.c (https://github.com/AshuLara/lisa.git) C · 159 lines
G3DQuatFunc.c (https://github.com/xxhp/HooleyBits.git) C · 679 lines
46 /******************************************************************************
47 *
48 * Quaternion Functions
49 *
50 *****************************************************************************/
477 float cz,sz;
479 // CONVERT QUATERNION TO MATRIX - I DON'T REALLY NEED ALL OF IT
481 matrix[0][0] = SG_ONE - (SG_TWO * quat[SG_Y] * quat[SG_Y])
type.c (https://gitlab.com/CoyoteLang/compiler) C · 333 lines
66 case COMPLEX_IMAG: return 1;
67 case COMPLEX_COMPLEX: return 2;
68 case COMPLEX_QUATERNION: return 4;
69 }
70 assert(0 && "Internal error: invalid type__complex_multiplier()");
166 case COMPLEX_IMAG: printf("i"); break;
167 case COMPLEX_COMPLEX: printf("c"); break;
168 case COMPLEX_QUATERNION: printf("q"); break;
169 }
170 }
quaternion.c (https://gitlab.com/kholdfuzion/goldeneye_src) C · 326 lines
1 #include <ultra64.h>
2 #include "quaternion.h"
3 #include "math_asinfacosf.h"
5 #define HALF2RAD(x) (x * (M_PI_F / 32768.0f))
7 void quaternion_set_rotation_around_xyz(vec3u angles, quatf q)
8 {
9 f32 cos_x = cosf(HALF2RAD(angles[0]) * 0.5f);
23 }
25 void quaternion_set_rotation_around_xyzf(vec3f angles, quatf q)
26 {
27 f32 cos_x = cosf(angles[0] * 0.5f);
41 }
43 void quaternion_set_rotation_around_x(f32 angle, quatf q)
44 {
45 q[0] = cosf(angle * 0.5f);
urotate.c (https://github.com/metrixcreate/RepSnapper.git) C · 217 lines
script-quaternion.c (https://github.com/deldiablo/GodheadLips.git) C · 253 lines
231 liscr_script_insert_cfunc (self, LISCR_SCRIPT_QUATERNION, "quaternion_new", Quaternion_new);
232 liscr_script_insert_cfunc (self, LISCR_SCRIPT_QUATERNION, "quaternion_new_euler", Quaternion_new_euler);
233 liscr_script_insert_mfunc (self, LISCR_SCRIPT_QUATERNION, "quaternion_add", Quaternion_add);
237 liscr_script_insert_mfunc (self, LISCR_SCRIPT_QUATERNION, "quaternion_nlerp", Quaternion_nlerp);
238 liscr_script_insert_mfunc (self, LISCR_SCRIPT_QUATERNION, "quaternion_normalize", Quaternion_normalize);
239 liscr_script_insert_mfunc (self, LISCR_SCRIPT_QUATERNION, "quaternion_get_conjugate", Quaternion_get_conjugate);
243 liscr_script_insert_mfunc (self, LISCR_SCRIPT_QUATERNION, "quaternion_set_x", Quaternion_set_x);
244 liscr_script_insert_mfunc (self, LISCR_SCRIPT_QUATERNION, "quaternion_get_y", Quaternion_get_y);
245 liscr_script_insert_mfunc (self, LISCR_SCRIPT_QUATERNION, "quaternion_set_y", Quaternion_set_y);
246 liscr_script_insert_mfunc (self, LISCR_SCRIPT_QUATERNION, "quaternion_get_z", Quaternion_get_z);
247 liscr_script_insert_mfunc (self, LISCR_SCRIPT_QUATERNION, "quaternion_set_z", Quaternion_set_z);
248 liscr_script_insert_mfunc (self, LISCR_SCRIPT_QUATERNION, "quaternion_get_w", Quaternion_get_w);
249 liscr_script_insert_mfunc (self, LISCR_SCRIPT_QUATERNION, "quaternion_set_w", Quaternion_set_w);
script-args.c (https://gitlab.com/xenodora/lipsofsuna) C · 1164 lines
568 }
570 int liscr_args_gets_quaternion (
571 LIScrArgs* self,
572 const char* name,
850 if (self->output_mode != LISCR_ARGS_OUTPUT_TABLE)
851 {
852 quat = liscr_data_new_alloc (self->script, self->lua, sizeof (LIMatQuaternion), LISCR_SCRIPT_QUATERNION);
853 if (quat != NULL)
854 {
865 }
866 lua_pushnumber (self->lua, ++self->ret);
867 quat = liscr_data_new_alloc (self->script, self->lua, sizeof (LIMatQuaternion), LISCR_SCRIPT_QUATERNION);
868 if (quat != NULL)
869 {
ext-script.c (https://gitlab.com/xenodora/lipsofsuna) C · 513 lines
376 {
377 LIMatTransform tmp;
378 LIMatQuaternion* q;
379 LIScrData* data;
381 if (liscr_args_geti_data (args, 0, LISCR_SCRIPT_QUATERNION, &data))
382 {
383 liphy_object_get_transform (args->self, &tmp);
390 {
391 LIMatTransform transform;
392 LIMatQuaternion quat;
394 if (liscr_args_geti_quaternion (args, 0, &quat))
ext-light.c (https://gitlab.com/xenodora/lipsofsuna) C · 239 lines
146 {
147 LIMatTransform transform;
148 LIMatQuaternion value;
149 LIExtLight* light = args->self;
151 if (liscr_args_geti_quaternion (args, 0, &value))
152 {
153 liren_render_light_get_transform (light->module->render, light->id, &transform);
154 transform.rotation = value;
155 limat_quaternion_normalize (transform.rotation);
156 liren_render_light_set_transform (light->module->render, light->id, &transform);
157 }
transCube.ec (https://github.com/thexa4/sdk.git) C · 215 lines
transCube.ec (https://github.com/redj/ecere-sdk.git) C · 215 lines
math.c (https://github.com/YokoZar/wine.git) C · 278 lines
77 /* Product of 2 quaternions */
78 LPD3DRMQUATERNION WINAPI D3DRMQuaternionMultiply(LPD3DRMQUATERNION q, LPD3DRMQUATERNION a, LPD3DRMQUATERNION b)
79 {
80 D3DRMQUATERNION temp;
127 /* Interpolation between two quaternions */
128 LPD3DRMQUATERNION WINAPI D3DRMQuaternionSlerp(LPD3DRMQUATERNION q, LPD3DRMQUATERNION a, LPD3DRMQUATERNION b, D3DVALUE alpha)
129 {
130 D3DVALUE dot, epsilon, temp, theta, u;
248 LPD3DVECTOR WINAPI D3DRMVectorRotate(LPD3DVECTOR r, LPD3DVECTOR v, LPD3DVECTOR axis, D3DVALUE theta)
249 {
250 D3DRMQUATERNION quaternion1, quaternion2, quaternion3;
251 D3DVECTOR norm;
260 D3DRMQuaternionMultiply(&quaternion1, &quaternion1, &quaternion3);
261 D3DRMQuaternionMultiply(&quaternion1, &quaternion1, &quaternion2);
263 *r = *D3DRMVectorNormalize(&quaternion1.v);
model-animation.c (https://github.com/deldiablo/GodheadLips.git) C · 465 lines
eMPL_outputs.c (https://bitbucket.org/rui_araujo/edvsboardos.git) C · 322 lines
89 /**
90 * @brief Body-to-world frame quaternion.
91 * The elements are output in the following order: W, X, Y, Z.
92 * @param[out] data Quaternion, q30 fixed point.
106 /**
107 * @brief Quaternion-derived heading.
108 * @param[out] data Heading in degrees, q16 fixed point.
109 * @param[out] accuracy Accuracy of the measurement from 0 (least accurate)
222 int inv_get_sensor_type_rot_mat(long *data, int8_t *accuracy, inv_time_t *timestamp)
223 {
224 inv_quaternion_to_rotation(eMPL_out.quat, data);
225 accuracy[0] = eMPL_out.quat_accuracy;
226 timestamp[0] = eMPL_out.nine_axis_timestamp;
surfaceTransformPoints.C (https://github.com/xyuan/OpenFOAM-1.7.x.git) C · 173 lines
42 #include "transformField.H"
43 #include "Pair.H"
44 #include "quaternion.H"
46 using namespace Foam;
120 v *= pi/180.0;
122 quaternion R(v.x(), v.y(), v.z());
124 Info<< "Rotating points by quaternion " << R << endl;
142 scalar roll = v.z();
144 quaternion R = quaternion(vector(0, 0, 1), yaw);
145 R *= quaternion(vector(0, 1, 0), pitch);
146 R *= quaternion(vector(1, 0, 0), roll);
148 Info<< "Rotating points by quaternion " << R << endl;
transform_convert_cursor.c (https://github.com/eliemichel/OpenMeshEffectForBlender.git) C · 136 lines
radio_protocol.c (https://gitlab.com/balajimude.it/robocup-firmware) C · 206 lines
ahrs_chimu_uart.c (https://bitbucket.org/tamasszabo/paparazzi_mavlink.git) C · 103 lines
40 uint8_t ping[7] = {CHIMU_STX, CHIMU_STX, 0x01, CHIMU_BROADCAST, MSG00_PING, 0x00, 0xE6 };
41 uint8_t rate[12] = {CHIMU_STX, CHIMU_STX, 0x06, CHIMU_BROADCAST, MSG10_UARTSETTINGS, 0x05, 0xff, 0x79, 0x00, 0x00, 0x01, 0x76 }; // 50Hz attitude only + SPI
42 uint8_t quaternions[7] = {CHIMU_STX, CHIMU_STX, 0x01, CHIMU_BROADCAST, MSG09_ESTIMATOR, 0x01, 0x39 }; // 25Hz attitude only + SPI
43 // uint8_t rate[12] = {CHIMU_STX, CHIMU_STX, 0x06, CHIMU_BROADCAST, MSG10_UARTSETTINGS, 0x04, 0xff, 0x79, 0x00, 0x00, 0x01, 0xd3 }; // 25Hz attitude only + SPI
44 // uint8_t euler[7] = {CHIMU_STX, CHIMU_STX, 0x01, CHIMU_BROADCAST, MSG09_ESTIMATOR, 0x00, 0xaf }; // 25Hz attitude only + SPI
58 // Quat Filter
59 for (int i=0;i<7;i++) {
60 InsUartSend1(quaternions[i]);
61 }
MadgwickAHRS.c (https://gitlab.com/krucios/Astraeus_FW) C · 278 lines
32 volatile float beta = betaDef; // 2 * proportional gain (Kp)
33 float q[4] = {1.0f, 0.0f, 0.0f, 0.0f}; // quaternion of sensor frame relative to auxiliary frame
35 //---------------------------------------------------------------------------------------------------
171 }
173 // Integrate rate of change of quaternion to yield quaternion
174 q[0] += qDot1 * (1.0f / sampleFreq);
175 q[1] += qDot2 * (1.0f / sampleFreq);
246 }
248 // Integrate rate of change of quaternion to yield quaternion
249 q[0] += qDot1 * (1.0f / sampleFreq);
250 q[1] += qDot2 * (1.0f / sampleFreq);
sound-module.c (https://gitlab.com/xenodora/lipsofsuna) C · 290 lines
54 self->music_volume = 1.0f;
55 self->music_fading = 1.0f;
56 self->listener_rotation = limat_quaternion_identity ();
58 #ifndef LI_DISABLE_SOUND
253 /* Update listener position. */
254 velocity = self->listener_velocity;
255 direction = limat_quaternion_get_basis (self->listener_rotation, 2);
256 up = limat_quaternion_get_basis (self->listener_rotation, 1);
SDA.C (https://github.com/OpenFOAM/OpenFOAM-4.x.git) C · 133 lines
stabilization_attitude_ref_quat_int.c (https://bitbucket.org/tamasszabo/paparazzi_mavlink.git) C · 180 lines
model-node.c (https://github.com/deldiablo/GodheadLips.git) C · 471 lines
166 uint32_t type;
167 LIMatVector position;
168 LIMatQuaternion rotation;
170 /* Read header. */
368 LIMatVector* z)
369 {
370 *x = limat_quaternion_transform (self->transform.global.rotation, limat_vector_init (1.0f, 0.0f, 0.0f));
371 *y = limat_quaternion_transform (self->transform.global.rotation, limat_vector_init (0.0f, 1.0f, 0.0f));
372 *z = limat_quaternion_transform (self->transform.global.rotation, limat_vector_init (0.0f, 0.0f, 1.0f));
373 }
math.c (https://github.com/andersonsp/Myr.git) C · 376 lines
285 }
287 // Dual Quaternions
288 void g_dual_quat_scale_add( GDualQuat* r, GDualQuat* dq, float t ){
289 float dot_real = r->q.x*dq->q.x + r->q.y*dq->q.y + r->q.z*dq->q.z + r->q.w*dq->q.w;
340 dq->q.z = a->q.w*b->q.z + a->q.z*b->q.w + a->q.x*b->q.y - a->q.y*b->q.x;
342 // Dual unit Quaternion.
343 dq->d.x = a->d.x*b->q.w + a->q.w*b->d.x + a->d.w*b->q.x + a->q.x*b->d.w -
344 a->d.z*b->q.y + a->q.y*b->d.z + a->d.y*b->q.z - a->q.z*b->d.y;
IoODEBody.c (https://github.com/basuke/io.git) C · 416 lines
94 {"setLinearVelocity", IoODEBody_setLinearVelocity},
96 {"quaternion", IoODEBody_quaternion},
97 //{"setQuaternion", IoODEBody_setQuaternion},
387 }
389 IoObject *IoODEBody_quaternion(IoODEBody *self, IoObject *locals, IoMessage *m)
390 {
391 IoODEBody_assertValidBody(self, locals, m);
392 {
393 const dReal *q = dBodyGetQuaternion(BODYID);
394 IoSeq *v = IoSeq_newFloatArrayOfSize_(IOSTATE, 4);
395 UArray *u = IoSeq_rawUArray(v);
404 /*
405 IoObject *IoODEBody_setQuaternion(IoODEBody *self, IoObject *locals, IoMessage *m)
406 {
407 const double w = IoMessage_locals_doubleArgAt_(m, locals, 0);
qmult~.c (https://github.com/pd-l2ork/pd.git) C · 166 lines
1 /*
2 * qmult.c - quaternion multiplication dsp object
3 * Copyright (c) 2000-2003 by Tom Schouten
4 *
71 {
73 /* read input quaternions */
74 wl = *in0l++;
75 xl = *in1l++;
85 /* multiply quaternions */
86 w = wl * wr;
87 x = wl * xr;
108 /* write output quaternion */
109 *out0++ = w;
110 *out1++ = x;
glEcereCamera.ec (https://github.com/redj/ecere-sdk.git) C · 155 lines
script-object.c (https://github.com/deldiablo/GodheadLips.git) C · 206 lines
161 lieng_object_get_transform (args->self, &tmp);
162 liscr_args_seti_quaternion (args, &tmp.rotation);
163 }
168 LIScrData* quat;
170 if (liscr_args_geti_data (args, 0, LISCR_SCRIPT_QUATERNION, &quat))
171 {
172 lieng_object_get_transform (args->self, &transform);
173 transform.rotation = *((LIMatQuaternion*) quat->data);
174 lieng_object_set_transform (args->self, &transform);
175 }
test-conform-main.c (https://gitlab.com/tchaik/mutter) C · 157 lines
obj_args.c (https://gitlab.com/oytunistrator/QuIP) C · 203 lines
solver_2bone.c (https://gitlab.com/Teo-Mirror/AtomicGameEngine) C · 138 lines
linearMotion.C (https://gitlab.com/johnvarv/OpenFOAM-3.0.x) C · 98 lines
vector.C (https://github.com/xyuan/OpenFOAM-1.7.x.git) C · 108 lines
68 //Quaternion Implementation
69 Quaternion operator*(Quaternion a,Quaternion b) {
70 Quaternion c;
75 return c;
76 }
77 Quaternion operator-(Quaternion q) {
78 return Quaternion(q.r*-1,q.x,q.y,q.z);
89 }
91 Quaternion operator+(Quaternion a,Quaternion b) {
92 return Quaternion(a.r+b.r, a.x+b.x, a.y+b.y, a.z+b.z);
95 return (a.r*b.r + a.x*b.x + a.y*b.y + a.z*b.z);
96 }
97 Quaternion slerp(Quaternion a,Quaternion b,float interp){
98 if((a^b) <0.0) {
99 a.r=-a.r;
CoordinateConversions.c (https://github.com/CorvusCorax/my_OpenPilot_mods.git) C · 217 lines
120 }
122 // ****** find roll, pitch, yaw from quaternion ********
123 void Quaternion2RPY(float q[4], float rpy[3])
140 }
142 // ****** find quaternion from roll, pitch, yaw ********
143 void RPY2Quaternion(float rpy[3], float q[4])
169 }
171 //** Find Rbe, that rotates a vector from earth fixed to body frame, from quaternion **
172 void Quaternion2R(float q[4], float Rbe[3][3])
attitude_estimator_q_params.c (https://gitlab.com/SJWink623/Firmware) C · 146 lines
anim_orient.c (https://bitbucket.org/vrrm/brl-cad-copy-for-fast-history-browsing-in-git.git) C · 226 lines
Quaternion.ec (https://github.com/thexa4/sdk.git) C · 321 lines
94 }
96 void Multiply(Quaternion q1, Quaternion q2)
97 {
98 w = q1.w * q2.w - q2.x * q1.x - q1.y * q2.y - q1.z * q2.z;
102 }
104 void Divide(Quaternion q1, Quaternion q2)
105 {
106 w = q2.w * q1.w + q2.x * q1.x + q2.y * q1.y + q2.z * q1.z;
180 #define DELTA 0
182 void Slerp(Quaternion from, Quaternion to, float t)
183 {
184 double to1[4];
PacketConfig.c (https://gitlab.com/TTYRobotiklubi/Follower) C · 140 lines
92 // ----------------------------------------------------------------------------
93 // Packet "Quaternions" parameters table
94 // ----------------------------------------------------------------------------
95 const PacketParameter packetQuaternionsParameterList[4] =
134 /* DistanceSensors */ { 0xF0, packetDistanceSensorsParameterList, 8, 8 },
135 /* RobotFeedback */ { 0xD4, packetRobotFeedbackParameterList, 4, 8 },
136 /* Quaternions */ { 0xF2, packetQuaternionsParameterList, 4, 8 },
137 /* Emergency */ { 0xCF, packetEmergencyParameterList, 4, 4 },
138 /* Gyro */ { 0xF1, packetGyroParameterList, 3, 6 }
constantVelocity.C (https://gitlab.com/pasbec/foam-extend-3.2) C · 133 lines
graphVelocity.C (https://gitlab.com/pasbec/foam-extend-3.2) C · 317 lines
script-quaternion.c (https://gitlab.com/xenodora/lipsofsuna) C · 321 lines
107 return;
109 tmp = limat_quaternion_add (*((LIMatQuaternion*) args->self), *((LIMatQuaternion*) liscr_data_get_data (b)));
110 liscr_args_seti_quaternion (args, &tmp);
290 LIScrScript* self)
291 {
292 liscr_script_insert_cfunc (self, LISCR_SCRIPT_QUATERNION, "quaternion_new", Quaternion_new);
293 liscr_script_insert_cfunc (self, LISCR_SCRIPT_QUATERNION, "quaternion_new_from_axis", Quaternion_new_from_axis);
294 liscr_script_insert_cfunc (self, LISCR_SCRIPT_QUATERNION, "quaternion_new_from_dir", Quaternion_new_from_dir);
295 liscr_script_insert_cfunc (self, LISCR_SCRIPT_QUATERNION, "quaternion_new_from_euler", Quaternion_new_from_euler);
296 liscr_script_insert_cfunc (self, LISCR_SCRIPT_QUATERNION, "quaternion_new_from_vectors", Quaternion_new_from_vectors);
297 liscr_script_insert_mfunc (self, LISCR_SCRIPT_QUATERNION, "quaternion_add", Quaternion_add);
298 liscr_script_insert_mfunc (self, LISCR_SCRIPT_QUATERNION, "quaternion_concat", Quaternion_concat);
299 liscr_script_insert_mfunc (self, LISCR_SCRIPT_QUATERNION, "quaternion_multiply", Quaternion_multiply);
300 liscr_script_insert_mfunc (self, LISCR_SCRIPT_QUATERNION, "quaternion_sub", Quaternion_sub);
matrix.c (https://gitlab.com/sat-metalab/vrpn) C · 302 lines
ekf_math.c (https://github.com/golaced/Oldx_fly_controller.git) C · 833 lines
4 // ËÄÔªÊýת»¯³ÉÒ»¸ö½«ÏòÁ¿ÓÉNED×ø±êϵÐýתµ½»úÌå×ø±êϵµÄ¾ØÕó
5 void Quaternion2Tnb(const float q[4], float Tnb[3][3])
6 {
7 // Calculate the ned to body cosine matrix
31 //ËÄÔªÊýת»¯³ÉÒ»¸ö½«ÏòÁ¿ÓÉ»úÌå×ø±êϵÐýתµ½NED×ø±êϵµÄ¾ØÕó
32 void Quaternion2Tbn(const float q[4], float Tbn[3][3])
33 {
34 // Calculate the body to ned cosine matrix
57 // ÓÉËÄÔªÊýת³ÉÅ·À½Ç
58 void Quaternion2Euler(const float q[4], float euler[3])
59 {
60 float R13, R11, R12, R23, R33;
Matrix.ec (https://github.com/redj/ecere-sdk.git) C · 310 lines
93 }
95 void RotationQuaternion(const Quaternion quat)
96 {
97 double xx = quat.x*quat.x, yy = quat.y*quat.y, zz = quat.z*quat.z;
128 }
130 void Rotate(const Quaternion quat)
131 {
132 Matrix rmat;
133 Matrix mat1;
134 rmat.RotationQuaternion(quat);
135 mat1.Multiply3x4(this, rmat);
136 this = mat1;
xyzquat.c (https://gitlab.com/sat-metalab/vrpn) C · 190 lines
stabilization_attitude_ref_quat_float.c (https://github.com/AshuLara/paparazzi_lisa.git) C · 148 lines
anim_keyread.c (https://bitbucket.org/vrrm/brl-cad-copy-for-fast-history-browsing-in-git.git) C · 160 lines
6 * The output table specifies the orientation in one of three ways:
7 *
8 * default - quaternions in the order x, y, z, w.
9 *
10 * -z option - Eulers angles, in the order xyz. The model axes are
48 #define YPR 0
49 #define XYZ 1
50 #define QUATERNION 2
52 #define DEGREES 0
118 printf("%.10g\t%.10g\t%.10g\n",angle[X],angle[Y],angle[Z]);
119 }
120 else if (mode==QUATERNION){
121 anim_mat2quat(quat,viewrot);
122 printf("%.10g\t%.10g\t%.10g\t%.10g\n",quat[X],quat[Y],quat[Z],quat[W]);
ext-render.c (https://gitlab.com/xenodora/lipsofsuna) C · 223 lines
translation.C (https://gitlab.com/pasbec/foam-extend-3.2) C · 173 lines
rotatingMotion.C (https://gitlab.com/johnvarv/OpenFOAM-3.0.x) C · 105 lines
quat.c (https://bitbucket.org/vrrm/brl-cad-copy-for-fast-history-browsing-in-git.git) C · 86 lines
PacketConfig.c (https://gitlab.com/TTYRobotiklubi/Follower) C · 108 lines
38 // ----------------------------------------------------------------------------
39 // Packet "Quaternions" parameters table
40 // ----------------------------------------------------------------------------
41 const PacketParameter packetQuaternionsParameterList[4] =
99 /* RobotFeedback */ { 0xD4, packetRobotFeedbackParameterList, 4, 8 },
100 /* DistanceSensors */ { 0xF0, packetDistanceSensorsParameterList, 8, 8 },
101 /* Quaternions */ { 0xF2, packetQuaternionsParameterList, 4, 8 },
102 /* MotorSpeeds */ { 0xD0, packetMotorSpeedsParameterList, 2, 4 },
103 /* RobotControl */ { 0xD3, packetRobotControlParameterList, 2, 4 },
vrpn_Tracker_SpacePoint.C (https://gitlab.com/sat-metalab/vrpn) C · 98 lines
Quaternion.ec (https://github.com/redj/ecere-sdk.git) C · 400 lines
33 }
35 void Multiply(const Quaternion q1, const Quaternion q2)
36 {
37 w = q1.w * q2.w - q2.x * q1.x - q1.y * q2.y - q1.z * q2.z;
81 }
83 static void rotateQuats(Quaternion qPitch, Quaternion qYaw, Quaternion qRoll, EulerRotationOrder rotationOrder)
84 {
85 Quaternion q, a;
332 }
334 void FromQuaternion(const Quaternion q, EulerRotationOrder order)
335 {
336 Matrix m;
pid.c (https://gitlab.com/krucios/Astraeus_FW) C · 97 lines
trackball.c (https://github.com/akosma/Lorenz.git) C · 165 lines
109 float sinAng2; // sin(half-angle)
111 // Convert a GL-style rotation to a quaternion. The GL rotation looks like this:
112 // {angle, x, y, z}, the corresponding quaternion looks like this:
126 // Figure out A' = A . dA
127 // In quaternions: let q0 <- A, and q1 <- dA.
128 // Figure out q2 = q1 + q0 (note the order reversal!).
129 // A' <- q3.
137 q2[2] = q1[0]*q0[1] - q1[1]*q0[0] + q1[3]*q0[2] + q1[2]*q0[3];
138 q2[3] = q1[3]*q0[3] - q1[0]*q0[0] - q1[1]*q0[1] - q1[2]*q0[2];
139 // Here's an excersize for the reader: it's a good idea to re-normalize your quaternions
140 // every so often. Experiment with different frequencies.
142 // An identity rotation is expressed as rotation by 0 about any axis.
143 // The "angle" term in a quaternion is really the cosine of the half-angle.
144 // So, if the cosine of the half-angle is one (or, 1.0 within our tolerance),
145 // then you have an identity rotation.
anim_keyread.c (https://bitbucket.org/vrrm/brl-cad-copy-for-fast-history-browsing-in-git.git) C · 175 lines
25 * The output table specifies the orientation in one of three ways:
26 *
27 * default - quaternions in the order x, y, z, w.
28 *
29 * -z option - Eulers angles, in the order xyz. The model axes are
52 #define YPR 0
53 #define XYZ 1
54 #define QUATERNION 2
56 #define DEGREES 0
123 printf("%.10g\t%.10g\t%.10g\n", angle[X], angle[Y], angle[Z]);
124 }
125 else if (mode==QUATERNION) {
126 anim_mat2quat(quat, viewrot);
127 printf("%.10g\t%.10g\t%.10g\t%.10g\n", quat[X], quat[Y], quat[Z], quat[W]);
vector.C (https://gitlab.com/pasbec/foam-extend-3.2) C · 108 lines
68 //Quaternion Implementation
69 Quaternion operator*(Quaternion a,Quaternion b) {
70 Quaternion c;
75 return c;
76 }
77 Quaternion operator-(Quaternion q) {
78 return Quaternion(q.r*-1,q.x,q.y,q.z);
89 }
91 Quaternion operator+(Quaternion a,Quaternion b) {
92 return Quaternion(a.r+b.r, a.x+b.x, a.y+b.y, a.z+b.z);
95 return (a.r*b.r + a.x*b.x + a.y*b.y + a.z*b.z);
96 }
97 Quaternion slerp(Quaternion a,Quaternion b,float interp){
98 if((a^b) <0.0) {
99 a.r=-a.r;
test_mlkf.c (https://bitbucket.org/tamasszabo/paparazzi_mavlink.git) C · 116 lines
106 fprintf(fd, "%.16f [%.16f %.16f %.16f %.16f] [%.16f %.16f %.16f] [%.16f %.16f %.16f] [%.16f %.16f %.16f %.16f %.16f %.16f]\n",
107 samples[i].time,
108 output[i].quat_est.qi, output[i].quat_est.qx, output[i].quat_est.qy, output[i].quat_est.qz, // quaternion
109 output[i].rate_est.p, output[i].rate_est.q, output[i].rate_est.r, // omega
110 output[i].bias_est.p, output[i].bias_est.q, output[i].bias_est.r, // bias
registration.c (https://github.com/Kinect5/ICP.git) C · 332 lines
vzerog.c (https://github.com/mattbornski/spice.git) C · 193 lines
septernion.C (https://gitlab.com/johnvarv/OpenFOAM-3.0.x) C · 102 lines
quaternions.c (https://github.com/zhengwy888/ARDrone-SDK_MF.git) C · 129 lines
12 const quaternion_t quat_unitary = { 1.0f, {{{ 0.0f, 0.0f, 0.0f}}} };
14 void mul_quat( quaternion_t* out, quaternion_t* q1, quaternion_t* q2)
15 {
16 vector31_t temp_v;
31 }
33 void add_quat( quaternion_t* out, quaternion_t* q1, quaternion_t* q2 )
34 {
35 // scalar result
39 }
41 void mulconst_quat( quaternion_t* out, quaternion_t* q, float32_t k )
42 {
43 out->a = (q->a) * k;
lib3ds_quat.c (https://github.com/AsherBond/MondocosmOS.git) C · 298 lines
oscillatingRotatingMotion.C (https://gitlab.com/johnvarv/OpenFOAM-3.0.x) C · 109 lines
quaternion.C (https://gitlab.com/johnvarv/OpenFOAM-3.0.x) C · 154 lines
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 const char* const Foam::quaternion::typeName = "quaternion";
33 const Foam::quaternion Foam::quaternion::zero(0, vector(0, 0, 0));
34 const Foam::quaternion Foam::quaternion::I(1, vector(0, 0, 0));
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 Foam::quaternion::quaternion(Istream& is)
39 {
40 is >> *this;
72 Foam::quaternion Foam::exp(const quaternion& q)
73 {
74 const scalar magV = mag(q.v());