immersive-web / hit-test

https://immersive-web.github.io/hit-test/
Other
78 stars 31 forks source link

XRRay.direction should have a w of 1. #81

Closed Manishearth closed 4 years ago

Manishearth commented 4 years ago

The direction attribute defines the ray’s 3-dimensional directional vector. The direction's w attribute MUST be 0.0 and the vector MUST be normalized to have a length of 1.0.

This doesn't make sense, if it's a vector the w should be 1, not 0, homogeneous space vectors with a w of 0 are meaningless.

Manishearth commented 4 years ago

The constructor test will also need to be updated

Manishearth commented 4 years ago

We could also return a type error if the w is not 1, or normalize to 1

bialpio commented 4 years ago

Homogenoeous space vectors with w of 0 represent points at infinity, which can be viewed as representing a direction - it is exactly what we need here. Transforming those vectors by 4x4 matrices does not apply translation parts to them, which is the expected behavior for a direction.

Manishearth commented 4 years ago

Hmmm, I think talking about the length of this vector is incorrect, then, this cannot be "normalized" to have a length of 1 since it has a length of infinity, but I get what's being said. Perhaps we should change it to say "the first three components normalized to have a length of 1.0"?

Manishearth commented 4 years ago

closing, it's not super important to make that clarification but i might open a PR later.

bialpio commented 4 years ago

(...) since it has a length of infinity (...)

I'd be careful with transferring concepts from 3D Euclidean space to projective space, I do not have good intuitions on what happens there (what's a length? distance from the origin? how is distance defined in projective space? what is an origin in projective space?). The way I explain the normalization algorithm to myself is that given a point (x, y, z, 0) we can import it to Euclidean space as a vector (representing direction b/c it was a point at infinity), calculate its length L in a familiar way where stuff makes sense, and then export it back to projective space as (x/L, y/L, z/L, 0).

In general, I'd prefer this spec to stay less math-focused (as long as it's clear what needs to happen) - it may be a good idea to open issues on the Geometry Interfaces Module spec if there are concepts that require clarification or more theory that backs up the math is needed.

Manishearth commented 4 years ago

My experiences are that computer science usage of the terminology of homogeneous spaces is highly inconsistent and it's better to be specific.