Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Matrix3f mul(Matrix3f otherMatrix){
- Matrix3f res = new Matrix3f();
- for(int i = 0; i < 3; i++){
- for(int j = 0; j < 3; j++){
- res.set(i, j,
- m[i][0] * otherMatrix.get(0, j) +
- m[i][1] * otherMatrix.get(1, j) +
- m[i][2] * otherMatrix.get(2, j));
- }
- }
- return res;
- }
- public Matrix3f initIdentity(){
- m[0][0] = 1; m[0][1] = 0; m[0][2] = 0;
- m[1][0] = 0; m[1][1] = 1; m[1][2] = 0;
- m[2][0] = 0; m[2][1] = 0; m[2][2] = 1;
- return this;
- }
- public Matrix3f initTranslationIdentity(float x, float y) {
- m[0][0] = 1; m[0][1] = 0; m[0][2] = x;
- m[1][0] = 0; m[1][1] = 1; m[1][2] = y;
- m[2][0] = 0; m[2][1] = 0; m[2][2] = 1;
- return this;
- }
- public Matrix3f initRotationIdentity(double angle) {
- float cos = (float) Math.cos(angle);
- float sin = (float) Math.sin(angle);
- m[0][0] = cos; m[0][1] = sin; m[0][2] = 0;
- m[1][0] = -sin; m[1][1] = cos; m[1][2] = 0;
- m[2][0] = 0; m[2][1] = 0; m[2][2] = 1;
- return this;
- }
- public Matrix3f initScaleIdentity(float x, float y) {
- m[0][0] = x; m[0][1] = 0; m[0][2] = 0;
- m[1][0] = 0; m[1][1] = y; m[1][2] = 0;
- m[2][0] = 0; m[2][1] = 0; m[2][2] = 1;
- return this;
- }
- public Matrix3f initShearXIdentity(float shearX) {
- m[0][0] = 1; m[0][1] = shearX; m[0][2] = 0;
- m[1][0] = 0; m[1][1] = 1; m[1][2] = 0;
- m[2][0] = 0; m[2][1] = 0; m[2][2] = 1;
- return this;
- }
- public Matrix3f initShearYIdentity(float shearY) {
- m[0][0] = 1; m[0][1] = 0; m[0][2] = 0;
- m[1][0] = shearY; m[1][1] = 1; m[1][2] = 0;
- m[2][0] = 0; m[2][1] = 0; m[2][2] = 1;
- return this;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement