Skip to content

Commit

Permalink
Fix rotate_to_matrix.
Browse files Browse the repository at this point in the history
We used transposed matrices for rotate before this fix.

https://www.w3.org/TR/css-transforms-1/#Rotate3dDefined
  • Loading branch information
Hiroyuki Ikezoe committed Jul 28, 2017
1 parent 12a49dc commit 81e51b3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions components/style/properties/helpers/animated_properties.mako.rs
Expand Up @@ -1738,25 +1738,25 @@ fn add_weighted_transform_lists(from_list: &[TransformOperation],
TransformList(Some(result))
}

/// https://drafts.csswg.org/css-transforms/#Rotate3dDefined
/// https://www.w3.org/TR/css-transforms-1/#Rotate3dDefined
fn rotate_to_matrix(x: f32, y: f32, z: f32, a: Angle) -> ComputedMatrix {
let half_rad = a.radians() / 2.0;
let sc = (half_rad).sin() * (half_rad).cos();
let sq = (half_rad).sin().powi(2);

ComputedMatrix {
m11: 1.0 - 2.0 * (y * y + z * z) * sq,
m12: 2.0 * (x * y * sq - z * sc),
m13: 2.0 * (x * z * sq + y * sc),
m12: 2.0 * (x * y * sq + z * sc),
m13: 2.0 * (x * z * sq - y * sc),
m14: 0.0,

m21: 2.0 * (x * y * sq + z * sc),
m21: 2.0 * (x * y * sq - z * sc),
m22: 1.0 - 2.0 * (x * x + z * z) * sq,
m23: 2.0 * (y * z * sq - x * sc),
m23: 2.0 * (y * z * sq + x * sc),
m24: 0.0,

m31: 2.0 * (x * z * sq - y * sc),
m32: 2.0 * (y * z * sq + x * sc),
m31: 2.0 * (x * z * sq + y * sc),
m32: 2.0 * (y * z * sq - x * sc),
m33: 1.0 - 2.0 * (x * x + y * y) * sq,
m34: 0.0,

Expand Down

0 comments on commit 81e51b3

Please sign in to comment.