Advertisement
Guest User

Transform

a guest
Nov 24th, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.71 KB | None | 0 0
  1. public class Transform {
  2.  
  3.     public Transform() {
  4.     translation = new Vector2f(0, 0);
  5.     rotation = 0;
  6.     scale = new Vector2f(1, 1);
  7.     shearX = 0;
  8.     shearY = 0;
  9.     }
  10.  
  11.     private Vector2f translation;
  12.     private Vector2f scale;
  13.     private float shearX;
  14.     private float shearY;
  15.     private double rotation;
  16.  
  17.     public Matrix3f getTransformation() {
  18.     Matrix3f translationMatrix = new Matrix3f().initTranslationIdentity(translation.getX(), translation.getY());
  19.     Matrix3f rotationMatrix = new Matrix3f().initRotationIdentity(rotation);
  20.     Matrix3f scaleMatrix = new Matrix3f().initScaleIdentity(scale.getX(), scale.getY());
  21.     Matrix3f shearXMatrix = new Matrix3f().initShearXIdentity(shearX);
  22.     Matrix3f shearYMatrix = new Matrix3f().initShearYIdentity(shearY);
  23.     Matrix3f transformation = translationMatrix.mul(rotationMatrix.mul(scaleMatrix).mul(shearXMatrix).mul(shearYMatrix));
  24.     return transformation;
  25.     }
  26.  
  27.     public Vector2f getTranslation() {
  28.     return translation;
  29.     }
  30.  
  31.     public Vector2f getScale() {
  32.     return scale;
  33.     }
  34.  
  35.     public void setTranslation(Vector2f translation) {
  36.     this.translation = translation;
  37.     }
  38.  
  39.     public void setTranslation(float x, float y) {
  40.     this.translation = new Vector2f(x, y);
  41.     }
  42.  
  43.     public void setScale(Vector2f scale) {
  44.     this.scale = scale;
  45.     }
  46.  
  47.     public float getShearX() {
  48.     return shearX;
  49.     }
  50.  
  51.     public float getShearY() {
  52.     return shearY;
  53.     }
  54.  
  55.     public double getRotation() {
  56.     return rotation;
  57.     }
  58.  
  59.     public void setShearX(float shearX) {
  60.     this.shearX = shearX;
  61.     }
  62.  
  63.     public void setShearY(float shearY) {
  64.     this.shearY = shearY;
  65.     }
  66.  
  67.     public void setRotation(double rotation) {
  68.     this.rotation = rotation;
  69.     }
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement