It seems there is no Quaternion<f64>::from_slice()
or quat.as_slice()
- or am I missing something?
Hi!
You’re right, there are no such methods. Though they could be added. Would you like to open an issue for this? Perhaps even a pull request them if you which?
Regarding quat.as_slice()
, one thing you can already do is quat.coords.as_slice()
.
btw I realized I accidentally didn’t set the category here… maybe move to nalgebra
?
seems there is no as_mut_slice()
on quat.coords
?
Or in more detail, DerefMut
isn’t implemented for Quaternion<f64>
There is already a quat.coords.as_mut_slice()
, and DerefMut
is alrealy implemented for Quaternion<f64>
: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=595a042e802f5e2178922a7b3e6bad2c
Perhaps your quat
is not mutable?
Sorry, my mistake, I had a UnitQuaternion<f64>
: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a0ea53b8b03fca56281e0c228d9af9a1
Am I supposed to first convert that back to a Quaternion<f64>
?
You should be careful with .as_mut_unchecked()
though. It is not unsafe, but you may end up with surprising results if you modify the slice in such a way that the resulting UnitQuaternion
is no longer of unit size: its norm should always be equal to 1 so it can actually represent a rotation.
This is actually the main difference between UnitQuaternion
and Quaternion
: if you need a rotation, use UnitQuaternion
which only supports operations that preserve its unit length (except for those _unchecked
methods). If you need a general quaternion which does not necessarily have a unit size, use Quaternion
.