
"Hubert Holin" <Hubert.Holin@lmd.polytechnique.fr> wrote
I am willing to build the bridges, but there has to bee something at the end of the bridge :-) ! There are geometry-oriented C++ libraries outside Boost, but none within, despite several proposals to develop such over the last few years. Basicaly, that's why I included some example code to show how quaternions could be plugged into rotation matrices, but no formal, part-of-the-library component.
I am happy to do the work. I hope that you might be willing to make sure that the output makes some sort of sense though :-) FWIW Here is a reinterpretation of the quaternion_to_R3_rotation in http://www.boost.org/libs/math/quaternion/HSO3.hpp reworked by Janek Kozicki and myself, (Any errors are my responsibility !) The matrices have been substituted with 3D vectors, some optimisation has been done and the code is compatible with the tentative Quan physical quantities Boost physical quantities library.as well as with floating point types. // Copyright Hubert Holin, Janek Kozicki, Andrew Little 2006 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // It might be better as a named function rather than an operator * template <typename TL, typename TR> inline quan::three_d::vect<TR> operator *( quan::three_d::quat<TL> const & lhs, quan::three_d::vect<TR> const & rhs //NB will become vect<3,TR> ) { TL const& a = lhs.w; TL const& b = lhs.x; TL const& c = lhs.y; TL const& d = lhs.z; // e.g typedef typeof(TL() * TR()) quat_squared_type; typedef typename quan::meta::binary_operation< TL, quan::meta::times, TL >::type quat_squared_type; quat_squared_type aa = a*a; quat_squared_type bb = b*b; quat_squared_type cc = c*c; quat_squared_type dd = d*d; quat_squared_type norme_carre = aa+bb+cc+dd; /* // throwing would be a good idea if nome-carre is too small! */ quat_squared_type ab = a*b; quat_squared_type ac = a*c; quat_squared_type ad = a*d; quat_squared_type bc = b*c; quat_squared_type bd = b*d; quat_squared_type cd = c*d; typedef quan::three_d::vect<quat_squared_type> squared_vect; squared_vect svx(aa+bb-cc-dd,2*(-ad+bc),2*(ac+bd)); squared_vect svy(2*(ad+bc),(aa-bb+cc-dd),2*(-ab+cd)); squared_vect svz(2*(-ac+bd),2*(ab+cd),(aa-bb-cc+dd)); quan::three_d::vect<TR> result( dot_product(svx,rhs)/norme_carre, dot_product(svy,rhs)/norme_carre, dot_product(svz,rhs)/norme_carre ); return result; } <...>
typedef complex<resistance> impedance; complex<voltage> v; complex<current> i
impedance z = v / i;
This is of course an entirely practical example.
In a similar vein, it would be fun to do simulations using the quaternionic version of Maxwell's equations.
That sounds like it would provide some good examples for the Quan library! http://sourceforge.net/projects/quan regards Andy little