|
From: Kevin M. <ke...@vr...> - 2003-09-23 19:43:36
|
for speed, you can cast the float* to a Vec*. then just dereference it
with * so you can return Vec&
Vec& getCol( int which )
{
return *(Vec*)&mData[do the math];
}
this way you don't need to return a copy, and you can actually use the
vector to change the column...
definately test this before committing. :) but I'm pretty sure it will
work.
kevin
On Tue, 23 Sep 2003, Ben Scott wrote:
> While it could be considered an unneeded function because you can achieve
> the same functionality on your own, I have often wanted the ability to get
> a column from a matrix as vector - especially when getting the forward
> vector for entities or doing billboarding. It's a relatively simple
> function that will bloat the API but not the user's code unless they use
> it. I figure that GMTL is hard enough for most people to grok because of
> the templates that anything we can do to help them use it and like it is
> good.
>
> I guess if Allen agrees with you and doesn't want it in the library I'll
> concede and just send Eric the patch rather than commit it.
>
> cheers,
> -Ben
>
> >
> >
> > I'm not sure it was an ambiguity, rather it was an effort not to bloat the
> > code with unneeded functions.
> >
> > for example, you can easily write your own GetColumn using the element
> > accessor operator ( mat[row][col] ).
> >
> > I see it as unneeded, but I'll defer the descision to allen or ben since I
> > don't feel too strongly about it.
> >
> > kevin
> >
> >
> > On Mon, 22 Sep 2003, Eric Maslowski wrote:
> >
> >> Ben said he was going to take a look into adding GetColumn() routine to
> >> the
> >> library to simplify this ambiguity. Thanks for the response.
> >>
> >> cheers
> >>
> >> E.
> >>
> >> At 15:13 09/22/2003 -0500, you wrote:
> >>
> >> >mats are column ordered, so that helps. you should be able to index
> >> one
> >> >element and dereference it to get the column.
> >> >
> >> >I think (float*)&mat.mData[0] would be the first column, which if you
> >> init
> >> >a Vec with it:
> >> >
> >> >gmtl::Vec4f col;
> >> >col.set( (float*)&mat.mData[0] );
> >> >
> >> >
> >> >second column (example):
> >> >
> >> > col.set( (float*)&mat(0,1) );
> >> >
> >> >
> >> >4th column (translation component):
> >> >
> >> > col.set( (float*)&mat[0][3] );
> >> >
> >> >
> >> >
> >> >-kevin
> >> >
> >> >
> >> >
> >> >On Mon, 22 Sep 2003, Eric Maslowski wrote:
> >> >
> >> > > How this is the right list: What is the recommended method for
> >> grabbing an
> >> > > entire column?
> >> > >
> >> > > Can't seem to find a general GetColumn() routine in the Matrix
> >> definition.
> >> > > I can't seem to even grab the components and throw them in a vector
> >> when
> >> > > the Matrix44f is a pointer.
> >> > >
> >> > > Matrix44f* mat = entity->GetTransform(); // GetTransform() returns
> >> > Matrix44f*
> >> > > Vec3f out_vec(mat[2][0],mat[2][1],mat[2][2]);
> >> > >
> >> > > yields:
> >> > >
> >> > > error C2664: 'gmtl::Vec<DATA_TYPE,SIZE>::Vec(const DATA_TYPE &,const
> >> > > DATA_TYPE &,const DATA_TYPE &)' : cannot convert parameter 1 from
> >> > > 'gmtl::Matrix<DATA_TYPE,ROWS,COLS>::RowAccessor *' to 'const float
> >> &'
> >> > >
> >> > > Any help would be greatly appreciated.
> >> > >
> >> > > cheers
> >> > >
> >> > > E.
> >> > >
> >> > >
> >> > >
> >> > > -------------------------------------------------------
> >> > > This sf.net email is sponsored by:ThinkGeek
> >> > > Welcome to geek heaven.
> >> > > http://thinkgeek.com/sf
> >> > > _______________________________________________
> >> > > ggt-devel mailing list
> >> > > ggt...@li...
> >> > > https://lists.sourceforge.net/lists/listinfo/ggt-devel
> >> > >
> >> >
> >> >--
> >> >*--*---*---*----*-----*------*------*-----*----*---*---*--*
> >> >Kevin Meinert /_/
> >> >home - http://www.vrsource.org/~kevin \ /
> >> >music - http://www.subatomicglue.com \/ __ \/
> >> > \__
> >> > \_\
> >>
> >>
> >
> > --
> > *--*---*---*----*-----*------*------*-----*----*---*---*--*
> > Kevin Meinert /_/
> > home - http://www.vrsource.org/~kevin \ /
> > music - http://www.subatomicglue.com \/ __ \/
> > \__
> > \_\
> >
> >
>
>
--
*--*---*---*----*-----*------*------*-----*----*---*---*--*
Kevin Meinert /_/
home - http://www.vrsource.org/~kevin \ /
music - http://www.subatomicglue.com \/ __ \/
\__
\_\
|