Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ScalingMatrix.java
- // Easel
- //
- // Created by Philip Rhodes on 7/31/05.
- // Copyright 2005 __MyCompanyName__. All rights reserved.
- //
- /** This class implements matrices for scaling. */
- public class ScalingMatrix extends Matrix{
- /** Creates a default matrix that scales all dimensions by
- * 1.0. That is, it does nothing.
- */
- public ScalingMatrix(){
- }
- /** Creates a scaling matrix that scales by the factors specified as
- * parameters.
- */
- public ScalingMatrix(double xscale, double yscale, double zscale){
- float [][] scale_matrix = {{(float)xscale, 0.0f, 0.0f, 0.0f},
- {0.0f, (float)yscale, 0.0f, 0.0f},
- {0.0f, 0.0f, (float)zscale, 0.0f},
- {0.0f, 0.0f, 0.0f, 1.0f}
- };
- matrix = scale_matrix;
- }
- /** Set the scale factors to the given values.*/
- public void setScales(double xscale, double yscale, double zscale){
- // Write me!
- matrix[0][0] = (float)xscale;
- matrix[1][1] = (float)yscale;
- matrix[2][2] = (float)zscale;
- }
- /** Calling copy on a scaling matrix is dangerous, since the result might not
- * be a scaling matrix.
- */
- public void copy(Matrix m){
- System.out.println("ScalingMatrix.java: copy(Matrix) can only be called on a generic Matrix.");
- System.exit(1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement