[Bf-committers] Re: [Bf-blender-cvs] CVS
commit: blender/source/blender/python/api2_2x vector.c
Joseph Gilbert
models at paposo.com
Tue Sep 27 05:13:59 CEST 2005
Well the math classes (in mathutils) have no comparison operators as of
yet. vector == vector is an instance check, not an equivalency test.
Also vec > vec, etc. is undefined.
This is something that was meant to be added to the classes originally.
If you do:
vec = Vector(1,2,3)
vec2 = Vector(1,2,3)
print vec == vec2
you get False - because they are separate instances of the the Vector
typeobject.
This in a sense is operator overloading but is a valid overload of the
tp_richcompare method pointer.
We need to have some sort of equivalency testing for math classes.
We might forgo the >,>=,<,<= operators (im not sure what we would return
- maybe a not-implemented warning) but we must have the eq, neq
equivalency tests of vectors at least.
The epsilon is because of floating point comparisons in the data. There
is a little article on this here:
http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
Please let me know what your suggestions are regarding equivalency tests
, I would appreciate your input.
Daniel Dunbar wrote:
>My intuition says this is a bad idea. You can
>reliably sort vectors for one thing. Also
>embedding an epsilon inside a class is really
>a bad idea in my opinion.
>
>This seems like abuse of operator overloading for
>a not particularly often used special case.
>
>--- Joseph Gilbert <models at paposo.com> wrote:
>
>
>
>>ascotan (Joseph Gilbert) 2005/09/26 22:11:13 CEST
>>
>> Modified files:
>> blender/source/blender/python/api2_2x vector.c
>>
>> Log:
>> - added some equivalency testing for vector classes
>> >, >=, <, <= test vector magnitude
>> ==, != test vector values 'within epsilon' :)
>> - inspired by ideasman
>>
>> Revision Changes Path
>> 1.32 +155 -14 blender/source/blender/python/api2_2x/vector.c
>>
>>
>>
>>
><http://projects.blender.org/viewcvs/viewcvs.cgi/blender/source/blender/python/api2_2x/vector.c.diff?r1=1.31&r2=1.32&cvsroot=bf-blender>
>
>
>>_______________________________________________
>>Bf-blender-cvs mailing list
>>Bf-blender-cvs at projects.blender.org
>>http://projects.blender.org/mailman/listinfo/bf-blender-cvs
>>
>>
>>
>
>
>daniel dunbar
>_______________________________________________
>Bf-committers mailing list
>Bf-committers at projects.blender.org
>http://projects.blender.org/mailman/listinfo/bf-committers
>
>
>
>
>
>
More information about the Bf-committers
mailing list