[Bf-committers] Proposal to Change Mathutils Vectors

Andrew Hale trumanblending at gmail.com
Wed Dec 7 11:33:15 CET 2011


Hi Paul,

Correct me if I'm wrong, but do you propose to have 3D vectors with matrix
multiplication just work (i.e. making assumptions about the w coordinate
and renormalising if necessary) but retain 4D vectors which compute the
product without modification of the w component? This sounds quite logical,
however, these transformations deal with points so I'm not sure I
understand what you mean by differentiating between vectors and normals.

Thanks again,
Andrew

On Wed, Dec 7, 2011 at 9:15 PM, Andrew Hale <trumanblending at gmail.com>wrote:

> Hi Paul,
>
> You make an excellent point (no pun intended!), this is correct and I made
> the mistake of not considering points vs vectors here. Would it be suitable
> then just to assume those using 4D vectors are aware of the pitfalls/issues?
>
> Thanks,
> Andrew
>
>
> On Wed, Dec 7, 2011 at 9:03 PM, Paul Melis <paul.melis at sara.nl> wrote:
>
>> Hi Andrew,
>>
>> On 12/02/2011 12:47 PM, Andrew Hale wrote:
>> > I've written a proposal to change the current handling of
>> transfomations of
>> > vectors and remove the use cases for 4D vectors. The proposal can be
>> found
>> > here:
>> >
>> http://wiki.blender.org/index.php/User:TrumanBlending#Proposal:_Four_Dimensional_Mathutils_Vectors
>>
>> A few comments on your proposal:
>>
>> (x1, y1, z1, 1) + (x2, y2, z2, 1) = (x1+x2, y1+y2, z1+z2, 2)
>>
>> This addition doesn't make much sense. You're adding two 3D points here,
>> i.e. 3D coordinates, for which there is no sensable geometric
>> interpretation. Addition of two 3D *vectors*, i.e. 3D directions, does
>> make sense, but in that case the w component should be 0. E.g.
>>
>> (x1, y1, z1, 0) + (x2, y2, z2, 0) = (x1+x2, y1+y2, z1+z2, 0)
>>
>> The value of w is also the major difference between representations of
>> points and vectors in homogenous coordinates. When sticking to w=0 for
>> vectors and w=1 for points things like subtraction actually make sense:
>>
>> (4, 4, 4, 1) - (1, 1, 1, 1) = (3, 3, 3, 0)
>>
>> That is, subtracting two 3D points results in a vector that points from
>> the second point to the first. Subtraction of vectors also just works:
>>
>> (0, 1, 0, 0) - (1, 0, 0, 0) = (-1, 1, 0, 0)
>>
>> Adding a vector to a point gets you a new point:
>>
>> (1, 2, 3, 1) + (4, 4, 4, 0) = (5, 6, 7, 1)
>>
>> The point being that in these cases you don't need to explicitly worry
>> about the w component, as for the sensible operations the results are
>> correct. It's only with applying transformation matrices that you need
>> to normalize the result by dividing by the w-component of the result
>> (but only if it is non-zero).
>>
>>
>> In general I would say, just like Stephen Swaney did somewhere in this
>> thread, that there's two kinds of users:
>>
>> 1. The first type of user doesn't need/want to know about the underlying
>> complexities of 3D math. He/she just wants to do simple manual
>> transformations on 3D geometry. The easiest interface would be to
>> provide methods in the Matrix class for transforming points, vectors and
>> normals specified as 3-tuples (e.g. transformPoint(Vector3),
>> transformVector(Vector3), transformNormal(Vector3)). These methods can
>> then hide the underlying assumptions about the value of the w component
>> and the different method needed for transforming vectors versus normals.
>> The results from these methods would be 3-tuples as well. By using
>> multiplication of transformation matrices you can simply compose
>> transformations from separate steps. I think that's about all the
>> operations this group of users wants to do (but correct me if I'm wrong).
>>
>> 2. The second type of user knowns his 3D math and just wants to work
>> with general 4x4 transformation matrices and the operations on length-4
>> tuples. They will worry themselves about homogenous coordinates and
>> such. These users also know that v*M and M*v produce different results
>> and ignore the fact that v plays the role of column-vector versus
>> row-vector here, etc.
>>
>> I consider myself to be in the second category and completely removing
>> vectors with homogenous coordinates from the Blender API makes me
>> nervous. I don't think the two types of usage conflict, it's more about
>> providing different APIs for accomplishing the same thing and educating
>> users in the first category what methods to use, providing good example
>> scripts, etc.
>>
>> Just my 2 euro-cents,
>> Paul
>>
>>
>>
>>
>> _______________________________________________
>> Bf-committers mailing list
>> Bf-committers at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-committers
>>
>
>


More information about the Bf-committers mailing list