-
Notifications
You must be signed in to change notification settings - Fork 28
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
Fully specify coordinate system of hit test result #89
base: main
Are you sure you want to change the base?
Conversation
index.bs
Outdated
<div class="algorithm" data-algorithm="calculate-native-origin"> | ||
|
||
To <dfn>calculate the native origin</dfn> given [=native hit test result=] |result| and {{XRRay}} |offsetRay|, the user agent MUST run the following steps: | ||
1. Let |coord| be a coordinate system defined by |offsetRay|'s {{XRRay/matrix}}. Let |X|, |Y|, and |Z| be the axes of coordinate system |coord|. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general we talk in terms of position and rotation transforms, do you have a way of framing this in those terms, using cross products and operations like "rotate vector by rotation"?
I'd eventually like to write a separate geometry primitives spec so that we can talk about these operations properly, but until then I am wary of introducing new operations like "let X be the coordinate system defined by matrix".
For example, here |Z|
is simply "rotate (0, 0, -1)
by rotation"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, |Z|
is simply the direction
of the ray 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me try to make it a bit more precise, I'll flip the PR into "draft" for the time being (I've noticed that I should probably be talking about angles between vector and its projection onto some plane instead of angles between planes to make this work correctly). I think |-Z|
is the direction of the ray, based on how we construct the ray's matrix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reworked the algorithm a bit, should be equivalent to what was previously here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems okay, I wish the math were a little bit more concrete, perhaps with flavortext explaining what things are conceptually
@toji @Manishearth @cabanier - PTAL, resurrected this PR given that we now have an interop issue related to underspecification of the pose. Also fixes #114. |
Thanks for making that change. |
Hmm, my intuition would be to fully specify the pose to something in all cases, and let the apps decide if they want to orient placed objects differently. And since we IMO need to fully specify the pose, we may as well specify it the same way for vertical planes as we do for horizontal planes (also note that hit-tests are not guaranteed to all come from planes, so we should probably use "hit test result normal").
Hit test pose should already be using hit test result's normal for the Y axis - is that what you are referring to here, or is it something else? |
1. Let |origin| be |offsetRay|'s {{XRRay/origin}}. | ||
1. Let |Z| be a directional vector resulting from normalizing |origin| - |p|. | ||
1. If |Z| and |normal| are parallel (i.e. they are supported by parallel lines), set |Z| to <code>{ x: 0.0, y: 1.0, z: 00, w: 0.0 }</code>. | ||
1. If |Z| and |normal| are parallel, set |Z| to <code>{ x: 1.0, y: 0.0, z: 0.0, w: 0.0 }</code>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy-paste error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you referring to potentially setting |Z| twice? Note the different vectors (line 710 is Y=1, line 711 is X=1) - this is needed since there's an edge case where normal is parallel to |origin| - |p|
and to Y=1 at the same time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, perhaps worth using a non normative inline note explaining this.
1. If |Z| and |normal| are parallel (i.e. they are supported by parallel lines), set |Z| to <code>{ x: 0.0, y: 1.0, z: 00, w: 0.0 }</code>. | ||
1. If |Z| and |normal| are parallel, set |Z| to <code>{ x: 1.0, y: 0.0, z: 0.0, w: 0.0 }</code>. | ||
1. Let |X| be a directonal vector resutling from normalizing |normal| x |Z|. | ||
1. Let |rotation| be a rotation that maps |X| to directional vector <code>{ x: 1.0, y: 0.0, z: 0.0, w: 0.0 }</code>, |normal| to directional vector <code>{ x: 0.0, y: 1.0, z: 0.0, w: 0.0 }</code>, and |Z| to directonal vector <code>{ x: 0.0, y: 0.0, z: 1.0, w: 0.0 }</code>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is underspecified and probably should be mathed out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, hmm, we don't do the math in any part of the spec, and instead use wording like
Set transform’s orientation to the orientation of space’s effective origin in baseSpace’s coordinate system.
Perhaps stick to that kind of wording?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is underspecified and probably should be mathed out
My understanding is that it's not underspecified for our purposes? We need a specific orientation of the newly created pose and do not really care what rotation was used to achieve it, as long as the end result is as described.
(...) Perhaps stick to that kind of wording?
The problem I have here is that I don't have an effective origin. I know the axes of the coordinate system when expressed in other space's coordinate system (|X|, |normal|, and |Z|, expressed relative to |coordinate system|), and all we need here is a coordinate system change matrix ("just smack those vectors in a matrix and you're done"), but I don't really see how to express it differently. 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, fair.
See the discussion for #86 for details.
/cc @Manishearth
Preview | Diff
Preview | Diff