[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Making A Module



RR4CLB wrote:
For some reason even though I have imported the math prior to the module,

Each module is a separate namespace. When you do 'import math',
it defines the name 'math' in the module where the import
statement occurs, and *only* that module. If you want to use
math in another module, you need to import it in that module
as well.

it is in the .pyc that is the problem.

You seem confused. The .pyc file is just a cache of compiled
bytecode -- its absence should never prevent any imports from
working (as long as the .py file it was created from can still
be found).

        self.Tan_Angle = math.tan( self.Dx/ self.Dy)
        self.Ship_Angle = math.atan( self.Dx/ self.Dy)
        self.Sin_Angle = math.asin( self.Dy/ math.hypot( self.Dx, self.Dy))
        self.Cos_Angle = math.acos( self.Dx/ math.hypot( self.Dx, self.Dy))

Not sure why you're calculating so many angles here, but if
you're trying to figure out which quadrant it's in, you
may find the math.atan2() function useful -- atan2(y, x)
gives you the angle of a vector from (0, 0) to (x, y)
with the signs of x and y taken into account.

Also -- what's with all the exclamation marks? Do you like
to write your comments comic-book style or something? :-)

--
Greg