Matrix operations
-
Oh, now I get it. This has nothing to do with the usual rotate, translate, scale,... transforms. There are no functions for this readily available in our framework. You need to implement that all by yourself.
-
@Wieland said in Matrix operations:
Oh, now I get it. This has nothing to do with the usual rotate, translate, scale,... transforms. There are no functions for this readily available in our framework. You need to implement that all by yourself.
Indeed this is what I was just thinking ... since the VRonin answer.
Thanks to both of you
-
What you described is called a matrix transposition. My advice - Just use Eigen, it's headers-only anyway.
-
@kshegunov said in Matrix operations:
What you described is called a matrix transposition. My advice - Just use Eigen, it's headers-only anyway.
Oh ? Great I was about implementing all by myself.
Thanks for this -
@doubitchou said in Matrix operations:
Actually I'd need some minimal matrix functions like rotation, inverse, flip
if by rotation and inverse you don't mean the mathematical terms linked but physical movements of the image in the leds, all these operations can be easily done just by acting on the indexes rather than the content of the matrix.
For example:
given amatrix[rowCount][colCount]
matrix[i][j]
- mirrored on the vertical axis is
matrix[i][colCount-j-1]
- rotated 90° counter-clockwise is
matrix[j][i]
- mirrored on the vertical axis is
-
To provide a better understanding I've put some design concepts :
As you can see these are basic operations
-
@VRonin said in Matrix operations:
You could even use
QImage
withQImage::Format_Mono
format as a container actuallyI'm not sure to understand it right
-
QImage myMatrix(8,8,QImage::Format_Mono)
will create a container of 8 by 8 bits (not bytes).myMatrix.fill(0);
to turn everything off.- Point:
myMatrix.setPixel(0,0,1);
- Line(1):
for(int i=0;i<myMatrix.width();++i) myMatrix.setPixel(0,i,1);
- Column(1):
for(int i=0;i<myMatrix.height();++i) myMatrix.setPixel(i,0,1);
- Border:
for(int i=0;i<myMatrix.width();++i) {myMatrix.setPixel(0,i,1); myMatrix.setPixel(myMatrix.height()-1,i,1);} for(int i=0;i<myMatrix.height();++i) {myMatrix.setPixel(i,0,1); myMatrix.setPixel(i,myMatrix.width()-1,1);}
- Column Shift(1):
myMatrix=myMatrix.transformed(QTransform().translate(1,0));
- Column Shift(-1):
myMatrix=myMatrix.transformed(QTransform().translate(-1,0));
- Line Shift(1):
myMatrix=myMatrix.transformed(QTransform().translate(0,1));
- Line Shift(-1):
myMatrix=myMatrix.transformed(QTransform().translate(0,-1));
- Rotate(1):
myMatrix=myMatrix.transformed(QTransform().rotate(270));
- Rotate(-1):
myMatrix=myMatrix.transformed(QTransform().rotate(90));
- Invert:
myMatrix.invertPixels();
-
Great answer !, especially to be adapted to my needs. Anyway, I think I should try with Format_Indexed8 instead as I need to store the color values which requires more than a single bit:
0 : off
1 : Green
2 : Red
3 : Orange(Merci pour cette réponse)