Skip to content

Commit e3b920e

Browse files
committed
[css-transforms] Differ between 2D and 3D matrix decomposing.
1 parent 871d456 commit e3b920e

File tree

3 files changed

+64
-24
lines changed

3 files changed

+64
-24
lines changed

css-transforms/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2013-10-10 Dirk Schulze <dschulze@adobe.com>
2+
Differ between 2D and 3D matrix decomposing.
3+
Add defintions for a 2D matrix and a 3D matrix.
4+
Decomposing code for 2D will be added with ono of
5+
the next commits.
6+
17
2013-10-07 Dirk Schulze <dschulze@adobe.com>
28
Used value of 'isolate' on 'isolation' property causes flattening.
39

css-transforms/Overview.html

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
</a></p>
4545
<h1 class="p-name no-ref" id=title>CSS Transforms Module Level 1</h1>
4646
<h2 class="no-num no-toc no-ref heading settled heading" id=subtitle><span class=content>Editor’s Draft,
47-
<span class=dt-updated><span class=value-title title=20131007>7 October 2013</span></span></span></h2>
47+
<span class=dt-updated><span class=value-title title=20131010>10 October 2013</span></span></span></h2>
4848
<div data-fill-with=spec-metadata><dl><dt>This version:<dd><a class=u-url href=http://dev.w3.org/csswg/css-transforms/>http://dev.w3.org/csswg/css-transforms/</a><dt>Latest version:<dd><a href=http://www.w3.org/TR/css3-transforms/>http://www.w3.org/TR/css3-transforms/</a><dt>Editor’s Draft:<dd><a href=http://dev.w3.org/csswg/css-transforms/>http://dev.w3.org/csswg/css-transforms/</a><dt>Previous Versions:<dd><a href=http://www.w3.org/TR/2012/WD-css3-transforms-20120911/ rel=previous>http://www.w3.org/TR/2012/WD-css3-transforms-20120911/</a><dd><a href=http://www.w3.org/TR/2012/WD-css3-transforms-20120403/ rel=previous>http://www.w3.org/TR/2012/WD-css3-transforms-20120403/</a>
4949
<dt>Feedback:</dt>
5050
<dd><a href="mailto:public-fx@w3.org?subject=%5Bcss-transforms%5D%20feedback">public-fx@w3.org</a>
@@ -103,7 +103,7 @@ <h2 class="no-num no-toc no-ref heading settled heading" id=contents><span class
103103
</a><li><a href=#svg-syntax><span class=secno>13.2</span>Syntax of the SVG <span class=property data-link-type=propdesc title=transform>transform</span> attribute</a><ul class=toc><li><a href=#svg-transform-list><span class=secno>13.2.1</span>Transform List</a><li><a href=#svg-functional-notation><span class=secno>13.2.2</span>Functional Notation</a><li><a href=#svg-data-types><span class=secno>13.2.3</span>SVG Data Types</a><ul class=toc><li><a href=#svg-transform-value><span class=secno>13.2.3.1</span>
104104
The <span class=production data-link-type=type title="<translation-value>">&lt;translation-value&gt;</span> and <span class=production data-link-type=type title="<length>">&lt;length&gt;</span> type
105105
</a><li><a href=#svg-angle><span class=secno>13.2.3.2</span>The <span class=production data-link-type=type title="<angle>">&lt;angle&gt;</span> type</a><li><a href=#svg-number><span class=secno>13.2.3.3</span>The <span class=production data-link-type=type title="<number>">&lt;number&gt;</span> type</a></ul></ul><li><a href=#svg-gradient-transform-pattern-transform><span class=secno>13.3</span>
106-
The SVG <span class=attr-name data-link-type=maybe title=gradienttransform>gradientTransform</span> and <span class=attr-name>patternTransform</span> attributes
106+
The SVG <span class=attr-name data-link-type=maybe title=gradienttransform>gradientTransform</span> and <span class=attr-name data-link-type=maybe title=patterntransform>patternTransform</span> attributes
107107
</a><li><a href=#svg-transform-functions><span class=secno>13.4</span>
108108
SVG transform functions
109109
</a><li><a href=#svg-three-dimensional-functions><span class=secno>13.5</span>SVG and 3D transform functions</a><li><a href=#svg-user-coordinate-space><span class=secno>13.6</span>User coordinate space</a><li><a href=#transform-attribute-dom><span class=secno>13.7</span>
@@ -116,9 +116,9 @@ <h2 class="no-num no-toc no-ref heading settled heading" id=contents><span class
116116
Transform function primitives and derivatives
117117
</a><li><a href=#interpolation-of-transform-functions><span class=secno>19</span>
118118
Interpolation of primitives and derived transform functions
119-
</a><li><a href=#matrix-interpolation><span class=secno>20</span>Interpolation of Matrices</a><ul class=toc><li><a href=#decomposing-a-4x4-matrix><span class=secno>20.1</span>Decomposing a Matrix</a><li><a href=#matrix-values-interpolation><span class=secno>20.2</span>
120-
Interpolation of decomposed matrix values
121-
</a><li><a href=#matrix-recomposing><span class=secno>20.3</span>Recomposing the Matrix</a></ul><li><a href=#mathematical-description><span class=secno>21</span>
119+
</a><li><a href=#matrix-interpolation><span class=secno>20</span>Interpolation of Matrices</a><ul class=toc><li><a href=#interpolation-of-2d-matrices><span class=secno>20.1</span>Interpolation of 2D matrices</a><li><a href=#interpolation-of-3d-matrices><span class=secno>20.2</span>Interpolation of 3D matrices</a><ul class=toc><li><a href=#decomposing-a-3d-matrix><span class=secno>20.2.1</span>Decomposing a 3D Matrix</a><li><a href=#interpolation-of-decomposed-3d-matrix-values><span class=secno>20.2.2</span>
120+
Interpolation of decomposed 3D matrix values
121+
</a><li><a href=#recomposing-to-a-3D-matrix><span class=secno>20.2.3</span>Recomposing to a 3D matrix</a></ul></ul><li><a href=#mathematical-description><span class=secno>21</span>
122122
Mathematical Description of Transform Functions
123123
</a><li><a href=#conformance><span class=secno></span>
124124
Conformance</a><ul class=toc><li><a href=#conventions><span class=secno></span>
@@ -230,6 +230,14 @@ <h2 class="heading settled heading" data-level=4 id=terminology><span class=secn
230230
<dd>
231231
A matrix computed for elements in a <a data-link-type=dfn href=#3d-rendering-context title="3d rendering context">3D rendering context</a>, as described <a href=#accumulated-3d-transformation-matrix-computation>below</a>.
232232
</dd>
233+
<dt><dfn data-dfn-type=dfn data-noexport="" id=2d-matrix>2D matrix<a class=self-link href=#2d-matrix></a></dfn></dt>
234+
<dd>
235+
A 3x2 transformation matrix with 6 items or a 4x4 matrix with 16 items, where the items m<sub>31</sub>, m<sub>32</sub>, m<sub>13</sub>, m<sub>23</sub>, m<sub>43</sub>, m<sub>14</sub>, m<sub>24</sub>, m<sub>34</sub> are equal to <span class=css data-link-type=maybe title=0>0</span> and m<sub>33</sub>, m<sub>44</sub> are equal to <span class=css data-link-type=maybe title=1>1</span>.
236+
</dd>
237+
<dt><dfn data-dfn-type=dfn data-noexport="" id=3d-matrix>3D matrix<a class=self-link href=#3d-matrix></a></dfn></dt>
238+
<dd>
239+
A 4x4 matrix which does not fulfill the requirements of an <a data-link-type=dfn href=#2d-matrix title="2d matrix">2D matrix</a>.
240+
</dd>
233241
<dt><dfn data-dfn-type=dfn data-noexport="" id=identity-transform-function>identity transform function<a class=self-link href=#identity-transform-function></a></dfn></dt>
234242
<dd>
235243
A <a href=#transform-functions>transform function</a> that is equivalent to a identity 4x4 matrix (see <a href=#mathematical-description>Mathematical Description of Transform Functions</a>). Examples for identity transform functions are <span class=css data-link-type=maybe title=translate(0)>translate(0)</span>, <span class=css data-link-type=maybe title="translate3d(0, 0, 0)">translate3d(0, 0, 0)</span>, <span class=css data-link-type=maybe title=translatex(0)>translateX(0)</span>, <span class=css data-link-type=maybe title=translatey(0)>translateY(0)</span>, <span class=css data-link-type=maybe title=translatez(0)>translateZ(0)</span>, <span class=css data-link-type=maybe title=scale(1)>scale(1)</span>, <span class=css data-link-type=maybe title=scalex(1)>scaleX(1)</span>, <span class=css data-link-type=maybe title=scaley(1)>scaleY(1)</span>, <span class=css data-link-type=maybe title=scalez(1)>scaleZ(1)</span>, <span class=css data-link-type=maybe title=rotate(0)>rotate(0)</span>, <span class=css data-link-type=maybe title="rotate3d(1, 1, 1, 0)">rotate3d(1, 1, 1, 0)</span>, <span class=css data-link-type=maybe title=rotatex(0)>rotateX(0)</span>, <span class=css data-link-type=maybe title=rotatey(0)>rotateY(0)</span>, <span class=css data-link-type=maybe title=rotatez(0)>rotateZ(0)</span>, <span class=css data-link-type=maybe title="skew(0, 0)">skew(0, 0)</span>, <span class=css data-link-type=maybe title=skewx(0)>skewX(0)</span>, <span class=css data-link-type=maybe title=skewy(0)>skewY(0)</span>, <span class=css data-link-type=maybe title="matrix(1, 0, 0, 1, 0, 0)">matrix(1, 0, 0, 1, 0, 0)</span> and <span class=css data-link-type=maybe title="matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)">matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)</span>. A special case is perspective: <span class=css data-link-type=maybe title=perspective(infinity)>perspective(infinity)</span>. The value of m<sub>34</sub> becomes infinitesimal small and the transform function is therefore assumed to be equal to the identity matrix.
@@ -1101,7 +1109,7 @@ <h5 class="heading settled heading" data-level=13.2.3.3 id=svg-number><span clas
11011109
<p>SVG supports scientific notations for numbers. Therefore a <em>number</em> gets parsed like described in SVG <a href=http://www.w3.org/TR/SVG/types.html#DataTypeNumber>Basic data types</a> for SVG attributes.
11021110

11031111
<h3 class="heading settled heading" data-level=13.3 id=svg-gradient-transform-pattern-transform><span class=secno>13.3 </span><span class=content>
1104-
The SVG <a class=attr-name data-link-type=maybe href=http://www.w3.org/TR/2011/REC-SVG11-20110816/http://www.w3.org/TR/2011/REC-SVG11-20110816/pservers.html#LinearGradientElementGradientTransformAttribute title=gradienttransform>gradientTransform</a> and <a class=attr-name href=http://www.w3.org/TR/2011/REC-SVG11-20110816/pservers.html#PatternElementPatternTransformAttribute>patternTransform</a> attributes
1112+
The SVG <a class=attr-name data-link-type=maybe href=http://www.w3.org/TR/2011/REC-SVG11-20110816/http://www.w3.org/TR/2011/REC-SVG11-20110816/pservers.html#LinearGradientElementGradientTransformAttribute title=gradienttransform>gradientTransform</a> and <a class=attr-name data-link-type=maybe href=http://www.w3.org/TR/2011/REC-SVG11-20110816/http://www.w3.org/TR/2011/REC-SVG11-20110816/pservers.html#PatternElementPatternTransformAttribute title=patterntransform>patternTransform</a> attributes
11051113
</span><a class=self-link href=#svg-gradient-transform-pattern-transform></a></h3>
11061114

