Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // RotationMatrixY.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 y axis.
- * according to the "right hand rule".
- */
- public class RotationMatrixY extends RotationMatrix{
- /** Constructs a rotation matrix with rotation angle 0. */
- public RotationMatrixY(){
- // The default constructor will set this matrix
- // equal to the identity, so do nothing here.
- }
- /** Construct a matrix that will rotate vertices around the y axis by the
- * angle theta, expressed in radians."
- */
- RotationMatrixY(double theta){
- // Write me!
- float [][] rotationx_matrix =
- {{(float)Math.cos(theta), 0.0f, (float)Math.sin(theta), 0.0f},
- {0.0f, 1.0f, 0.0f, 0.0f},
- {-(float)Math.sin(theta), 0.0f, (float)Math.cos(theta), 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][2] = (float)Math.sin(theta);
- matrix[2][0] = -(float)Math.sin(theta);
- matrix[2][2] = (float)Math.cos(theta);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement