POV-Ray : Newsgroups : povray.newusers : Singular matrix reading polygon Server Time
1 Nov 2024 17:20:05 EDT (-0400)
  Singular matrix reading polygon (Message 1 to 7 of 7)  
From: pixelphile
Subject: Singular matrix reading polygon
Date: 22 Feb 2005 17:20:01
Message: <web.421baf07656b43159c2e82100@news.povray.org>
I'm trying to render an architectural design.  My CAD system generates
(inter alia) the following:
polygon { 5,
<-41.486087666667,0.272721000000,-5.718333333333>,
<-41.484943666667,0.271479000000,-5.717189333333>,
<-41.484891666667,0.272721000000,-5.719251333333>,
<-41.486087666667,0.272721000000,-5.718333333333>,
<-41.486087666667,0.272721000000,-5.718333333333>
texture {Soft_blue
}
}
- which causes "Parse Error: singular matrix in MInvers".  Actually my model
contains hundreds of polygons that generate this message.
What is it about the polygon that causes this?  Are the points not coplanar?
 (I've tried removing the final point - makes no difference).
I can't easily change either the contents of the model (supplied by a third
party) or the CAD system (ditto) so my scope for experimentation is
limited.  I just need to know who to complain to!
Apparently the same data file renders correctly under a different operating
system, so it may be a rounding issue.  Surely POVRay can't be so sensitive
to coplanarity or the polygon primitive would fail this way all the time?

TIA for any ideas


Post a reply to this message

From: Slime
Subject: Re: Singular matrix reading polygon
Date: 22 Feb 2005 17:47:30
Message: <421bb682@news.povray.org>
> 0.27272100000
> 0.271479000000
> 0.272721000000
> 0.272721000000

Three of the four points have the same Y value, but the second has a very
different Y value. I think that's close enough to not coplanar to make
POV-Ray complain. (Although I thought POV-Ray gave a better error message
for that.)

Is there any way you can just triangulate the whole thing?

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: Mike Williams
Subject: Re: Singular matrix reading polygon
Date: 23 Feb 2005 00:04:45
Message: <6XQdaBAh7AHCFws4@econym.demon.co.uk>
Wasn't it pixelphile who wrote:
>I'm trying to render an architectural design.  My CAD system generates
>(inter alia) the following:
>polygon { 5,
><-41.486087666667,0.272721000000,-5.718333333333>,
><-41.484943666667,0.271479000000,-5.717189333333>,
><-41.484891666667,0.272721000000,-5.719251333333>,
><-41.486087666667,0.272721000000,-5.718333333333>,
><-41.486087666667,0.272721000000,-5.718333333333>
>texture {Soft_blue
>}
>}
>- which causes "Parse Error: singular matrix in MInvers".  Actually my model
>contains hundreds of polygons that generate this message.
>What is it about the polygon that causes this?  Are the points not coplanar?
> (I've tried removing the final point - makes no difference).
>I can't easily change either the contents of the model (supplied by a third
>party) or the CAD system (ditto) so my scope for experimentation is
>limited.  I just need to know who to complain to!
>Apparently the same data file renders correctly under a different operating
>system, so it may be a rounding issue.  Surely POVRay can't be so sensitive
>to coplanarity or the polygon primitive would fail this way all the time?
>
>TIA for any ideas

Yes, it's some sort of rounding problem. Observe that the problem goes
away if we multiply the values by 100 and then scale it back down again
afterwards.

polygon { 5,
<-41.486087666667,0.272721000000,-5.718333333333>*100,
<-41.484943666667,0.271479000000,-5.717189333333>*100,
<-41.484891666667,0.272721000000,-5.719251333333>*100,
<-41.486087666667,0.272721000000,-5.718333333333>*100,
<-41.486087666667,0.272721000000,-5.718333333333>*100
texture {Soft_blue}
scale 0.01
}

I don't know why POV is trying to invert a matrix based on these points,
but when it does so the determinant of the matrix was getting rounded
down to zero.

Would it be possible for you to try scaling up the whole object in your
CAD program and then apply "scale 0.01" to the whole union once you've
got it into POV? 