11071115
<p>SVG specifies the attributes <a class=attr-name data-link-type=maybe href=http://www.w3.org/TR/2011/REC-SVG11-20110816/http://www.w3.org/TR/2011/REC-SVG11-20110816/pservers.html#LinearGradientElementGradientTransformAttribute title=gradienttransform>gradientTransform</a> and <a class=attr-name href=http://www.w3.org/TR/2011/REC-SVG11-20110816/pservers.html#PatternElementPatternTransformAttribute>‘patternTransform‘</a>. This specification makes both attributes presentation attributes. Both attributes use the same <a href=#svg-syntax>syntax</a> as the SVG <a class=property data-link-type=propdesc href=#propdef-transform title=transform>transform</a> attribute. This specification does not introduce corresponding CSS style properties. Both, the <a class=attr-name data-link-type=maybe href=http://www.w3.org/TR/2011/REC-SVG11-20110816/http://www.w3.org/TR/2011/REC-SVG11-20110816/pservers.html#LinearGradientElementGradientTransformAttribute title=gradienttransform>gradientTransform</a> and the <a class=attr-name href=http://www.w3.org/TR/2011/REC-SVG11-20110816/pservers.html#PatternElementPatternTransformAttribute>‘patternTransform‘</a> attribute, are presentation attributes for the <a class=property data-link-type=propdesc href=#propdef-transform title=transform>transform</a> property.
@@ -1794,7 +1802,7 @@ <h2 class="heading settled heading" data-level=19 id=interpolation-of-transform-
17941802

17951803
<h2 class="heading settled heading" data-level=20 id=matrix-interpolation><span class=secno>20 </span><span class=content>Interpolation of Matrices</span><a class=self-link href=#matrix-interpolation></a></h2>
17961804

1797-
<p>When interpolating between two matrices, each is decomposed into the corresponding translation, rotation, scale, skew and perspective values. Not all matrices can be accurately described by these values. Those that can’t are decomposed into the most accurate representation possible, using the pseudocode in <a href=#decomposing-a-4x4-matrix>Decomposing the Matrix</a>. The resulting values get <a href=#matrix-values-interpolation>interpolated numerically</a> and <a href=#matrix-recomposing>recomposed back to a matrix</a> in a final step.
1805+
<p>When interpolating between two matrices, each matrix is decomposed into the corresponding translation, rotation, scale, skew and (for a <a data-link-type=dfn href=#3d-matrix title="3d matrix">3D matrix</a>) perspective values. Each corresponding component of the decomposed matrices gets interpolated numerically and recomposed back to a matrix in a final step.
17981806

17991807
<div class=note>
18001808
<p>
@@ -1821,11 +1829,19 @@ <h2 class="heading settled heading" data-level=20 id=matrix-interpolation><span
18211829
</p>
18221830
</div>
18231831

1832+
<p>In the following we differ between the <a href=#interpolation-of-2d-matrices>interpolation of two 2D matrices</a> and the <a href=#interpolation-of-3d-matrices>interpolation of two matrices</a> where at least one matrix is not a <a data-link-type=dfn href=#2d-matrix title="2d matrix">2D matrix</a>.
1833+
18241834
<p>If one of the matrices for interpolation is non-invertible, the used animation function must fall-back to a discrete animation according to the rules of the respective animation specification.
18251835

1826-
<p class=issue id=issue-bf7b6c81><a class=self-link href=#issue-bf7b6c81></a>The following algorithms does not create nice results for pure 2D interpolations. See <a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=17017">Bug 17017</a>.</p>
1836+
<h3 class="heading settled heading" data-level=20.1 id=interpolation-of-2d-matrices><span class=secno>20.1 </span><span class=content>Interpolation of 2D matrices</span><a class=self-link href=#interpolation-of-2d-matrices></a></h3>
1837+
1838+
<p>The pseudo code below is based upon the "unmatrix" method in "Graphics Gems II, edited by Jim Arvo".
1839+
1840+
<p class=issue id=issue-9abd49cc><a class=self-link href=#issue-9abd49cc></a>Use different algorithm for interpolation of 2D matrices. See <a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=17017">Bug 17017</a>.</p>
1841+
1842+
<h3 class="heading settled heading" data-level=20.2 id=interpolation-of-3d-matrices><span class=secno>20.2 </span><span class=content>Interpolation of 3D matrices</span><a class=self-link href=#interpolation-of-3d-matrices></a></h3>
18271843

1828-
<h3 class="heading settled heading" data-level=20.1 id=decomposing-a-4x4-matrix><span class=secno>20.1 </span><span class=content>Decomposing a Matrix</span><a class=self-link href=#decomposing-a-4x4-matrix></a></h3>
1844+
<h4 class="heading settled heading" data-level=20.2.1 id=decomposing-a-3d-matrix><span class=secno>20.2.1 </span><span class=content>Decomposing a 3D Matrix</span><a class=self-link href=#decomposing-a-3d-matrix></a></h4>
18291845

18301846
<p>The pseudo code below is based upon the "unmatrix" method in "Graphics Gems II, edited by Jim Arvo", but modified to use Quaternions instead of Euler angles to avoid the problem of Gimbal Locks.
18311847

@@ -1956,9 +1972,9 @@ <h3 class="heading settled heading" data-level=20.1 id=decomposing-a-4x4-matrix>
19561972
quaternion[2] = -quaternion[2]
19571973

19581974
return true</pre>
1959-
<h3 class="heading settled heading" data-level=20.2 id=matrix-values-interpolation><span class=secno>20.2 </span><span class=content>
1960-
Interpolation of decomposed matrix values
1961-
</span><a class=self-link href=#matrix-values-interpolation></a></h3>
1975+
<h4 class="heading settled heading" data-level=20.2.2 id=interpolation-of-decomposed-3d-matrix-values><span class=secno>20.2.2 </span><span class=content>
1976+
Interpolation of decomposed 3D matrix values
1977+
</span><a class=self-link href=#interpolation-of-decomposed-3d-matrix-values></a></h4>
19621978

19631979
<p>Each component of the decomposed values translation, scale, skew and perspective of the source matrix get linearly interpolated with each corresponding component of the destination matrix.
19641980

@@ -2001,9 +2017,9 @@ <h3 class="heading settled heading" data-level=20.2 id=matrix-values-interpolati
20012017
quaternionDst[i] = quaternionA[i] + quaternionB[i]
20022018

20032019
return</pre>
2004-
<h3 class="heading settled heading" data-level=20.3 id=matrix-recomposing><span class=secno>20.3 </span><span class=content>Recomposing the Matrix</span><a class=self-link href=#matrix-recomposing></a></h3>
2020+
<h4 class="heading settled heading" data-level=20.2.3 id=recomposing-to-a-3D-matrix><span class=secno>20.2.3 </span><span class=content>Recomposing to a 3D matrix</span><a class=self-link href=#recomposing-to-a-3D-matrix></a></h4>
20052021

2006-
<p>After interpolation the resulting values are used to transform the elements user space. One way to use these values is to recompose them into a 4x4 matrix. This can be done following the pseudo code below:
2022+
<p>After interpolation, the resulting values are used to transform the elements user space. One way to use these values is to recompose them into a 4x4 matrix. This can be done following the pseudo code below:
20072023

20082024
<pre>Input: translation ; a 3 component vector
20092025
scale ; a 3 component vector
@@ -2292,6 +2308,8 @@ <h3 class="no-num no-ref heading settled heading" id=informative><span class=con
22922308
<h2 class="no-num no-ref heading settled heading" id=index><span class=content>
22932309
Index</span><a class=self-link href=#index></a></h2>
22942310
<div data-fill-with=index><ul class=indexlist>
2311+
<li>2D matrix, <a href=#2d-matrix title="section 4">4</a>
2312+
<li>3D matrix, <a href=#3d-matrix title="section 4">4</a>
22952313
<li>3D rendering context, <a href=#3d-rendering-context title="section 4">4</a>
22962314
<li>accumulated 3D transformation matrix, <a href=#accumulated-3d-transformation-matrix title="section 4">4</a>
22972315
<li>bottom (value), <a href=#valuedef-bottom0 title="section 8">8</a>
@@ -2381,6 +2399,6 @@ <h2 class="no-num heading settled" id=issues-index><span class=content>Issues In
23812399

23822400
<p class=issue>Backface-visibility cannot be tested by only looking at m33. See <a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=23014">Bug 23014</a>.<a href=#issue-1b6023b0></a></p>
23832401

2384-
<p class=issue>The following algorithms does not create nice results for pure 2D interpolations. See <a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=17017">Bug 17017</a>.<a href=#issue-bf7b6c81></a></p>
2402+
<p class=issue>Use different algorithm for interpolation of 2D matrices. See <a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=17017">Bug 17017</a>.<a href=#issue-9abd49cc></a></p>
23852403

23862404
</div>

0 commit comments

Comments
 (0)