diagrams / diagrams-lib

Diagrams standard library
https://diagrams.github.io/
Other
138 stars 62 forks source link

extrudeEnvelope gives incorrect results #316

Closed byorgey closed 6 years ago

byorgey commented 6 years ago

From benzrf in IRC: .

Or consider

dia :: Diagram B
dia = square 1 === (square 1 # extrudeTop 1)

main = defaultMain (dia # frame 1)

which produces extrudetest You can see that the squares are clearly at distance 1/2 from each other, but should be 1.

byorgey commented 6 years ago

Apparently deformEnvelope has been buggy this whole time, but the bug was exactly canceled out by the particular way it was used in the examples in the user manual. In particular, the envelope that resulted from calling deformEnvelope gave inconsistent results depending on the length of the input vector. In particular it only worked correctly if given a vector of length exactly 2. There were strange values of 0.5 in the code which really should be 1, and another value was being divided by only the norm of the input vector where it should have been the squared norm.