-
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
Direction type #186
Direction type #186
Conversation
move some instances around, remove some imports
e :: Angle -> R2 | ||
e = fromDirection | ||
e = fromDirection . (xDir .+^) |
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 we change the name of this function and perhaps provide e as a synonym. I was really trying to avoid using e in arrowheads, it gives very little info on what the function does. Maybe something like fromAngle?
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.
Actually. I think we should get rid of e, as it's semantics have changed. Since it used to be a synonym for fromDirection.
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.
The behavior of e
in unchanged, but the type of fromDirection
has changed.
I was torn between
- not providing a function
Angle -> R2
, in favor of the newDirection
semantics - keeping one around because there's a lot of code, mostly arrowheads, that uses it
Since e
is a pun on e^i\theta
, it makes some sense that it takes an Angle. And it isn't exported from Diagrams.Preude
, mitigating my concern there. I'd be fine adding a synonym fromAngle
. Should it be exported?
I'm also fine removing e
, and rewriting code as unitX & _theta .~ foo
or similar. Does anyone besides me find that comfortable to read?
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.
I seem to recall that we all agreed several months ago to stop exporting e from prelude (although it is possible I am mistaken). I'm comfortable reading the lens based code, my only concern is that it's a bit verbose. I'm fine with either eliminating an Angler -> R2 function or renaming it to fromAngle.
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.
Why not use rotate theta unitX
? That seems simple to write and clearer than lenses or the shorthand e.
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.
I think that's a good idea.
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.
@Mathnerd314 Oh, good point
On May 16, 2014 2:38:57 PM EDT, Mathnerd314 notifications@github.com wrote:
e :: Angle -> R2
-e = fromDirection
+e = fromDirection . (xDir .+^)Why not use
rotate theta unitX
? That seems simple to write and
clearer than lenses or the shorthand e.
Reply to this email directly or view it on GitHub:
https://github.com/diagrams/diagrams-lib/pull/186/files#r12753425
Sent from my Android device with K-9 Mail. Please excuse my brevity.
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.
Agreed, we might as well keep this version of e
; @jeffreyrosenbluth remembers correctly that we no longer export it from Prelude
.
remove extra language extension pragma
My linking errors are fixed, after wiping out my entire diagrams tree and cloning all 24 diagrams-related repos anew. Go figure. |
This will also close #38. It links now; I was missing a cabal "exposed module" line. See also the associated branch of -contrib. |
What's the status of this PR? Would it be helpful for me to take a look? |
@byorgey yes, that would be great. So would feedback from anyone else. The status is: it builds, but probably shouldn't be merged until I test more and update -doc to match.
|
-- the angle @s@ counterclockwise. | ||
arcT :: Direction R2 -> Angle -> Trail R2 | ||
arcT start sweep | ||
| sweep < zeroV = arcT start (sweep ^-^ (fromIntegral d @@ turn)) | ||
| otherwise = (if sweep >= fullTurn then glueTrail else id) |
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.
I never really thought much about this before. Why do we do this glueTrail
? E.g. what if the sweep angle is 3/2 turn? Doing glueTrail
is very strange in that case. It seems the most consistent thing to do is to always generate a Line
, which may wrap around multiple times in the case of a sweep angle greater than 1 turn (or less than -1 turn). I could imagine actually being able to do useful things with such arcs, e.g. using them to parameterize animations, or applying a transformation that scales along with the parameter in order to create a spiral, etc.
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.
The current behavior (predating this PR) is that any arc which would result in more than a full circle is truncated before gluing. The Haddocks aren't very clear -- it's explained for bezierFromSweep
, but you need to know that arcT
is implemented in terms of that function. I like your proposal.
I support getting rid of the |
I should also mention that I like this very much! |
Direction R2 is not actually an AffineSpace. for all Directions d, d .+^ fullTurn = d therefore (d .+^ a) .-. d is not a for a >= fullTurn angleBetweenDirs and rotate give nearly the same behavior
Removing the I'm using I'm tempted to add a new function / operator / lens or two to make constructing Directions nicer. Thoughts on what it should be called? What the type should be? Brainstorming:
The last three allow the obvious subtraction functions, also. |
Why not create a |
I don't see why we need scale invariant at all. @bergey , what's wrong with non-uniform scaling of |
Note that |
It is not right when the intent is to create a rotation between two vectors.
This code is confusing, untested, and poorly named. It will probably change in the future. But this implementation is not obviously wrong, like the last one was.
Conflicts: src/Diagrams/TwoD/Arc.hs
I've fixed the bugs of which I am aware. I think this is ready to merge, along with the associated branches of |
I'm assuming folks are just busy. But let me know if you wanted more time to review this, or if I should be more reserved about merging my own code in future. |
I had a chance to read through the code and it looks very nice. |
Maybe. I'm pretty happy with |
This branch introduces a new direction type, distinguished from Angles and Vectors. This was discussed a bit in on trello and probably elsewhere.
I changed the semantics of the arc-generating functions substantially, because the old semantics depended on distinguishing the direction 0 from the direction
fullTurn
. I'm tempted to go farther, and eliminate the CW / CCW functions, since a start direction and a (positive or negative)Angle
seems to cover all the options. Or we could go back to taking twoDirection
s, but give up on defining circles. Or interpretarc xDir (xDir.+^fullTurn)
specially. @fryguybob what do you think?I definitely need to test the arrow code more before this can be merged.
Right now, this branch builds, but trying to build
diagrams-svg
or other packages linking to it fails with linker errors. Is that just for me, or can others reproduce?