gnu3dkit-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnu3dkit-discuss] matrix multiply of vector


From: Philippe C.D. Robert
Subject: Re: [Gnu3dkit-discuss] matrix multiply of vector
Date: Wed, 10 Jul 2002 01:00:47 +0200

On Tuesday, July 9, 2002, at 10:21 PM, Brent Gulanowski wrote:
Here's my late reply to your previous reply.
On Saturday, July 6, 2002, at 12:15  PM, Philippe C.D. Robert wrote:
On Friday, July 5, 2002, at 11:53 PM, Brent Gulanowski wrote:
Pursuant to my questions about "Bugs?" on the bug list,

I have a thing I'm trying to do, which I'm sure I'll scrap for an entirely better solution soon, but currently this requires that I apply a scale matrix multiplication to a vector3f. In this case, I want to mirror the vector in the z-axis, and then set the scale of a transform to that vector. It's kind of the wrong application, but assuming I find a use for what is a standard 3D operation, does 3DKit have a way for me to do it properly?

Hmm, I am not entirely sure what you mean... If I get you right then you would multiply your vector with the mirror matrix ( see vectorByPreMultiplying: ) and after that you'd call setScaleValues: on the transform passing your new vector.

The mirror matrix looks like

1  0  0  0
0  1  0  0
0  0 -1  0
0  0  0  1

BTW please be aware that you should always use 4 dimensions when doing 3D graphics, thus you would use a G3DVector4f!


I guess I forget that part :-). So given a Transform, I can get the scale vector (which is a vector3f). How do I convert that to a vector4f? And after I use the z mirror matrix, how do turn the resultant vector4f back into a vector3f?

Well, add 1 as forth element and write only the first 3 values back into the transformation...:-) But you are right, this is bad design, it should probably be changed (I already did it for the matrix class in the latest, yet unreleased GeometryKit). The design comes from OpenGL where ie. glScalef only takes 3 values.

Even if I use getScaleMatrix: I still have to set the values with a vector3f. So, this is where I'm stuck. (Not urgent, won't be doing this work for a week or so.)

You can just set the values from the vector3f, this will work as expected since the forth element is always 1 here anyway. So there is not need to use getScaleMatrix: for this, I guess.

HTH,

-Phil
--
Philippe C.D. Robert
http://www.nice.ch/~phip




reply via email to

[Prev in Thread] Current Thread [Next in Thread]