Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make "Converting..." section normative #410

Merged
merged 1 commit into from Sep 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 8 additions & 19 deletions index.html
Expand Up @@ -324,23 +324,6 @@ <h2><code>PointerEvent</code> interface</h2>

<p>The <dfn>PointerEventInit</dfn> dictionary is used by the {{PointerEvent}} interface's constructor to provide a mechanism by which to construct untrusted (synthetic) pointer events. It inherits from the {{MouseEventInit}} dictionary defined in [[UIEVENTS]]. The [=event constructing steps=] are defined in the [[[DOM]]]. See the <a href="#examples" title="examples">examples</a> for sample code demonstrating how to fire an untrusted pointer event.</p>

<div class="note">
<p>Pointer Events include two complementary sets of attributes to express the orientation of a
transducer relative to the X-Y plane: <code>tiltX</code> / <code>tiltY</code>
(introduced in the original Pointer Events specification), and
<code>azimuthAngle</code> / <code>altitudeAngle</code>
(adopted from the <a href="https://w3c.github.io/touch-events/">Touch Events - Level 2</a> specification).
Implementations SHOULD provide both sets of attributes for trusted events.</p>
<p>When an untrusted (synthetic) Pointer Event is created programmatically using the constructor,
and only one set of attributes is provided, the complementary set of attributes SHOULD be calculated and
initialized by the user agent. If both sets of attributes are provided, no calculation should be performed.
If only the value of one of the two attributes is provided, the other attribute SHOULD be initialized to
the default value.</p>
<p>When the user agent calculates <code>tiltX</code> / <code>tiltY</code> from
<code>azimuthAngle</code> / <code>altitudeAngle</code> it SHOULD round the final integer values using
<a data-cite="ECMASCRIPT#sec-math.round">Math.round</a> [[ECMASCRIPT]] rules.</p>
</div>

<div class="note">The <code>PointerEvent</code> interface inherits from {{MouseEvent}}, defined in [[[UIEVENTS]]].
Also note the proposed extension in [[[CSSOM-VIEW]]], which changes the various coordinate properties from <code>long</code>
to <code>double</code> to allow for fractional coordinates. For user agents that already implement this proposed extension for
Expand Down Expand Up @@ -1268,9 +1251,15 @@ <h2>Mapping for devices that do not support hover</h2>
</div>
</section>
</section>
<section class='informative'>
<section>
<h2>Converting between <code>tiltX</code> / <code>tiltY</code> and <code>altitudeAngle</code> / <code>azimuthAngle</code></h2>
<p>Depending on the specific hardware and platform, user agents will likely only receive one set of values for the transducer orientation relative to the screen plane — either <code>tiltX</code> / <code>tiltY</code> or <code>altitudeAngle</code> / <code>azimuthAngle</code>. The following basic code provides an initial suggested approach for converting these values.</p>
<p>Pointer Events include two complementary sets of attributes to express the orientation of a transducer relative to the X-Y plane:
<code>tiltX</code> / <code>tiltY</code> (introduced in the original Pointer Events specification), and
<code>azimuthAngle</code> / <code>altitudeAngle</code>
(adopted from the <a href="https://w3c.github.io/touch-events/">Touch Events - Level 2</a> specification).</p>
patrickhlauke marked this conversation as resolved.
Show resolved Hide resolved
<p>Depending on the specific hardware and platform, user agents will likely only receive one set of values for the transducer orientation relative to the screen plane — either <code>tiltX</code> / <code>tiltY</code> or <code>altitudeAngle</code> / <code>azimuthAngle</code>. User agents MUST use the following algorithm for converting these values.</p>
<p>When the user agent calculates <code>tiltX</code> / <code>tiltY</code> from <code>azimuthAngle</code> / <code>altitudeAngle</code> it SHOULD
round the final integer values using <a data-cite="ECMASCRIPT#sec-math.round">Math.round</a> [[ECMASCRIPT]] rules.</p>
<pre id="example_12" class="example" title="Converting between tiltX/tiltY and altitudeAngle/azimuthAngle"><code>/* Converting between tiltX/tiltY and altitudeAngle/azimuthAngle */

function spherical2tilt(altitudeAngle, azimuthAngle){
Expand Down