Bug with gcal multmatrix

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

Bug with gcal multmatrix

Len Trigg
The attached scad file renders very differently when you go "compile"
vs "compile and render". It seems to be ignoring the final vector in
the multmatrix.

(you need a recent version of openscad, as it makes use of 2d minkowski)

Cheers,
Len.

bracket.scad (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Bug with gcal multmatrix

kintel
Administrator
On May 11, 2011, at 05:56 AM, Len Trigg wrote:

> It seems to be ignoring the final vector in the multmatrix.
>

This is reproducible with the following slimmed-down example, also for older OpenSCAD versions:

multmatrix(m = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, -0.02, 1]]) linear_extrude(height=20) circle(r=10);

It looks like CGAL's Aff_transformation_3 doesn't support matrices containing shear.
See transform.cc:298:

        if (N.dim == 3) {
                CGAL_Aff_transformation t(
                                m[0], m[4], m[ 8], m[12],
                                m[1], m[5], m[ 9], m[13],
                                m[2], m[6], m[10], m[14], m[15]);
                N.p3.transform(t);
        }

We might have to implement out own transform functionality unless we can find something in CGAL supporting 4x4 matrices including shear.

 -Marius


Reply | Threaded
Open this post in threaded view
|

Re: Bug with gcal multmatrix

Giles Bathgate-2
On 11 May 2011 20:21, Marius Kintel <[hidden email]> wrote:
> It looks like CGAL's Aff_transformation_3 doesn't support matrices containing shear.

I am not sure "shear" is the right term here

3D shear can be defined in terms of a 3x3 matrix so when put into a
4x4 matrix we don't care about the last column or last row:

[
    [1,Sxy,Sxz,0],
    [Syx,1,Syz,0],
    [Szx,Szy,1,0],
    [0,0,0,1]
]

See: http://www.cs.fit.edu/~wds/classes/cse5255/thesis/shear/shear.html#3dShear

I think CGAL's assumption is that you will always have the final
vector (row) set to [0,0,0,HW] where HW is variable. This reference
might also be useful:
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Kernel_23_ref/Class_Aff_transformation_3.html

I am wondering why the developers of CGAL would make such an
assumption if it were indeed useful to be able to change the values of
the final row to something other than 0. So my question to Len is what
is your transformation trying to do?


Regards

Giles.

Reply | Threaded
Open this post in threaded view
|

Re: Bug with gcal multmatrix

Len Trigg
Basically I am trying to increase the scale of the object as Z
increases, similarly to a perspective transformation. The
transformation is not affine, but i see no reason why the CGAL library
shouldn't let you do arbitrary transformations. I am guessing they are
assuming the typical use case is affine transformations only.

Cheers,
Len.

On Thu, May 12, 2011 at 9:13 PM, Giles Bathgate
<[hidden email]> wrote:

> On 11 May 2011 20:21, Marius Kintel <[hidden email]> wrote:
>> It looks like CGAL's Aff_transformation_3 doesn't support matrices containing shear.
>
> I am not sure "shear" is the right term here
>
> 3D shear can be defined in terms of a 3x3 matrix so when put into a
> 4x4 matrix we don't care about the last column or last row:
>
> [
>    [1,Sxy,Sxz,0],
>    [Syx,1,Syz,0],
>    [Szx,Szy,1,0],
>    [0,0,0,1]
> ]
>
> See: http://www.cs.fit.edu/~wds/classes/cse5255/thesis/shear/shear.html#3dShear
>
> I think CGAL's assumption is that you will always have the final
> vector (row) set to [0,0,0,HW] where HW is variable. This reference
> might also be useful:
> http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Kernel_23_ref/Class_Aff_transformation_3.html
>
> I am wondering why the developers of CGAL would make such an
> assumption if it were indeed useful to be able to change the values of
> the final row to something other than 0. So my question to Len is what
> is your transformation trying to do?
>
>
> Regards
>
> Giles.
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad
>

Reply | Threaded
Open this post in threaded view
|

Re: Bug with gcal multmatrix

Giles Bathgate-2
On 12 May 2011 10:47, Len Trigg <[hidden email]> wrote:
> The transformation is not affine, but i see no reason why the CGAL library
> shouldn't let you do arbitrary transformations.

The library used for this is the CGAL class Aff_transformation_3<Kernel> which
represents three-dimensional affine transformations only.

Going back to what Marius said "...might have to implement our own
transform functionality unless we can find something in CGAL
supporting..." non-affine transformations.

So basically he was right, just his use of the word "shear" that threw me off.

For the time being it might be helpful to add a warning to the output
when the script is evaluated, if the final row contains any values
other than 0.

Regards

Giles.