The fact that three of the five points are identical is nothing to do
with the problem, since the error still happens with a polygon 3 using
the three non-identical points.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: pixelphile
Subject: Re: Singular matrix reading polygon
Date: 23 Feb 2005 05:25:00
Message: <web.421c5944b14fd3b4a70e760@news.povray.org>
>
> Is there any way you can just triangulate the whole thing?
>
I might just be able to persuade the writer of my CAD program that
outputting 5-vertex polygons is doomed to failure and totally unnecessary
when only three points are unique..


Post a reply to this message

From: pixelphile
Subject: Re: Singular matrix reading polygon
Date: 23 Feb 2005 05:30:00
Message: <web.421c5a21b14fd3b4a70e760@news.povray.org>
Thanks for the ideas.  Your leisure time is well spent!
It seems to me that the fact that three of the five points are identical
means that my CAD program ought to use a triangle primitive instead of a
polygon.  That way there will be no need to test for coplanarity, which it
seems to me is _bound_ to fail due to rounding in some circumstances
(except in the trivial cases of the points all lying on a single x, y or x
plane).
So I'll try to speak soothingly to the writer of the CAD program...


Post a reply to this message

From: Mike Williams
Subject: Re: Singular matrix reading polygon
Date: 24 Feb 2005 00:10:04
Message: <6CWN$AA57VHCFw9J@econym.demon.co.uk>
Wasn't it pixelphile who wrote:
>Thanks for the ideas.  Your leisure time is well spent!
>It seems to me that the fact that three of the five points are identical
>means that my CAD program ought to use a triangle primitive instead of a
>polygon.  That way there will be no need to test for coplanarity, which it
>seems to me is _bound_ to fail due to rounding in some circumstances
>(except in the trivial cases of the points all lying on a single x, y or x
>plane).
>So I'll try to speak soothingly to the writer of the CAD program...

If the writer is amenable to suggestions, then try recommending the use
of mesh2 structures rather than individual polygons. POV doesn't have
this rounding error with meshes. Meshes render faster, use much less
memory and have smaller file sizes. Meshes also provide the ability to
handle extra features, like smoothness and uv_mapping.

I did some tests on a reasonably complicated model that I had in mesh2
format, by converting it to a set of polygons. In my case I had to scale
the thing up by a factor of 1000 to avoid the Singular Matrix problem.

I examined three cases:
        Mesh2
        Individual polygons each with their own "texture {soft_blue}"
        A union of polygons with a single texture

                mesh2           polygons        polygon union
                =====           ========        =============
File size       520,295         2,655,817       2,367,241
Parse time      2 secs          7 secs          6 secs
Render time     28 secs         37 secs         42 secs
Memory used     2,807,915       47,574,731      23,078,795


-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: pixelphile
Subject: Re: Singular matrix reading polygon
Date: 24 Feb 2005 07:55:00
Message: <web.421dcbfcb14fd3b4a70e760@news.povray.org>
> If the writer is amenable to suggestions, then try recommending the use
> of mesh2 structures rather than individual polygons. POV doesn't have
> this rounding error with meshes. Meshes render faster, use much less
> memory and have smaller file sizes. Meshes also provide the ability to
> handle extra features, like smoothness and uv_mapping.
>
I think/hope that moving to triangles rather than polygons will avoid the
matrix inversion issue - haven't had enough leisure time to do this
experiment yet...
However, I think that moving to meshes would be rather more complex.  The
original data is imported into the CAD program (CYCAS, from www.cycas.de)
from a DXF file, and I guess the DXF represents the solid as individual
triangular or polygonal elements.  Going from this description to an
efficient mesh representation may be more effort than it's worth.  I'm only
trying to draw a bathroom, after all!

I'm now planning to write a simple program to analyse the POV input text
file and replace polygons by triangles where I can, in the hope that this
will fix the problem.

Overall I'm still surprised that POV can be flummoxed by such a simple
issue; it almost makes the polygon primitive unworkable.  A less
numerically-sensitive approach would be to define a polygon by defining the
(3D) origin of the plane, then two orthogonal vectors that lie in the
plane, then the points as linear combinations of those vectors.  That way
the points would be coplanar by definition.  I guess a further alternative
would be to define the plane through the first three points, then to
project all subsequent ones onto the plane.  But I'm a newcomer: perhaps
the polygon primitive just isn't designed to be used in this way at all.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.