-
Notifications
You must be signed in to change notification settings - Fork 43
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
Better handling of singular transformations #33
Comments
I think that having a special representation for singular transformations would be best. Not sure what this would look like given the current representation of It's a bit tricky, because you end up wanting to use linear equations as the output of the inverse of your linear transformation.. (e.g. for scaleX 0, you end up with a bunch of horizontal lines when asking for the). The domain of the inverse is weird too, since it ought to be restricted to the codomain of the forward transformation.. Writing this stuff in a way that doesn't cut corners, and is mostly statically checked, while maintaining usability, could be quite a challenge.. Interesting problem, though! |
Well, I guess I was thinking more along the lines that a singular transformation simply doesn't have an inverse. Whether this would be enforced statically or dynamically is still an interesting question. |
The main things that would break are the Random idea: data (:-:) u v = (u :-* (u, v)) :-: (v :-* (v, u))
-- Used to be
data (:-:) u v = (u :-* v) :-: (v :-* u) What're those extra tupled values? They let you know what actual value the input was mapped to, in order to be within the domain. So, |
Hmm... maybe I'm just being dense but I don't think I quite understand. What do the output tuples represent, exactly? And can you give some simpler examples, e.g. what would be the result of |
You're not being dense, I'm just being terse and vague. I haven't actually worked out whether these linear maps would function properly, but there are instances for tuples. Intuitively it seems like it has good chances of working. The idea is that you should be able to query the inverse of a singular matrix if you have a default way of removing the singularity. In this case that's projecting on to the span of the matrix. So, instead it's a "pseudo-inverse", maybe even this one: |
Also, need to figure out what this means for the otherwise broken
|
I am not following this at all. But it doesn't help that I am sick. I will come back and think about it more carefully once my head doesn't feel like it's full of cotton. =) |
I'm wondering if Deform solves the use cases for scaling by 0. If so, we can just document that |
Debugging the performance of |
Drat, I always get confused and think the "close" button means "close this comment box". |
The impetus for this ticket is the unfortunate code
(currently found here: https://github.com/diagrams/diagrams-core/blob/master/src/Diagrams/Core/Transform.hs#L286).
What should be done, indeed?
One idea (from @mgsloan, in a comment here), is to add a
tzero
method toTransformable
, likewhere
tzero
is defined to be the result of applying a singular transformation.It also occurs to me we might be able to move this even closer to the source by having a special representation for singular transformations. Then
tzero
is implicit in the fact thatTransformable
instances have to decide what to do about singular transformations.One important thing to note is that not all singular transformations are equal. (To be clear, by "singular" I mean "linear transformation whose corresponding matrix is non-invertible".) For example,
scale 0
andscaleX 0
are both singular, but they are not the same and it may be useful to distinguish them. For example,scaleX 0
can usefully be applied to anyPath R2
(resulting in the "projection" of the path onto the y-axis). Butscale 0
andscaleX 0
have the same result on Diagrams (that is, currently, bottom; but ideally,mempty
).The text was updated successfully, but these errors were encountered: