[webkit-dev] Complex and Vector3 classes in WTF?
Kenneth Russell
kbr at google.com
Tue Aug 31 18:59:34 PDT 2010
On Tue, Aug 31, 2010 at 6:42 PM, Maciej Stachowiak <mjs at apple.com> wrote:
>
> On Aug 31, 2010, at 5:29 PM, Chris Marrin wrote:
>
>>
>> On Aug 31, 2010, at 5:25 PM, Kenneth Russell wrote:
>>
>>>>> ...Yes, I did the Google search and you're right that the term is not in common usage (although I still maintain it's a completely reasonable term). The reason I think it's meaningful is because it really is a matrix of sorts, but a specialized one that handles only affine transformations. We could call it AffineTransform, but then why not call our 4x4 matrix HomogeneousTransform? I'd just like to be consistent.
>>>>
>>>> HomogenousTransform is fine. I would also be fond of PerspectiveProjection.
>>>
>>> PerspectiveProjection is not a good name for a 4x4 matrix class. Such
>>> a matrix might be used to represent an orthographic projection.
>>>
>>>> I think TransformMatrix is not a good name. It immediately raises the question, "what kind of transform". I also think Matrix does not need to be in the name. That is to some extent an implementation detail, from the mathematical perspective. It's more important to identify the type of transformation.
>>>
>>> I'm concerned about the route of adding a class for each kind of
>>> transformation. It will lead to a proliferation of confusingly named
>>> types and excess type conversion, or re-identification of the type of
>>> transformation, when composing transformations. At least in the 3D
>>> realm, all that is desired is one simple 4x4 matrix class. Additional
>>> classes to represent e.g. 4x3 matrices add unnecessary complexity.
>
> I don't think we need a huge number, but the 2D affine transform case is clearly special - it's too expensive to use a 4x4 matrix for this.
Agreed.
>>
>> I agree. So, in order to appease Maciej :-) what if we keep AffineTransform as is, and change TransformationMatrix to Matrix (or Matrix4 if Matrix is too generic)?
>
> Is HomogenousTransform an inaccurate representation of what it does?
>
> The class has methods such as mapPoint, projectPoint, scale, rotate3d, applyPerspective, etc. It is clearly oriented around being some sort of transform, not a generic 4x4 matrix. Is it ever used to represent something that is not a transform at all? Would you use this class for something totally unrelated to transforms, for example if you wanted to solve a system of linear equations via gaussian elimination? My expectation is that you would not.
I would certainly not preclude this possibility. If you look at the
implementation of TransformationMatrix, it actually does matrix
decomposition to extract components like rotation and perspective of a
given transform. I could easily see the need to expose the underlying
operations, or other operations like LU decomposition, in the public
API.
-Ken
More information about the webkit-dev
mailing list