Use of mini-class in a main-class

Hi everyone,

I am working with a class called "Rotations" where several constructors and static functions for vector calculations are implemented. Half of this functions use so called quaternions (four float values m,x,y,z) to get orientational data. In a sensor class where the quaternions are measured, I want to forward those float values as one object (Quaternions quaternions), because the order of the float values matters and I want to have it fix with this object.
Now, since I also just want to include "rotations.h", I want to have this Quaternion class to be part of the rotation class. I would like to be able doing that:

include "rotations.h"

Rotation vector_rotations;
Quaternions quaternion;


The "Rotations" class in rotations.h has static functions with return type "Rotations", so I want to keep that and not cast some of them to Quaternions return type (have tried it, was uggly).

Thanks for helping out!
Just declare both classes in rotations.h. Or you could create quaternions.h and declare Quanernions there. Of course you'd have to #include that file in your code.
what was ugly?
you can make an 'automatic casting' between the two types and it should be very simple, eg
rotation r;
quaternion q;
r = q; //ok
q = r; //ok
and that is extensible:
q = static_rotation_function_foo(p1, p2); //ok, function returns a rotation that is shoveled into the quaternion

you can do this by simply overloading the assignment operators, if that resolves your problem?
if not, can you describe a little better what you want to do?

quaternions have been with us for almost 200 years. They are no longer 'so called' but have earned their place in the math world. Try sending your rocket straight up, rotating, and coming back down without them!
Last edited on
Topic archived. No new replies allowed.