-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
GfPlane::_distance
appears to have the wrong sign or docs could use some more clarification
#3436
Comments
If you look at the some of the other Set functions
We can see that _distance follows the convention that a positive distance represents the side of the plane in the direction of the normal vector. As you mentioned, GfPlane is self consistent in this regard. In the GfVec4 case, the plane equation is given as Ax+By+Cz+D=0. To store the distance in the conventional signed form, I see your point about clarity, perhaps an additional comment on that Set could mention that the plane is stored as { eqn[0], eqn[1],+ eqn[2], distance } and therefore distance is -eqn[3]. |
Thanks so much for the quick response - I think I understand what the code is doing now. To rephrase a little : In standard form, the distance from the origin of a plane defined by This is undesirable for graphics applications because it's more intuitive to think about distance along the plane normal to be positive. The standard form considers the distance away from the plane normal to be positive (ie : the plane is running away from the origin). OpenUSD resolves this with a slight reformulation of the plane equation : So that now when we try to find the point to plane distance : Like you said, I think the confusion can be resolved with just a single comment, so that those who are expecting the standard form know not to look for it : - /// \p eqn[0] * x + \p eqn[1] * y + \p eqn[2] * z + \p eqn[3] = 0.
+ /// \p eqn[0] * x + \p eqn[1] * y + \p eqn[2] * z - \p eqn[3] = 0. Thanks again for your help! |
Filed as internal issue #USD-10460 |
Description of Issue
According to this comment block, the equation of a plane in
GfPlane
is in standard form :OpenUSD/pxr/base/gf/plane.h
Lines 66 to 70 in 9b0c13b
Since all constructors normalize the incoming
normal
vector, we can further assume thatGfPlane
is in Hessian Normal Form. We can derive that form here.For brevity, we can map the code to the variables above :$a$ , $b$ , $c$ , and $d$ .
eqn[0]
=eqn[1]
=eqn[2]
=eqn[3]
=The following block expands the vector of coefficients$-d$ .
eqn
but sets_distance = -eqn[3]
=OpenUSD/pxr/base/gf/plane.cpp
Lines 44 to 56 in 9b0c13b
We can derive the point$\mathbf{p}$ to plane distance $D$ , assuming $\mathbf{x}$ is some point on the plane :
Plugging in$\mathbf{p} = \mathbf{0}$ , we get that the origin to plane distance is actually $+d$ and not $-d$ like the code suggests.
I was curious if this is a bug or an undocumented sign convention. All other "distance" functions use$-d$ is
-_distance
so I believeGfPlane
is self consistent. The only one that actually returnsGfPlane::GetDistanceFromOrigin
.Steps to Reproduce
N/A
System Information (OS, Hardware)
N/A
Package Versions
N/A
Build Flags
N/A
The text was updated successfully, but these errors were encountered: