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

Projective/perspective transforms for points and paths #108

Closed
byorgey opened this issue Sep 12, 2013 · 2 comments
Closed

Projective/perspective transforms for points and paths #108

byorgey opened this issue Sep 12, 2013 · 2 comments

Comments

@byorgey
Copy link
Member

byorgey commented Sep 12, 2013

For diagrams in general, we can only support affine transformations, because there's no way to apply projective transformations to envelopes (though I think traces would be OK). However, there's no reason we can't apply projective transformations to simpler things.

  1. Applying projective transformations to points and linear segments is straightforward.
  2. Applying projective transformations to Bézier segments is more complicated, since cubic Béziers are not closed under projective transformation. But we could probably do something to approximate the result with a sequence of cubics.

Another important part of this ticket is figuring out a nice way to represent projective transformations that fits well with our existing representation of affine transformations, and a nice API for constructing projective transformations.

@bergey
Copy link
Member

bergey commented Sep 26, 2013

Am I understanding the problem correctly? Do you have more specific ideas about how you want to do this?

  1. We want to represent orthogonal and perspective projections, which lack inverses, and so are not proper members of our current type.

  2. We want to be able to combine our current transformations with projections:

    ex1 = invertable <> notInvertable -- obviously won't type check
    ex2 = cast invertable <> notInvertable -- so we may need something like this
    ex3 = invertable `combineProjections` notInvertable -- or this
  3. We might want to distinguish orthogonal projections from perspective, since (I think) cubic Beziers are closed under the former. Is the correctness worth the extra complexity?

I think we can accomplish (2) with two type classes, one for "geometry which can be projected", and one for "transformations which can be combined with a projection". If we only have two types, we could replace the latter with a monomorphic function.

If we want to approximate Beziers under perspective projection, I think we can do (3) with an extra field in the Projection type, rather than a new type. That keeps the API a bit cleaner.

I haven't wrapped my head around Data.LinearMap yet, but it feels wrong to use it for maps that aren't linear. Do we want to keep the memo-trie?

I also want to think more about diagrams/diagrams-core#33. The above doesn't address that problem, but having a type-correct way to express scaleX 0 might mitigate it. I think scalingX0 would actually be a decent name for that orthogonal projection.

Sorry this got so long.

@byorgey
Copy link
Member Author

byorgey commented Sep 26, 2013

(1) sounds right. I don't have much of an opinion about (2) right now. Probably the most important thing to do at this point is to think up examples of cases where one might wish to use a more general projection, and then think about what a nice API for those examples would be. That can help drive our opinions about the actual design, e.g. whether distinguishing orthogonal projections is worth it.

Re: Data.LinearMap, note that as I understand it, perspective projections are linear, if you think about them in terms of homogeneous coordinates one dimension up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants