[Bf-python] vector.negate() question

Gilbert, Joseph T. jgilbert at tigr.ORG
Tue May 9 16:43:26 CEST 2006


I believe vec1 - vec2 is available (I hope so!). There are a lot of pythonic math operations that are not commonly used but are shorthand (like ~vec). I added some of these to the object classes for quick scripting. 

I think a more difficult issue to address is why vector.negate (or -vec) doesn't return a NEW vector as opposed to a self operation (which is extremely non-pythonic). This goes back to the vector_proxy issue and the wraping of internal data structures for modification.

object.matrix.blah(x) in a truly pythonic sense doesn't modify the data but creates a new matrix for you and returns it. We had problems with people not understanding why when they did object.matrix.blah(x) the data was not modified internally. So we came up with the idea of wrapping internal data (i.e. you DON'T get back a new matrix but modify the data directly in C). But to make this work you need self operations on data types or else it gets confusing.

object.matrix(wrapped data).blah(self operation).negate(returns a new matrix)()!!

Personally I think it's a bit of a mess. It may be we need 2 separate methods for every operation, 1 for self modification and another for returning a new value. vector.negate_self() and vector.negate_new() or something. ??


-----Original Message-----
From: bf-python-bounces at projects.blender.org [mailto:bf-python-bounces at projects.blender.org] On Behalf Of Toni Alatalo
Sent: Tuesday, May 09, 2006 10:33 AM
To: Blender Foundation Python list
Subject: Re: [Bf-python] vector.negate() question

Gilbert, Joseph T. wrote:

>lol you make great points. -vector is really a shorthand for vector.negate(). No harm in having both available.
>  
>

i think -vector should definitely not do anything, but vector1 - vector2 
should return vec_sub(vec1, vec2)
.. that is how python normally works, and how e.g. the soya3d api does it.

~Toni

> 
>________________________________________
>From: bf-python-bounces at projects.blender.org [mailto:bf-python-bounces at projects.blender.org] On Behalf Of Germán Alonso
>Sent: Tuesday, May 09, 2006 7:36 AM
>To: Blender Foundation Python list
>Subject: [Bf-python] vector.negate() question
>
>Good morning to all:
> 
>I'd love to know why vector.negate() has been depreciated, to use -vector instead of it.
> 
>I think that the explicit method would be better and more natural than the minus prefix, as this new can make undesired negations of vectors that may be difficult to detect if you're not used to this behaviour.
> 
>For example when you pass to a function an integer negated you use:
>function( -integer )
>and this don't change the integer variable value, but if you pass a vector:
>function( -vector )
>the vector value changes and you'll have to use:
>function( -Vector(vector) )
>if you don't want the vector variable to change.
> 
>I think this is a little odd, and purpose restore the old vector.negate() method, as is an explicit action instead of being hidden behind the minus symbol.
> 
>Thanks for reading.
> 
>Germán
>_______________________________________________
>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



More information about the Bf-python mailing list