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

@peterjoel 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())
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funky indentation.

@bors-servo
Copy link
Contributor

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

@peterjoel
Copy link
Author

@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
Contributor

nical commented Aug 25, 2016

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

@peterjoel
Copy link
Author

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
Contributor

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
Contributor

nical commented Aug 25, 2016

@bors-servo
Copy link
Contributor

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

@nical
Copy link
Contributor

nical commented Sep 9, 2016

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

@nox
Copy link
Contributor

nox commented Sep 9, 2016

@peterjoel needs to rebase it.

@peterjoel
Copy link
Author

@nox @nical Rebased

@nox
Copy link
Contributor

nox commented Sep 13, 2016

@bors-servo delegate=nical

@bors-servo
Copy link
Contributor

✌️ @nical can now approve this pull request

@nical
Copy link
Contributor

nical commented Sep 13, 2016

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit 2968443 has been approved by nical

@bors-servo
Copy link
Contributor

⌛ Testing commit 2968443 with merge e20f274...

bors-servo pushed 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

☀️ Test successful - status-travis

@bors-servo bors-servo merged commit 2968443 into servo:master Sep 13, 2016
bors-servo pushed 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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants