How to build a vector from two floats?
Calvelo Daniel
dcalvelo at pharion.univ-lille2.fr
Tue Aug 29 05:45:52 EDT 2000
Fredrik Lundin <m94lufr at mtek.chalmers.se> wrote:
: I am experiencing problems when I want to build a vector out of two floats.
: I am routing two SFFloats from a WRL-file to the python script.
What is an SFFloat? And a WRL-file?
: class TextureScale(TypedField(SFVec2f,(SFFloat,SFFloat))):
: def evaluate(self, inputs):
: return inputs[0].get(),inputs[1].get()
: texturescale = TextureScale()
You are declaring a class named 'TextureScale' which is a descendant of
the class returned by 'TypedField(SFVec3f,(SFFloat,SFFloat))'. Then, you
define the member function evaluate. Then you declare 'texturescale' as
an instance of TextureScale.
: Shouldn't the return be of the type SFVec2f with two SFFloat in x- & y-pos?
Instanciation ('TextureScale()') will always return a new instance of the
class. If you do stg like
texturescale = TextureScale().evaluate( SFFloat_1, SFFloat_2 )
Then a newly created TextureScale instance will be passed to method evaluate
along with both arguments; it will return the tuple I guess you want.
BTW Python isn't typed. At least not in the C++ sense.
HTH (somehow), DCA
-- Daniel Calvelo Aros
calvelo at lifl.fr
More information about the Python-list
mailing list