Re: Proposal to add unit quaternion representation to the Device Orientation event.

The idea itself to provide screen adjusted orientation is nice, but I think
there are some issues on the API / implementation level.

>From talking to Mounir I understand there can be multiple different screen
orientations per 'window'. This is in contrast to Device Orientation where
there is only one orientation per device (i.e. per browser process). In
addition to that it is technically possible to change screen orientation
while device orientation does not change so in that case screen adjusted
angles should be updated as well. Device Orientation API would need to
listen to screen orientation so would become more complicated and somewhat
duplicate the Screen Orientation API.

If we provide a quaternion I think we can get away with minimal plumbing in
javascript to compute screen orientation where needed:
let's say q is the current device orientation quaternion and A current
screen orientation angle then:

screen_q = [cos(A/2) -n*sin(A/2)] * q   (quaternion multiplication)
where n = q.Rotate([0 0 1])      (quaternion conjugation)
(i.e. n is the normal to the screen)

that way the Device Orientation / Screen Orientation APIs and their
implementations can be kept separate.


On Thu, Aug 28, 2014 at 11:07 AM, Rich Tibbett <richt@opera.com> wrote:

> On Sun, Aug 3, 2014 at 9:53 PM, Mandyam, Giridhar <mandyam@quicinc.com>
> wrote:
> > Having heard no objections, I am going to ask Tim/Rich in their capacity
> as Editors of the DeviceOrientation spec to create an ED with the
> quarternion proposal incorporated.
> >
> > Note that Mounir has posted to the public-fx list a suggestion to
> incorporate this into the Geometry specification:  see
> http://lists.w3.org/Archives/Public/public-fx/2014JulSep/0076.html.
> Thanks for Mounir for doing this.  If this feature is incorporated into the
> Geometry spec, the editors can adjust the DeviceOrientation specification
> accordingly.
>
> While I think is a good addition it does not solve the underlying
> issue of getting DeviceOrientation to work when a device's display
> rotates away from its default orientation. In addition, this is
> already a solvable problem for web developers. We have provided code
> examples to transform the provided 'alpha', 'beta' and 'gamma'
> attributes to a Unit Quaternion (and a Rotation Matrix) in the
> "Alternate device orientation representations" annex within the latest
> editor's draft @
>
> https://w3c.github.io/deviceorientation/spec-source-orientation.html#worked-example-2
> .
>
> My concern here is that giving web developers a Quaternion
> representation of the device orientation still relies on them to
> correctly transform that Quaternion relative to screen orientation
> angle changes in order for their applications to work in any screen
> orientation. Given that we still require web developers to apply their
> own screen orientation transform to this fixed device frame quaternion
> I wonder if this only partially solves the problems web developers are
> having.
>
> I would rather we provided screen-adjusted device orientation values
> on DeviceOrientation Event objects and let web developers construct
> their own Quaternions and/or Rotation Matrices in JavaScript for now.
> This issue has been discussed on public-webapps@ starting at
> http://lists.w3.org/Archives/Public/public-webapps/2014JulSep/0203.html
> and on the W3C DeviceOrientation Github issue tracker at
> https://github.com/w3c/deviceorientation/issues/4. Currently we have
> seen tentative support from Mozilla (and Opera) for this approach.
> What do other browser implementers feel about prioritizing this
> addition above and perhaps instead of adding a Quaternion
> representation to the spec?
>
> I have made a pull request for adding 'screenAlpha', 'screenBeta' and
> 'screenGamma' attributes to the DeviceOrientationEvent interface at
> https://github.com/w3c/deviceorientation/pull/10. I also currently
> have a tentative Chromium patch ready to add these attributes pending
> general consensus on this mailing list.
>
> - Rich
>
> >
> > Thanks,
> >
> > -Giri
> >
> > -----Original Message-----
> > From: Mandyam, Giridhar [mailto:mandyam@quicinc.com]
> > Sent: Thursday, July 24, 2014 8:40 AM
> > To: Mounir Lamouri; Tim Volodine; public-geolocation
> > Cc: Rich Tibbett; Rob Manson
> > Subject: RE: Proposal to add unit quaternion representation to the
> Device Orientation event.
> >
> > Hi Mounir,
> > It just went to Last Call:
> http://www.w3.org/TR/2014/WD-geometry-1-20140626/.  I wonder if we bring
> this in at this point.
> >
> > One possibility is to suggest this as a change to the Geometry I/F
> Module Level 1 spec prior to the August 7 deadline for LC comments, and go
> ahead and list the quaternion interface in DeviceOrientation until it is
> adopted in the Geometry I/F.
> >
> > Does anyone else have opinions on Mounir's suggestion?
> >
> > -Giri
> >
> > -----Original Message-----
> > From: Mounir Lamouri [mailto:mounir@lamouri.fr]
> > Sent: Thursday, July 24, 2014 8:30 AM
> > To: Mandyam, Giridhar; Tim Volodine; public-geolocation
> > Cc: Rich Tibbett; Rob Manson
> > Subject: Re: Proposal to add unit quaternion representation to the
> Device Orientation event.
> >
> > Giri, should we investigate adding this to
> http://dev.w3.org/fxtf/geometry/ ?
> >
> > -- Mounir
> >
> > On Thu, 24 Jul 2014, at 22:43, Mandyam, Giridhar wrote:
> >> If there are no objections to this proposal provided to the mailing
> >> list by 5 PM US Pacific Time, August 1, 2014, then I will request the
> >> editors (Tim and Rich) to include this proposal in the
> DeviceOrientation spec.
> >>
> >> Thanks,
> >>
> >> -Giri
> >>
> >> -----Original Message-----
> >> From: Mounir Lamouri [mailto:mounir@lamouri.fr]
> >> Sent: Thursday, July 17, 2014 3:05 AM
> >> To: Tim Volodine; public-geolocation
> >> Cc: Rich Tibbett; Rob Manson; Mandyam, Giridhar
> >> Subject: Re: Proposal to add unit quaternion representation to the
> >> Device Orientation event.
> >>
> >> On Thu, 17 Jul 2014, at 00:29, Tim Volodine wrote:
> >> > Proposed interface changes:
> >> >
> >> > [Callback, NoInterfaceObject]
> >> > interface OrientationQuaternion {
> >> >   readonly attribute double x;
> >> >   readonly attribute double y;
> >> >   readonly attribute double z;
> >> >   readonly attribute double w;
> >> > }
> >>
> >> That sounds great! Should we consider adding DOMQuaternion to
> >> http://dev.w3.org/fxtf/geometry/ instead of creating it inside this
> spec?
> >>
> >> -- Mounir
> >>
> >
>

Received on Friday, 29 August 2014 16:29:54 UTC