Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // RotationMatrixZ.java
- // Easel
- //
- // Created by Philip Rhodes on 7/29/05.
- // Copyright 2005 __MyCompanyName__. All rights reserved.
- //
- /** This class represents matrices that rotate vertices around the z axis.
- * according to the "right hand rule".
- */
- public class RotationMatrixZ extends RotationMatrix{
- /** Constructs a rotation matrix with rotation angle 0. */
- public RotationMatrixZ(){
- // The default constructor will set this matrix
- // equal to the identity, so do nothing here.
- }
- /** Construct a matrix that will rotate vertices around the z axis by the
- * angle theta, expressed in radians."
- */
- RotationMatrixZ(double theta){
- // Write me!
- float [][] rotationx_matrix =
- {{(float)Math.cos(theta), -(float)Math.sin(theta), 0.0f, 0.0f},
- {(float)Math.sin(theta), (float)Math.cos(theta), 0.0f, 0.0f},
- {0.0f, 0.0f, 1.0f, 0.0f},
- {0.0f, 0.0f, 0.0f, 1.0f}
- };
- matrix = rotationx_matrix;
- }
- /** Set the angle of rotation to theta, expressed in radians. */
- public void setAngle(double theta){
- // Write me!
- matrix[0][0] = (float)Math.cos(theta);
- matrix[0][1] = -(float)Math.sin(theta);
- matrix[1][0] = (float)Math.sin(theta);
- matrix[1][1] = (float)Math.cos(theta);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement