[Bf-python] Matrix comparison broken

Toni Alatalo antont at kyperjokki.fi
Tue Nov 22 18:03:28 CET 2005


On Tuesday 22 November 2005 16:58, Gilbert, Joseph T. wrote:
> How about >, >= , <, <=?
> With the vector classes these sort the length of the vector. Should
> these be implemented on matrix?

http://www3.sympatico.ca/cjw/PyMatrix/Doc/PyMatrix.matrix.M-class.html has 
quite many, i wonder if we could use that code at some point even?

   __and__(self, other) 
 Bitwise and (&).
     __div__(self, other) 
 divide - other is the divisor
     __eq__(self, other) #this is the normal equality method
     __ge__(self, other)

__mul__(self, other) 
 Return self * other.

  __rdiv__(self, other) 
 other / self.

etc.

as i always like to point out, the scipy people are working on Numeric3 with 
the idea in mind that it would become a part of the python core / stdlib at 
some point.

that PEP is not addressing higher level entities such as Matrices, but i guess 
it would be cool to get them standardized too .. so i hope 3d gfx math 
knowledgeable ppl will be involved in the process. 
http://www.scipy.org/wikis/numdesign/ has the info about the array base type 
etc

> I think we will agree then on numerical identity for '==' on all the
> math classes. We'll implement this on quat, euler, matrix.

sounds ok.

~Toni

>
> -----Original Message-----
> From: bf-python-bounces at projects.blender.org
> [mailto:bf-python-bounces at projects.blender.org] On Behalf Of Campbell
> Barton
> Sent: Monday, November 21, 2005 4:17 PM
> To: Blender Foundation Python list
> Subject: Re: [Bf-python] Matrix comparison broken
>
> Id say just numerical equiv. Wil some error margin ~0.000001 or
> somthing.
> If they are different but describe the same TX then there still
> different.
> Another func could be used to test the other- added later if people
> need.
> - Cam
>
> Gilbert, Joseph T. wrote:
> > This is default behavior. A == B is by default an instance comparison.
> > We need to write overloaded comparison operators for the other math
> > classes.
> >
> > The problem I see here is what the definition of equivalency is for a
> > matrix.
> > i.e. what does a == b supposed to evaluate? Do you mean they have the
> > exact same numbers? If so to what floating point extent. Is a matrix
> > equivalent when it describes the same transformation?
> >
> > -----Original Message-----
> > From: bf-python-bounces at projects.blender.org
> > [mailto:bf-python-bounces at projects.blender.org] On Behalf Of Campbell
> > Barton
> > Sent: Monday, November 21, 2005 3:26 PM
> > Cc: Blender Foundation Python list
> > Subject: Re: [Bf-python] Matrix comparison broken
> >
> > instance_a is instance_b - Alredy works for instance comparison,
> > shouldent we raise an error if its not supported?
> > It causes bugs to be written into new python code. - and scriptors
>
> need
>
> > to find out for themselves that its not supported.
> > or at least print an error message.
> >
> > - Cam
> >
> > Gilbert, Joseph T. wrote:
> >> Because matrix has no overloaded comparison operator like vector.
> >> A == b is an instance comparison. It's equivalent to:
> >> instance_a == instance_b = False
> >>
> >>
> >> -----Original Message-----
> >> From: bf-python-bounces at projects.blender.org
> >> [mailto:bf-python-bounces at projects.blender.org] On Behalf Of Campbell
> >> Barton
> >> Sent: Monday, November 21, 2005 12:25 PM
> >> To: bf-python at blender.org
> >> Subject: [Bf-python] Matrix comparison broken
> >>
> >> Entered this into the command line, matrix's never return true when
> >> comparing ATM-
> >> a = Mathutils.Matrix()
> >> b = Mathutils.Matrix()
> >> b == a
> >> False



More information about the Bf-python mailing list