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

3d color & lighting, more solids, Angle utilities #166

Merged
merged 22 commits into from
Mar 12, 2014
Merged

3d color & lighting, more solids, Angle utilities #166

merged 22 commits into from
Mar 12, 2014

Conversation

bergey
Copy link
Member

@bergey bergey commented Mar 9, 2014

Let me know if you'd rather I break this up into multiple PRs.

  • The first patch replaces the use of FillColor with some proper 3D Attributes that allow more realistic images
  • The last two patches add boxes (rectangular prisms) and Frusta (including cylinders and cones)
  • In the middle are several utility functions I wanted while writing the new solid shapes. Following the Angle type, the 3D direction type doesn't need to be a type class.

The matching branch in diagrams-povray can render these Prims and Attributes, is in the images below:

trace test for box (png)
trace test for cone (png)
source for trace tests
shading demo (png)
source for shading demo

@byorgey
Copy link
Member

byorgey commented Mar 9, 2014

This all looks good to me, except it looks like there are some warnings causing the build to fail.

@bergey
Copy link
Member Author

bergey commented Mar 9, 2014

I'm working on the warnings now, fighting with GHC about overlapping instances.

@byorgey
Copy link
Member

byorgey commented Mar 9, 2014

Ouchies, good luck.

This definition works in all vector spaces, and is probably more often
useful.  The cylindrical r is easy to refer to as cylindrical._1; it
just happens that it was the case that motivated me to write these lenses.
@bergey
Copy link
Member Author

bergey commented Mar 9, 2014

Builds now, except for 7.8.1. Note that the last patch is a change of meaning; the other two are just to fix warnings.

@@ -121,3 +121,7 @@ class HasY t where
-- | The class of types with at least three coordinates, the third called _z.
class HasZ t where
_z :: Lens' t Double

-- | _r is the vector magnitude
Copy link
Member

Choose a reason for hiding this comment

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

Can we make a better comment for this? The vector magnitude of what?

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right, that is a terrible comment. I will write something better in the morning.

Angle's aren't specific to R2, and this way 3D modules don't need to
import from 2D.
and move 3D angleBetweenDir next to the definition of Direction type
@@ -0,0 +1,113 @@
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
Copy link
Member

Choose a reason for hiding this comment

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

I like the idea of moving angle stuff into a separate module. This also paves the way for something else I'd like to think about, which is to generalize Direction over the vector space and do a better job distinguishing angles and directions (in 2D we currently conflate the two notions). (But note I'm not saying we should worry about that for this PR, it's just something I thought I would mention.)

Does Diagrams.Angle need to be added to the exported modules list in the .cabal file?

@bergey
Copy link
Member Author

bergey commented Mar 12, 2014

Incidentally, I think I've made all the changes @byorgey suggested, so it might be good to go. Thanks for all the feedback! (And I think a polymorphic type for Direction would be nice.)

@byorgey
Copy link
Member

byorgey commented Mar 12, 2014

Oh, one more thing, is Diagrams.Angle re-exported from Diagrams.Prelude? I don't see it, but I might have missed it.

@bergey
Copy link
Member Author

bergey commented Mar 12, 2014

It's reexported from Diagrams.TwoD, so indirectly from Diagrams.Prelude. (And also from Diagrams.ThreeD). I did that because the functions used to be in TwoD, but I see that's inconsistent with everything else.

@byorgey
Copy link
Member

byorgey commented Mar 12, 2014

Oh, I see, I missed that it was exported from Diagrams.TwoD and Diagrams.ThreeD. But yes, it's probably simpler to export it directly from Diagrams.Prelude since it's no longer 2D-specific.

byorgey added a commit that referenced this pull request Mar 12, 2014
3d color & lighting, more solids, Angle utilities
@byorgey byorgey merged commit cc73190 into master Mar 12, 2014
@byorgey byorgey deleted the 3d-color branch March 12, 2014 01:48
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.

None yet

2 participants