Skip to content

Commit 3b30438

Browse files
zcorpansvgeesus
authored andcommitted
Define better how to transform a point with a matrix
Fixes #183.
1 parent 5f3abd6 commit 3b30438

File tree

1 file changed

+51
-16
lines changed

1 file changed

+51
-16
lines changed

geometry/Overview.bs

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -183,20 +183,13 @@ steps:
183183
method, when invoked, must run the following steps:
184184

185185
<ol>
186-
<li><p>Create a new {{DOMPoint}} <var>point</var> initialized to {{DOMPoint/x}}, {{DOMPoint/y}},
187-
{{DOMPoint/z}} and {{DOMPoint/w}} of the current point.
188-
189186
<li><p>Let <var>matrixObject</var> be the result of invoking <a>create a <code>DOMMatrix</code>
190187
from the dictionary</a> <var>matrix</var>.
191188

192-
<li><a for=matrix>Post-multiply</a> <var>point</var> with <var>matrixObject</var>.
193-
194-
<li><p>Return <var>point</var>.
189+
<li><p>Return the result of invoking <a>transform a point with a matrix</a>, given the current
190+
point and <var>matrixObject</var>. The current point does not get modified.
195191
</ol>
196192

197-
<p>{{DOMPointReadOnly/matrixTransform()}} does not modify the current {{DOMPointReadOnly}} object
198-
and returns a new {{DOMPoint}} object.
199-
200193
<div class=example>
201194
<p>In this example the method {{DOMPointReadOnly/matrixTransform()}} on a {{DOMPoint}} instance is
202195
called with a {{DOMMatrix}} instance as argument.
@@ -215,6 +208,51 @@ and returns a new {{DOMPoint}} object.
215208
</div>
216209

217210

211+
<h3 id=transforming-a-point-with-a-matrix>Transforming a point with a matrix</h3>
212+
213+
<p>To <dfn export>transform a <a>point</a> with a <a>matrix</a></dfn>, given <var>point</var> and
214+
<var>matrix</var>:
215+
216+
<ol>
217+
<li><p>Let <var>x</var> be <var>point</var>'s <a for=point>x coordinate</a>.
218+
219+
<li><p>Let <var>y</var> be <var>point</var>'s <a for=point>y coordinate</a>.
220+
221+
<li><p>Let <var>z</var> be <var>point</var>'s <a for=point>z coordinate</a>.
222+
223+
<li><p>Let <var>w</var> be <var>point</var>'s <a for=point>w perspective</a>.
224+
225+
<li>
226+
<p>Let <var>pointVector</var> be a new column vector with the elements being <var>x</var>,
227+
<var>y</var>, <var>z</var>, and <var>w</var>, respectively.
228+
229+
<p><math display=inline><mrow><mfenced open=[ close=]><mrow><mtable><mtr><mtd><mi>x</mi></mtd></mtr><mtr><mtd><mi>y</mi></mtd></mtr><mtr><mtd><mi>z</mi></mtd></mtr><mtr><mtd><mi>w</mi></mtd></mtr></mtable></mrow></mfenced></mrow></math>
230+
231+
<li><p>Set <var>pointVector</var> to <var>pointVector</var> <a for=matrix>post-multiplied</a> by
232+
<var>matrix</var>.
233+
234+
<li><p>Let <var>transformedPoint</var> be a new {{DOMPoint}} object.
235+
236+
<li><p>Set <var>transformedPoint</var>'s <a for=point>x coordinate</a> to <var>pointVector</var>'s
237+
first element.
238+
239+
<li><p>Set <var>transformedPoint</var>'s <a for=point>y coordinate</a> to <var>pointVector</var>'s
240+
second element.
241+
242+
<li><p>Set <var>transformedPoint</var>'s <a for=point>z coordinate</a> to <var>pointVector</var>'s
243+
third element.
244+
245+
<li><p>Set <var>transformedPoint</var>'s <a for=point>w perspective</a> to <var>pointVector</var>'s
246+
fourth element.
247+
248+
<li><p>Return <var>transformedPoint</var>.
249+
</ol>
250+
251+
<p class=note>If <var>matrix</var>'s <a for=matrix>is 2D</a> is true, <var>point</var>'s <a
252+
for=point>z coordinate</a> is ''0'' or ''-0'', and <var>point</var>'s <a for=point>w perspective</a>
253+
is ''1'', then this is a 2D transformation. Otherwise this is a 3D transformation.
254+
255+
218256
<h2 id=DOMRect>The DOMRect interfaces</h2>
219257

220258
<p>Objects implementing the {{DOMRectReadOnly}} interface represent a <dfn>rectangle</dfn>. The type
@@ -1395,13 +1433,9 @@ export>is 2D</dfn>. This flag indicates that:
13951433
<dt><dfn>transformPoint(<var>point</var>)</dfn>
13961434
<dd>
13971435
<p>Let <var>pointObject</var> be the result of invoking <a>create a <code>DOMPoint</code> from the
1398-
dictionary</a> <var>point</var>. <var>pointObject</var> is <a for=matrix>post-multiplied</a> to
1399-
the current matrix and returns the resulting point. The passed argument does not get modified.
1400-
1401-
<p class=note>Even if {{DOMMatrixReadOnly/is2D}} of the current matrix returns <code>true</code>,
1402-
a 4x4 matrix multiplication will be performed if the {{DOMPointReadOnly/z}} attribute of
1403-
<var>point</var> is not ''0'' or ''-0'' or the {{DOMPointReadOnly/w}} attribute of
1404-
<var>point</var> is not ''1''.
1436+
dictionary</a> <var>point</var>. Return the result of invoking <a>transform a point with a
1437+
matrix</a>, given <var>pointObject</var> and the current matrix. The passed argument does not get
1438+
modified.
14051439

14061440
<dt><dfn>toFloat32Array()</dfn>
14071441
<dd><p>Returns the serialized 16 elements {{DOMMatrixReadOnly/m11}} to {{DOMMatrixReadOnly/m44}} of
@@ -2190,6 +2224,7 @@ Max Vujovic,
21902224
Mike Taylor,
21912225
Peter Hall,
21922226
Philip Jägenstedt,
2227+
Simon Fraser,
21932228
and
21942229
Timothy Loh
21952230
for their careful reviews, comments, and corrections.

0 commit comments

Comments
 (0)