Skip to content
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

Associativity issue because w is not multiplied #157

Merged
merged 1 commit into from Sep 13, 2016

Conversation

@peterjoel
Copy link
Contributor

peterjoel commented Aug 17, 2016

Transforming a point by two matrices in sequence should be the same as premultiplying the matrices and performing one transformation.

The issue appears to be because the w field of the point is assumed to be always 1.


This change is Reviewable

fn approx_eq(&self, other: &Self) -> bool {
self.approx_eq_eps(&other, &Self::approx_epsilon())
}
}

This comment has been minimized.

@nox

nox Aug 18, 2016

Member

Funky indentation.

@bors-servo
Copy link
Contributor

bors-servo commented Aug 18, 2016

The latest upstream changes (presumably #149) made this pull request unmergeable. Please resolve the merge conflicts.

@peterjoel peterjoel force-pushed the peterjoel:associativity_w branch from 05d6263 to df9487c Aug 20, 2016
@peterjoel
Copy link
Contributor Author

peterjoel commented Aug 24, 2016

@nical What should be done here? Is it intentional that users can't treat a Matrix4D as a general-purpose 4x4 matrix? I feel like m14, m24 & m34 shouldn't be exposed if setting them to non-zero values can cause unexpected results. Likewise for m44 being set to a non-unit value.

@nical
Copy link
Collaborator

nical commented Aug 25, 2016

I am in favor of fixing the 4D multiplication the way you propose in your patch.

@peterjoel
Copy link
Contributor Author

peterjoel commented Aug 25, 2016

Ok. I think it's worth mentioning that Firefox currently implements it without the multiplying w, and produces identical results to the current unpatched Euclid. If we merge my patch then we should log an issue with Firefox too.

@nical
Copy link
Collaborator

nical commented Aug 25, 2016

Yes, I'll handle the gecko side, we should definitely have the same behavior to avoid interop headaches.

@nical
Copy link
Collaborator

nical commented Aug 25, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Sep 9, 2016

The latest upstream changes (presumably #163) made this pull request unmergeable. Please resolve the merge conflicts.

@nical
Copy link
Collaborator

nical commented Sep 9, 2016

We should merge this. The gecko equivalent has landed in mozilla-central, by the way.

@nox
Copy link
Member

nox commented Sep 9, 2016

@peterjoel needs to rebase it.

@peterjoel peterjoel force-pushed the peterjoel:associativity_w branch from df9487c to 2968443 Sep 9, 2016
@peterjoel
Copy link
Contributor Author

peterjoel commented Sep 9, 2016

@nox @nical Rebased

@nox
Copy link
Member

nox commented Sep 13, 2016

@bors-servo delegate=nical

@bors-servo
Copy link
Contributor

bors-servo commented Sep 13, 2016

✌️ @nical can now approve this pull request

@nical
Copy link
Collaborator

nical commented Sep 13, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Sep 13, 2016

📌 Commit 2968443 has been approved by nical

@bors-servo
Copy link
Contributor

bors-servo commented Sep 13, 2016

Testing commit 2968443 with merge e20f274...

bors-servo added a commit that referenced this pull request Sep 13, 2016
Associativity issue because w is not multiplied

Transforming a point by two matrices in sequence should be the same as premultiplying the matrices and performing one transformation.

The issue appears to be because the `w` field of the point is assumed to be always 1.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/euclid/157)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Sep 13, 2016

☀️ Test successful - status-travis

@bors-servo bors-servo merged commit 2968443 into servo:master Sep 13, 2016
1 check passed
1 check passed
homu Test successful
Details
bors-servo added a commit that referenced this pull request May 26, 2017
Separate Point and Vector types

This changeset implements my proposal from issue #151:
- TypedVector2D and TypedVector3D types are added (no 4D vector)
- Matrix types implement separate transformations for points and vectors
- the 4D vector is removed, and along with it the bug-prone behavior of ignoring its w component half of the time.
- Point arithmetic is changed so that:
  - Point + Point is not implemented
  - Point + Vector = Point
  - Point - Point = Vector

With points and vectors as separate types, we don't need the 4D types anymore because the homogeneous coordinate is part type itself: for vectors it is always zero, and for points it is always one. Matrix transformations always divide the resulting points by w. It avoids the confusion that motivated the PR #157, where w was ignored in half of euclid because the code expected it to be equal to one.

<!-- Reviewable:start -->

---

This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/euclid/159)

<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.