/// <summary> /// Rotate the texture coordinates. /// </summary> public Quad RotateTextureCoordinates(Vector3 axis, int rotations) { if (new Vector3(Vert0.N, Vert0.O, Vert0.P).Absolute().Rounded(digits: 2) != axis) { return(this); } for (var r = 0; r < rotations; r++) { Vert0 = Vert0.RotateUV(); Vert1 = Vert1.RotateUV(); Vert2 = Vert2.RotateUV(); Vert3 = Vert3.RotateUV(); } return(this); }
/// <summary> /// Apply a rotation matrix to this quad. /// </summary> public Quad ApplyRotationMatrixY(Matrix4 xyz, Matrix4 nop, int rotations) { // Rotate positions and normals. Vert0 = Vert0.ApplyMatrix(xyz, nop); Vert1 = Vert1.ApplyMatrix(xyz, nop); Vert2 = Vert2.ApplyMatrix(xyz, nop); Vert3 = Vert3.ApplyMatrix(xyz, nop); // Rotate UVs for top and bottom sides. if (new Vector3(Vert0.N, Vert0.O, Vert0.P).Absolute().Rounded(digits: 2) == Vector3.UnitY) { for (var r = 0; r < rotations; r++) { Vert0 = Vert0.RotateUV(); Vert1 = Vert1.RotateUV(); Vert2 = Vert2.RotateUV(); Vert3 = Vert3.RotateUV(); } } return(this); }