-
Notifications
You must be signed in to change notification settings - Fork 62
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
Projections #229
Projections #229
Conversation
Thank you for adding the matrix-to-Transformation code. That's been a weird omission.
Do you think |
I've been thinking about how to do projective transforms. Ideally we would use rational Bézier curves, which are closed under projective transforms and have lots of other nice properties. But it looks like a lot of work. For now I was going to use I don't think I can use |
Yeah, I wrote some NURBs code. Not as fun as I expected, and since then the folks who wrote the book on NURBs have come out against NURBS. =) I think rational curves have much less to recommend them in 2D than in 3D, since we already have a good story about continuity, and we want to output integral Bezier curves. (With 3D, there's the option to pass rational Bezier surfaces to a geometry shader on the GPU, and approximate by segments / triangles there.) Unfortunately, the recursive subdivision I implemented for Ah yes, still waiting for higher order functors =) |
Ah OK. I saw some things about approximating rational Béziers with normal ones which should be a lot better than the current |
Sounds good. (Except the part about you not knowing everything.) Let me know how I can help. |
I've tried to make a start at projections. The orthographic ones seems OKish but I struggling with perspective projections (never used homogenous coordinates before). Could you take a look @bergey? There's a house path for you to play with :) |
I think you want something like m44Deformation :: M44 Double -> Deformation V3 V2 Double
m44Deformation m =
Deformation (P . view _xy . normalizePoint . (m !*) . point . view _Point)
|
I've had a little look at rational approximation and found a couple of papers: http://link.springer.com/article/10.1007%2FBF02936562 but I haven't looked at them properly. Maybe one of us could look at this later to replace I'll leave cameras for now. For me they feel like a backend thing. Maybe we can deal with it when we get more 3D backends. Even thought this PR isn't particularly useful on it's own it's a start. I think this is ready to merge. |
facingXY = lookingAt unitX origin zDir | ||
|
||
facingXZ :: (Epsilon n, Floating n) => AffineMap V3 V2 n | ||
facingXZ = lookingAt unitY origin yDir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain the naming convention here? Also, up and forward shouldn't be the same direction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My idea was to have projections for facing the xy, xz, and yz planes in the "natural" way. Looking at them now they're clearly wrong :)
I'm sorry it's taken me so long to respond to this. I definitely want to merge the matrix -> It feels a bit heavy-weight to me, adding two types and the associated type classes & combinators, when I know, usually I'm the one trying to add more types. One argument in favor is that the implementation is simpler for |
I see where you're coming from. There's no real need for the The nice thing about splitting it into affine and linear maps is we can change the number type with the linear map and the affine map class follows nicely. But I'm open to any simpler solutions. |
That's a good point about the matrix conversion. I wouldn't expect anyone to want a non-invertible matrix, but that leaves users writing a The only simpler solution I've come up with is like this (please excuse my poor naming): reduceV :: (Coordinates vn, Decomposition vn ~ (u n :& n)) => vn -> u n
reduceV (coords -> u :& _) = u
class ReduceDim t where
reduce :: (Coordinates (v n), Decomposition (v n) ~ (u n :& n)) => t v n -> t u n
instance ReduceDim Point where
reduce (P v) = P $ reduceV v I'm undecided about what usage pattern is most readable. What do you think? -- this PR
dia2 = amap facingXY . transform t $ dia3
-- this PR plus new combinator
dia2 = amap (facingXY `amapTimesTr` t) dia3
-- ReduceDim
dia2 = reduce . transform t $ dia3 |
Just having reduce means we'd lose some functionally, like promoting planar paths to In terms of readable patterns, I don't expect most users to use this class directly. It's meant as a tool for other things like a |
Sounds good. Once you fix up the |
3D attributes haven't been changed yet. This requires changes to the povray backend.
Now _Attribute is an Iso and _attribute is a lens onto the attribute in a style.
They're just added noise, you never really use them because you need to know the types. We can always add them later.
There's no need to use the maybe value, transparent it equivilent to no fill. This reverts commit 731f181.
a87ea5a
to
844b100
Compare
Sorry it took so long to make the small fixes, I'll merge this too after travis builds. |
Great. I was worried that the ball was in my court, and I'd forgotten. |
Nah, I was just busy on doc and forgot about it. Speaking of which there's diagrams/diagrams-doc#79 if you're looking for something to do :) If not I'll get back to it eventually. I just got a little bored and needed a break from it. |
I won't get to it this weekend, but likely later this week. |
Great, thanks. |
Not ready.
Just a start at projections of path-like things. I'm still working things out and open to suggestions.
LinearMappable
classAffineMappable
classCamera
sDeformable