Thanks for all your answers !
I think I understand better why Vector3D
does not extend RealVector
as of the development history hindsight you gave me. My point was not to change what RealVector
is used for, but rather to let Vector3D
be seen as this kind of N-dimension container (with N = 3). However I understand that this could be against the current design choice of separating geometry and linear algebra.
Do you think this method could be useful for you?
I don’t think adding this method will really change anything in my case, because it is a matter of code clunkyness and not of actually performing the computation. My issue here is that because the .operate
method does not handle Vector3D
, the following:
RealMatrix matrix = someRealMatrix();
Vector3D vector = someVector3D();
Vector3D output = matrix.operate(vector);
does not work, and we have to use a workaround like :
RealMatrix matrix = someRealMatrix();
Vector3D vector = someVector3D();
Vector3D output = new Vector3D(matrix.operate(vector.toArray()));
which I think is more tedious than needed. Adding the .toRealVector()
in the Vector3D
class would lead to similar cumbersome :
RealMatrix matrix = someRealMatrix();
Vector3D vector = someVector3D();
Vector3D output = new Vector3D(matrix.operate(vector.toRealVector()));
As an example, you can apply a Rotation
to a Vector3D
, but it is not necessarily the same as multiplying a 3x3 matrix and a 3x1 vector. In fact, it is not done this way as we use quaternions to implement rotations, not matrices.
I agree that rotation should indeed be represented with Rotation
instances and not by RealMatrix
ones, however in my case the matrix I need to use is not a rotation matrix (it is an inertia matrix), so the Rotation
class is not the appropriate way to represent it. But maybe once again I am not using the proper tools to solve my problem?
Anyway, thank you again for all your answers and sorry if I am too verbose to express my issue.
Cheers,
Guillaume