Elipse "cannot invert matrix" possible fix

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Elipse "cannot invert matrix" possible fix

Stuart Axon
I've been trying to get lsystem1.py to work; and noticed that the problem seems
to occur in very small ellipses.

One solution seems to be a check for zero size ellipses; I don't know whether to
apply it though as my maths isn't strong enough to tell if this is breaking a
legitimate fix.

Any idea if this makes sense ?


(If anybody could test lsystem1.py on nodebox vs shoebot with this fix it might
be a start).
[+ Any other scripts that have the same "Cannot Invert Matrix error]


--- a/shoebot/core/cairo_canvas.py      Thu Sep 16 09:09:31 2010 +0200
+++ b/shoebot/core/cairo_canvas.py      Thu Sep 23 04:08:56 2010 +0100
@@ -207,11 +207,12 @@
                 self.context.close_path()
             elif cmd == ELLIPSE:
                 x, y, w, h = values
-                self.context.save()
-                self.context.translate (x + w / 2., y + h / 2.)
-                self.context.scale (w / 2., h / 2.)
-                self.context.arc (0., 0., 1., 0., 2 * pi)
-                self.context.restore()
+                if w != 0.0 and h != 0.0:
+                    self.context.save()
+                    self.context.translate (x + w / 2., y + h / 2.)
+                    self.context.scale (w / 2., h / 2.)
+                    self.context.arc (0., 0., 1., 0., 2 * pi)
+                    self.context.restore()
             else:
                 raise ShoebotError(_("PathElement(): error parsing path element
command (got '%s')") % (cmd))


     
_______________________________________________
Shoebot-devel mailing list
[hidden email]
http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net
Reply | Threaded
Open this post in threaded view
|

Re: Elipse "cannot invert matrix" possible fix

Stuart Axon
Thought about this during the day and of course it makes sense, so will push to
repository :)

 S++



----- Original Message ----

> From: Stuart Axon <[hidden email]>
> To: shoebox mailing list <[hidden email]>
> Sent: Thu, September 23, 2010 3:12:07 AM
> Subject: [shoebot-devel] Elipse "cannot invert matrix" possible fix
>
> I've been trying to get lsystem1.py to work; and noticed that the problem  
>seems
>
> to occur in very small ellipses.
>
> One solution seems to be a  check for zero size ellipses; I don't know whether
>to
>
> apply it though as my  maths isn't strong enough to tell if this is breaking a

> legitimate  fix.
>
> Any idea if this makes sense ?
>
>
> (If anybody could test  lsystem1.py on nodebox vs shoebot with this fix it
>might
>
> be a start).
> [+  Any other scripts that have the same "Cannot Invert Matrix error]
>
>
> ---  a/shoebot/core/cairo_canvas.py      Thu Sep 16 09:09:31 2010  +0200
> +++ b/shoebot/core/cairo_canvas.py      Thu Sep 23  04:08:56 2010 +0100
> @@ -207,11 +207,12 @@
>                   self.context.close_path()
>               elif cmd == ELLIPSE:
>                   x, y, w, h = values
> -                 self.context.save()
> -                 self.context.translate (x + w / 2., y + h / 2.)
> -                 self.context.scale (w / 2., h /  2.)
> -                self.context.arc  (0., 0., 1., 0., 2 * pi)
> -                 self.context.restore()
> +                 if w != 0.0 and h != 0.0:
> +                     self.context.save()
> +                     self.context.translate (x + w /  2., y + h / 2.)
> +                     self.context.scale (w / 2., h / 2.)
> +                     self.context.arc (0., 0., 1.,  0., 2 * pi)
> +                     self.context.restore()
>               else:
>                  raise  ShoebotError(_("PathElement(): error parsing path
>element
>
> command (got  '%s')") % (cmd))
>
>
>      
> _______________________________________________
> Shoebot-devel mailing  list
> [hidden email]
> http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net
>


     
_______________________________________________
Shoebot-devel mailing list
[hidden email]
http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net
Reply | Threaded
Open this post in threaded view
|

Re: Elipse "cannot invert matrix" possible fix

ricardo lafuente
yay!
yeah, cairo's scale errors out on zero values (and not only that, but i
forgot now... i think the scale() function has safeguards against this).
Probably this is due to rounding? But anyway, if it's fixed, it's gone
:) thanks Stuart!

On 09/23/2010 09:56 PM, Stuart Axon wrote:

> Thought about this during the day and of course it makes sense, so will push to
> repository :)
>
>   S++
>
>
>
> ----- Original Message ----
>> From: Stuart Axon<[hidden email]>
>> To: shoebox mailing list<[hidden email]>
>> Sent: Thu, September 23, 2010 3:12:07 AM
>> Subject: [shoebot-devel] Elipse "cannot invert matrix" possible fix
>>
>> I've been trying to get lsystem1.py to work; and noticed that the problem
>> seems
>>
>> to occur in very small ellipses.
>>
>> One solution seems to be a  check for zero size ellipses; I don't know whether
>> to
>>
>> apply it though as my  maths isn't strong enough to tell if this is breaking a
>
>> legitimate  fix.
>>
>> Any idea if this makes sense ?
>>
>>
>> (If anybody could test  lsystem1.py on nodebox vs shoebot with this fix it
>> might
>>
>> be a start).
>> [+  Any other scripts that have the same "Cannot Invert Matrix error]
>>
>>
>> ---  a/shoebot/core/cairo_canvas.py      Thu Sep 16 09:09:31 2010  +0200
>> +++ b/shoebot/core/cairo_canvas.py      Thu Sep 23  04:08:56 2010 +0100
>> @@ -207,11 +207,12 @@
>>                    self.context.close_path()
>>                elif cmd == ELLIPSE:
>>                    x, y, w, h = values
>> -                 self.context.save()
>> -                 self.context.translate (x + w / 2., y + h / 2.)
>> -                 self.context.scale (w / 2., h /  2.)
>> -                self.context.arc  (0., 0., 1., 0., 2 * pi)
>> -                 self.context.restore()
>> +                 if w != 0.0 and h != 0.0:
>> +                     self.context.save()
>> +                     self.context.translate (x + w /  2., y + h / 2.)
>> +                     self.context.scale (w / 2., h / 2.)
>> +                     self.context.arc (0., 0., 1.,  0., 2 * pi)
>> +                     self.context.restore()
>>                else:
>>                   raise  ShoebotError(_("PathElement(): error parsing path
>> element
>>
>> command (got  '%s')") % (cmd))
>>
>>
>>
>> _______________________________________________
>> Shoebot-devel mailing  list
>> [hidden email]
>> http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net
>>
>
>
>
> _______________________________________________
> Shoebot-devel mailing list
> [hidden email]
> http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net
>

_______________________________________________
Shoebot-devel mailing list
[hidden email]
http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net
Reply | Threaded
Open this post in threaded view
|

Re: Elipse "cannot invert matrix" possible fix

Stuart Axon
Cool, will commit this later - that's one annoying bug down at least !

----- Original Message ----

> From: ricardo lafuente <[hidden email]>
> To: [hidden email]
> Sent: Thu, September 23, 2010 10:12:36 PM
> Subject: Re: [shoebot-devel] Elipse "cannot invert matrix" possible fix
>
> yay!
> yeah, cairo's scale errors out on zero values (and not only that, but i
> forgot now... i think the scale() function has safeguards against this).
> Probably this is due to rounding? But anyway, if it's fixed, it's gone
> :) thanks Stuart!
>
> On 09/23/2010 09:56 PM, Stuart Axon wrote:
> >  Thought about this during the day and of course it makes sense, so will push  
>to
> > repository :)
> >
> >    S++
> >
> >
> >
> > ----- Original Message ----
> >>  From: Stuart Axon<[hidden email]>
> >> To:  shoebox mailing list<[hidden email]>
> >>  Sent: Thu, September 23, 2010 3:12:07 AM
> >> Subject: [shoebot-devel]  Elipse "cannot invert matrix" possible fix
> >>
> >> I've been  trying to get lsystem1.py to  work; and noticed that the problem
> >> seems
> >>
> >> to  occur in very small ellipses.
> >>
> >> One solution seems to be  a  check for zero size ellipses; I don't know
>whether
> >>  to
> >>
> >> apply it though as my  maths isn't strong enough  to tell if this is
>breaking a
> >
> >> legitimate   fix.
> >>
> >> Any idea if this makes sense  ?
> >>
> >>
> >> (If anybody could test  lsystem1.py  on nodebox vs shoebot with this fix it
> >> might
> >>
> >>  be a start).
> >> [+  Any other scripts that have the same "Cannot  Invert Matrix error]
> >>
> >>
> >> ---   a/shoebot/core/cairo_canvas.py      Thu Sep 16 09:09:31  2010  +0200
> >> +++ b/shoebot/core/cairo_canvas.py       Thu Sep 23  04:08:56 2010 +0100
> >> @@ -207,11 +207,12  @@
> >>                     self.context.close_path()
> >>                 elif cmd == ELLIPSE:
> >>                     x, y, w, h = values
> >>  -                  self.context.save()
> >> -                  self.context.translate (x + w / 2., y + h / 2.)
> >>  -                 self.context.scale (w  / 2., h /  2.)
> >> -                 self.context.arc  (0., 0., 1., 0., 2 * pi)
> >>  -                  self.context.restore()
> >> +                  if w != 0.0 and h != 0.0:
> >> +                       self.context.save()
> >> +                      self.context.translate (x + w /  2., y + h /  2.)
> >> +                      self.context.scale (w / 2., h / 2.)
> >> +                      self.context.arc (0., 0.,  1.,  0., 2 * pi)
> >> +                      self.context.restore()
> >>                 else:
> >>                    raise   ShoebotError(_("PathElement(): error parsing
path

> >>  element
> >>
> >> command (got  '%s')") %  (cmd))
> >>
> >>
> >>
> >>  _______________________________________________
> >> Shoebot-devel  mailing  list
> >> [hidden email]
> >> http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net
> >>
> >
> >
> >
> > ; _______________________________________________
> > Shoebot-devel mailing  list
> > [hidden email]
> > http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net
> >
>
> _______________________________________________
> Shoebot-devel  mailing list
> [hidden email]
> http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net
>


     
_______________________________________________
Shoebot-devel mailing list
[hidden email]
http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net