beginner oo programming

Multiscan gcangiani at yahoo.it
Tue Feb 25 04:07:58 EST 2003


Hi all,
	may be it is not the right place to post this question but I an
approaching oo programming using python and therefore...

Suppose I want to define a new vector class. This is simple: a vector has
x, y, z components.
But suppose I want to be able to use/write/store the vectors in two (or
more) different coordinate systems as, e.g. cartesian and oblique, and 
that the transformation from one system to another is variable.
For example. Suppose you have a 
cartesian coordinate system {(1, 0), (0,1)} 
and an oblique one {(1, 0), (a, b)} with b != 0
The way to transform a vector from one system to the other depends on the
ration a/b. Right ?
Now what is the best way to add to the vectors the knowledge of the
transformation relation ?

I think the best is always to store the vectors with a unique corrdinate
system and then to add methods to get the coordinates on the other
coordinate systems. But 
How do I teach to the vector object what the transformation relation 
(the a/b ratio in the above example) is ?
Should each istance of vector class contain also a reference to the
coordinate system object ? 
Or should I include the transformation relation as a parameter for the
getcoordinate method ?
What is the coordinate system object disappears or change address ? 
Should it be a sort of global object ?
If I have a list of vectors, how do I store only once the information on
the reference system ?
Should I consider inheritance ?

Thanks in advance for any information.

	giovanni






More information about the Python-list mailing list