mdn / content

The content behind MDN Web Docs
https://developer.mozilla.org
Other
9.1k stars 22.46k forks source link

Explanation of X, y, z coordinates of DeviceMotionEvent.acceleration and DeviceMotionEvent.accelerationIncludingGravity is either completely wrong or extremely confusing (or both) #22885

Open php4fan opened 1 year ago

php4fan commented 1 year ago

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent/acceleration

What specific section or headline is this issue about?

No response

What information was incorrect, unhelpful, or incomplete?

It says:

x Represents the acceleration upon the x axis which is the west to east axis y Represents the acceleration upon the y axis which is the south to north axis

z Represents the acceleration upon the z axis which is the down to up axis

Now, the definitions of "west to east" and "south to north" axes are completely unambiguous (unless you are on one of the poles), and crystal clear. And it's definitely not true that x and y correspond to west to east and north to south.

"Down to up" on its own would be potentially ambiguous, but given the other two are east to west and south to north, one can only reasonably assume that "up to down" is referring to the surface of the earth. And of course, that is also not true.

By that description, one would unambiguously understand (wrongly) that the coordinates are absolute and in no way influenced by the orientation of the device. One can only infer that the system has already done the necessary calculations behind the scene to compute those values (which by the way is only possible by using also the compass as well as the accelerometer; and also I think it would involve some heuristics, not entirely sure about that).

I couldn't believe it but it is so crystal clear and unambiguously stated, that I assumed it had to be true. But of course my gut instinct was right 🤦

What did you expect to see?

From some quick experiments, I think the reality is:

x: corresponds to the x axis of the html document (not sure if with the same sign or opposite) y: corresponds to the y axis of the html document (not sure if with the same sign or opposite) z: corresponds to the remaining perpendicular axis, so one that either points into the screen or out of the screen.

Which of course makes way more sense 🤦

And this is true both for acceleration and accelerationIncludingGravity

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

MDN metadata

Page report details * Folder: `en-us/web/api/devicemotionevent/acceleration` * MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent/acceleration * GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/api/devicemotionevent/acceleration/index.md * Last commit: https://github.com/mdn/content/commit/1511e914c6b1ce6f88056bfefd48a6aa585cebce * Document last modified: 2022-09-09T05:10:34.000Z
php4fan commented 1 year ago

x: corresponds to the x axis of the html document (not sure if with the same sign or opposite) y: corresponds to the y axis of the html document (not sure if with the same sign or opposite)

Actually it's more complicated than that.

It seems to be like that when the orientation is portrait, and rotated 90º when in landscape orientation. In other words, it's fixed with respect to the physical screen, and remains attached to it even when the browser/system changes orientation.

Anyway, whatever the specification is, it has nothing to do with east/west and north/south and should be explained correctly.

advitiya7 commented 1 year ago

@sideshowbarker hey i want to contribute to can you assign this to me ? or should i start doing it?

advitiya7 commented 1 year ago

@sideshowbarker i have already raised a PR please check it thanks

advitiya7 commented 1 year ago

@sideshowbarker any update on the changes?