overlaping diagrams and peformance issue

34 views
Skip to first unread message

carl greifenkla

unread,
Aug 24, 2019, 2:53:00 PM8/24/19
to diagrams-discuss
hi there !
i'm new to haskell and new to diagrams.

Screenshot from 2019-08-24 20-38-01.png



my first question is if two "objects" of type Diagram B can be intersected at path level  (substracted, joined, excluded)

a,b,c::Diagram B
a = circle 1
b = square 1 # translate (r2 (1,1))
c = a intersected b 

/ resulting in a closed curve with two right edges and a bit of arc of circle
(mconcat , atop' seems to stack layers, maybe there is an option with them)

second question is about an gif animation
i don't want to dwell to much in to detail about how haskell does lazy evaluation
initially i believed it's the fault of my computer, than after upgrading with some ram  and increasing the swap memory
the application takes more than 40 Gb of ram and after finnishing the reserved memory its get killed by the operating system

why using a function that contain -  circle (sqrt (( i+3*de)^2 -12^2))  -seems to create this ?
and - circle ( i+3*de) works fine ?
one idea i have is because of some rounding error caused by Double type

new-function-without-rounding-errors :: Double->Diagram B

typing errors are not presents when compiled

maybe i'm not using the right approach
if it's caused by some obvious error how could i check the root cause .
 what would be a hint/ path for resolving it ?


Message has been deleted

carl greifenkla

unread,
Aug 25, 2019, 4:30:56 AM8/25/19
to diagrams-discuss
first question apparently already have an answer on this group (cabal install does not work - next thing i'm doing to download the pack via github)

Screenshot from 2019-08-25 10-55-35.png


dfs

Nao Fujinaga

unread,
Aug 25, 2019, 5:10:37 AM8/25/19
to diagrams-discuss
Hi,

It seems diagrams-boolean package is deprecated:


Instead, you can use Diagrams.TwoD.Path.Boolean module of diagrams-contrib package as explained below:

Nao Fujinaga

unread,
Aug 25, 2019, 5:44:59 AM8/25/19
to diagrams-discuss
For the second question,

In your code, the argument of sqrt, namely ((i + 3*de)^2 - 12^2) could be negative value (I think you define the range of i to be [1,5..150] and de to be [0,1..2] in your code).

The argument of sqrt should never be negative, I guess.

2019年8月25日日曜日 14時00分56秒 UTC+5:30 carl greifenkla:
first question apparently already have an answer on this group (cabal install does not work - next thing i'm doing to download the pack via github)

Brent Yorgey

unread,
Aug 25, 2019, 4:22:38 PM8/25/19
to Nao Fujinaga, diagrams-discuss
Just to follow up on this answer, you cannot intersect diagrams directly.  But you can intersect paths (using Diagrams.TwoD.Path.Boolean) and then turn the resulting path into a diagram.

As for your other problem, I think calling sqrt on a negative number may be the likely cause as well.  This results in NaN and honestly I am not sure what happens when you make a circle with radius NaN.  Ideally it should fail instead of using up a ton of memory but I have seen bugs like this in diagrams before.

-Brent

--
You received this message because you are subscribed to the Google Groups "diagrams-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to diagrams-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/diagrams-discuss/216a4070-d163-49b9-a0d8-6ba86ba27058%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages