Example #1
0
            return new

        def __mul__(self, other):
            '''x.__mul__(y) <==> x * y'''

            try:
                other = float(other)
            except TypeError:
                return other.__rmul__(self)
            return self._from_coords(self.x * other, self.y * other)

        def __eq__(self, other):
            x, y = other
            return self.x == x and self.y == y

    auto_public(Vec2)

###############################################################################
#                         Propriedades vetoriais
###############################################################################


class VecSlot(object):
    if C.compiled:
        __slots__ = []
    else:
        __slots__ = ['getter', 'setter']

    def __init__(self, slot):
        self.setter = slot.__set__
        self.getter = slot.__get__
Example #2
0
            return new

        def __mul__(self, other):
            '''x.__mul__(y) <==> x * y'''

            try:
                other = float(other)
            except TypeError:
                return other.__rmul__(self)
            return self._from_coords(self.x * other, self.y * other)

        def __eq__(self, other):
            x, y = other
            return self.x == x and self.y == y

    auto_public(Vec2)

###############################################################################
#                         Propriedades vetoriais
###############################################################################


class VecSlot(object):
    if C.compiled:
        __slots__ = []
    else:
        __slots__ = ['getter', 'setter']

    def __init__(self, slot):
        self.setter = slot.__set__
        self.getter = slot.__get__
Example #3
0
                other = float(other)
            except TypeError:
                return other.__rmul__(self)
            return self._from_coords(
                self.x *
                other,
                self.y *
                other,
                self.z *
                other)

        def __eq__(self, other):
            x, y, z = other
            return self.x == x and self.y == y and self.z == z

    auto_public(Vec3)

###############################################################################
#                         Propriedades vetoriais
###############################################################################


class VecSlot(object):
    if C.compiled:
        __slots__ = []
    else:
        __slots__ = ['getter', 'setter']

    def __init__(self, slot):
        self.setter = slot.__set__
        self.getter = slot.__get__
Example #4
0
        R = RotMat2(theta)
        self._data = (R * self * R.transpose())._data

    def itranspose(self):
        '''Transpõe a matriz *inplace*'''

        self[1, 0], self[0, 1] = self[0, 1], self[1, 0]

###############################################################################
#               Código injetado para rodar no modo interpretado
###############################################################################
if not C.compiled:
    @pyinject(globals())
    class Mat2Inject:
        pass

    @pyinject(globals())
    class mMat2Inject:
        pass

    @pyinject(globals())
    class RotMat2Inject:
        pass

    auto_public(Mat2)

if __name__ == '__main__' and not C.compiled:
    import doctest
    doctest.testmod()
Example #5
0
        def __mul__(self, other):
            '''x.__mul__(y) <==> x * y'''

            try:
                other = float(other)
            except TypeError:
                return other.__rmul__(self)
            return self._from_coords(self.x * other, self.y * other,
                                     self.z * other)

        def __eq__(self, other):
            x, y, z = other
            return self.x == x and self.y == y and self.z == z

    auto_public(Vec3)

###############################################################################
#                         Propriedades vetoriais
###############################################################################


class VecSlot(object):
    if C.compiled:
        __slots__ = []
    else:
        __slots__ = ['getter', 'setter']

    def __init__(self, slot):
        self.setter = slot.__set__
        self.getter = slot.__get__
Example #6
0
        self._data = (R * self * R.transpose())._data

    def itranspose(self):
        '''Transpõe a matriz *inplace*'''

        self[1, 0], self[0, 1] = self[0, 1], self[1, 0]


###############################################################################
#               Código injetado para rodar no modo interpretado
###############################################################################
if not C.compiled:

    @pyinject(globals())
    class Mat2Inject:
        pass

    @pyinject(globals())
    class mMat2Inject:
        pass

    @pyinject(globals())
    class RotMat2Inject:
        pass

    auto_public(Mat2)

if __name__ == '__main__' and not C.compiled:
    import doctest
    doctest.testmod()