@@ -49,9 +49,9 @@ pub unsafe extern "C" fn new_quaternion_from_vector(
49
49
null_pointer_check ! ( imag_ptr) ;
50
50
to_raw_pointer ( & Quaternion :: new (
51
51
real,
52
- ( * imag_ptr) . x ,
53
- ( * imag_ptr) . y ,
54
- ( * imag_ptr) . z ,
52
+ ( & ( * imag_ptr) ) . x ,
53
+ ( & ( * imag_ptr) ) . y ,
54
+ ( & ( * imag_ptr) ) . z ,
55
55
) )
56
56
}
57
57
@@ -82,7 +82,12 @@ pub unsafe extern "C" fn quaternion_get_components(
82
82
quat_ptr : * const Quaternion < f64 > ,
83
83
) -> * const c_double {
84
84
null_pointer_check ! ( quat_ptr) ;
85
- let components: [ c_double ; 4 ] = [ ( * quat_ptr) . w , ( * quat_ptr) . i , ( * quat_ptr) . j , ( * quat_ptr) . k ] ;
85
+ let components: [ c_double ; 4 ] = [
86
+ ( & ( * quat_ptr) ) . w ,
87
+ ( & ( * quat_ptr) ) . i ,
88
+ ( & ( * quat_ptr) ) . j ,
89
+ ( & ( * quat_ptr) ) . k ,
90
+ ] ;
86
91
Box :: into_raw ( Box :: new ( components) ) as * const _
87
92
}
88
93
@@ -97,7 +102,7 @@ pub unsafe extern "C" fn quaternion_get_components(
97
102
#[ no_mangle]
98
103
pub unsafe extern "C" fn quaternion_set_real ( quat_ptr : * mut Quaternion < f64 > , real : f64 ) {
99
104
null_pointer_check ! ( quat_ptr) ;
100
- ( * quat_ptr) . w = real;
105
+ ( & mut ( * quat_ptr) ) . w = real;
101
106
}
102
107
103
108
/// Set the i component of an existing quaternion stored at the address
@@ -111,7 +116,7 @@ pub unsafe extern "C" fn quaternion_set_real(quat_ptr: *mut Quaternion<f64>, rea
111
116
#[ no_mangle]
112
117
pub unsafe extern "C" fn quaternion_set_i ( quat_ptr : * mut Quaternion < f64 > , i : f64 ) {
113
118
null_pointer_check ! ( quat_ptr) ;
114
- ( * quat_ptr) . i = i;
119
+ ( & mut ( * quat_ptr) ) . i = i;
115
120
}
116
121
117
122
/// Set the j component of an existing quaternion stored at the address
@@ -125,7 +130,7 @@ pub unsafe extern "C" fn quaternion_set_i(quat_ptr: *mut Quaternion<f64>, i: f64
125
130
#[ no_mangle]
126
131
pub unsafe extern "C" fn quaternion_set_j ( quat_ptr : * mut Quaternion < f64 > , j : f64 ) {
127
132
null_pointer_check ! ( quat_ptr) ;
128
- ( * quat_ptr) . j = j;
133
+ ( & mut ( * quat_ptr) ) . j = j;
129
134
}
130
135
131
136
/// Set the k component of an existing quaternion stored at the address
@@ -139,7 +144,7 @@ pub unsafe extern "C" fn quaternion_set_j(quat_ptr: *mut Quaternion<f64>, j: f64
139
144
#[ no_mangle]
140
145
pub unsafe extern "C" fn quaternion_set_k ( quat_ptr : * mut Quaternion < f64 > , k : f64 ) {
141
146
null_pointer_check ! ( quat_ptr) ;
142
- ( * quat_ptr) . k = k;
147
+ ( & mut ( * quat_ptr) ) . k = k;
143
148
}
144
149
145
150
/// Set all of the components of an existing quaternion stored at the address
@@ -159,10 +164,10 @@ pub unsafe extern "C" fn quaternion_set_components(
159
164
k : f64 ,
160
165
) {
161
166
null_pointer_check ! ( quat_ptr) ;
162
- ( * quat_ptr) . w = real;
163
- ( * quat_ptr) . i = i;
164
- ( * quat_ptr) . j = j;
165
- ( * quat_ptr) . k = k;
167
+ ( & mut ( * quat_ptr) ) . w = real;
168
+ ( & mut ( * quat_ptr) ) . i = i;
169
+ ( & mut ( * quat_ptr) ) . j = j;
170
+ ( & mut ( * quat_ptr) ) . k = k;
166
171
}
167
172
168
173
/// Set the imaginary components of an existing quaternion stored at
@@ -182,9 +187,9 @@ pub unsafe extern "C" fn quaternion_set_imag_from_vector(
182
187
) {
183
188
null_pointer_check ! ( quat_ptr) ;
184
189
null_pointer_check ! ( vec_ptr) ;
185
- ( * quat_ptr) . i = ( * vec_ptr) . x ;
186
- ( * quat_ptr) . j = ( * vec_ptr) . y ;
187
- ( * quat_ptr) . k = ( * vec_ptr) . z ;
190
+ ( & mut ( * quat_ptr) ) . i = ( & ( * vec_ptr) ) . x ;
191
+ ( & mut ( * quat_ptr) ) . j = ( & ( * vec_ptr) ) . y ;
192
+ ( & mut ( * quat_ptr) ) . k = ( & ( * vec_ptr) ) . z ;
188
193
}
189
194
190
195
/// Copies the imaginary components to a 3-vector (using x -> i, y -> j
@@ -272,7 +277,7 @@ pub unsafe extern "C" fn quaternion_from_euler_angles(
272
277
) -> * mut Quaternion < f64 > {
273
278
let unit_quat = UnitQuaternion :: from_euler_angles ( roll, pitch, yaw) ;
274
279
let quat = unit_quat. quaternion ( ) ;
275
- to_raw_pointer ( & quat)
280
+ to_raw_pointer ( quat)
276
281
}
277
282
278
283
/// Converts from an axis angle given by a vector's x, y, z components
@@ -453,7 +458,7 @@ pub unsafe extern "C" fn quaternion_hamiltonian_product(
453
458
///
454
459
/// # Safety
455
460
///
456
- /// Outer processes that request the components of a quaternion should call this function
461
+ /// Outer processes that request the components of a quaternion should call this function
457
462
/// to free the memory allocated to the array once finished
458
463
#[ no_mangle]
459
464
pub unsafe extern "C" fn free_quaternion_components ( ptr : * mut c_double ) {
0 commit comments