Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // TranslationMatrix.java
- // Easel
- //
- // Created by Philip Rhodes on 7/31/05.
- // Copyright 2005 __MyCompanyName__. All rights reserved.
- //
- /** This class imlements matrices for translation (i.e. moving in space) */
- public class TranslationMatrix extends Matrix {
- /** Creates a default matrix that translates by 0 in all directions.
- * That is, it does nothing.
- */
- public TranslationMatrix(){
- }
- /** Create a translation matrix that will translate points (vertices) by
- * by the specified distances for each axis.
- */
- public TranslationMatrix(double dx, double dy, double dz){
- float [][] transform_matrix = {{1.0f, 0.0f, 0.0f, (float)dx},
- {0.0f, 1.0f, 0.0f, (float)dy},
- {0.0f, 0.0f, 1.0f, (float)dz},
- {0.0f, 0.0f, 0.0f, 1.0f}
- };
- matrix = transform_matrix;
- }
- /** Set the distances for all three axes.*/
- public void setDistances(double dx, double dy, double dz){
- // Write me!
- matrix[0][3] = (float)dx;
- matrix[1][3] = (float)dy;
- matrix[2][3] = (float)dz;
- }
- /** Calling copy on a translation matrix is dangerous, since the result might not
- * be a translation matrix.
- */
- public void copy(Matrix m){
- System.out.println("TranslationMatrix.java: copy(Matrix) can only be called on a generic Matrix.");
- System.exit(1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement