[Bf-python] mathutil PyNumberMethods behaving badly

Gilbert, Joseph T. jgilbert at tigr.ORG
Fri Jul 21 16:32:18 CEST 2006


Cam, I'm pretty busy right now with other projects. Could you take care
of this? (Maybe Ken, etc. would like to help)

:)

-----Original Message-----
From: bf-python-bounces at projects.blender.org
[mailto:bf-python-bounces at projects.blender.org] On Behalf Of Campbell
Barton
Sent: Friday, July 21, 2006 2:38 AM
To: Blender Foundation Python list
Subject: Re: [Bf-python] mathutil PyNumberMethods behaving badly

Hi Joseph, read through this and It sounds like what we want

Think I suggested that in the first place but we can take it further.
invert() inverted() - inverted would be realy usefull because at the 
moment You have to copy a matrix and then invert it wich can be a bit
wordy

omat_i=Blender.Mathutils.Matrix( ob.matrixLocal )  # (wrapped)
omat_i.invert()

- could be replaced with

omat_i= ob.matrixLocal.inverted()

Do you want help with this or would you rather do yourself?
Id like to have this for 2.43

- Cam


Gilbert, Joseph T. wrote:
> This was something we discussed a few months ago.
> The proposal was to have a 2 methods. One which returns a
self-modified
> reference and another that returns a modified-copy.
>
> Example:
> ref_to_orig_vector = vector.negate()
> new_mod_vector = vector.negated()
>
> The -vec are shortcuts in pymath. They should be bound to either of
the
> 2 above methods. It would make sense to have them be bound to the
> version that returns a new_modified_vector for safety.
>
> To keep the current API "negate" would continue to do what it does
now.
> We would need to add "negated", etc. for all the self-modifying
methods
> of all the py math objects that require them. 
>
>
> -----Original Message-----
> From: bf-python-bounces at projects.blender.org
> [mailto:bf-python-bounces at projects.blender.org] On Behalf Of Ken
Hughes
> Sent: Thursday, July 20, 2006 2:29 PM
> To: Blender Foundation Python list
> Subject: [Bf-python] mathutil PyNumberMethods behaving badly
>
> Cam discovered a problem in the mathutils with expressions like this:
>
> me = Mesh.Get('Cube')
> x = -me.verts[0].co
> print x
> print me.verts[0].co
>
> You get this:
>
> [-0.565980, -1.386673, 0.000000](vector)
> [-0.565980, -1.386673, 0.000000](vector)
>
> Joseph put in code which modifies the original object, since script 
> users wanted to concatenate operations, but I don't think we really
want
>
> to this with math operations (i.e., PyNumberMethods).
>
> Seems to me we need two type of operations in mathutils: one modify
the 
> original data and return it and ones that don't (now on three: 1, 2,
3, 
> "Duh").  Obviously the math operations shouldn't do this, but looks
like
>
> we need to "un-deprecate" some of the original methods like
> vector.negate()
>
> Ken
> _______________________________________________
> Bf-python mailing list
> Bf-python at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-python
> _______________________________________________
> Bf-python mailing list
> Bf-python at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-python
>
>   


-- 
Campbell J Barton

133 Hope Street
Geelong West, Victoria 3218 Australia

URL:    http://www.metavr.com
e-mail: cbarton at metavr.com
phone: AU (03) 5229 0241
_______________________________________________
Bf-python mailing list
Bf-python at projects.blender.org
http://projects.blender.org/mailman/listinfo/bf-python



More information about the Bf-python mailing list