def __str__(self):
        """'Pretty' formatting of the Matrix44."""

        # Pretty printing generates a lot of ugly code - oh the irony!
        # Changed in release 0.0.3 so that the decimal point is always
        # line up on the columns

        cols = [ list(map(format_number, col)) for col in self.columns() ]

        def decimal_pos(n):
            if '.' in n:
                return n.index('.')
            return len(n)

        for col_no, col in enumerate(cols[:]):

            decimal = max( decimal_pos(format_number(c)) for c in col )
            cols[col_no] = [" "*(decimal-decimal_pos(c))+c for c in col]

        max_col_lengths = [ max(len(c) for c in col) for col in cols ]
        rows = [[], [], [], []]
        for row_no in range(4):

            for col_no in range(4):

                v = cols[col_no][row_no]
                rows[row_no].append( v.ljust(max_col_lengths[col_no]) )

        rows = [" ".join(row).rstrip() for row in rows]
        return "\n".join("[ %s ]"%row for row in rows)

        return str(cols)
Example #2
0
    def __str__(self):
        """'Pretty' formatting of the Matrix44."""

        # Pretty printing generates a lot of ugly code - oh the irony!
        # Changed in release 0.0.3 so that the decimal point is always
        # line up on the columns

        cols = [map(format_number, col) for col in self.columns()]

        def decimal_pos(n):
            if '.' in n:
                return n.index('.')
            return len(n)

        for col_no, col in enumerate(cols[:]):
            decimal = max(decimal_pos(format_number(c)) for c in col)
            cols[col_no] = [" " * (decimal - decimal_pos(c)) + c for c in col]

        max_col_lengths = [max(len(c) for c in col) for col in cols]
        rows = [[], [], [], []]
        for row_no in range(4):

            for col_no in range(4):
                v = cols[col_no][row_no]
                rows[row_no].append(v.ljust(max_col_lengths[col_no]))

        rows = [" ".join(row).rstrip() for row in rows]
        return "\n".join("[ %s ]" % row for row in rows)

        return str(cols)
Example #3
0
    def __str__(self):
        """'Pretty' formatting of the Matrix44."""

        max_len = max(len(format_number(v)) for v in self.components())

        def format_row(row):
            return "%s" % " ".join(
                format_number(value).ljust(max_len) for value in row)

        rows = [format_row(row).rstrip() for row in self.rows()]
        max_row_len = max(len(row) for row in rows)
        return "\n".join("[ %s ]" % row.ljust(max_row_len) for row in rows)
Example #4
0
    def __str__(self):

        x, y, z = self._v
        return "(%s, %s, %s)" % (format_number(x),
                                 format_number(y),
                                 format_number(z))
Example #5
0
 def format_row(row):
     return "(%s)" % ", ".join(format_number(value) for value in row)
 def format_row(row):
     return "(%s)" % ", ".join( format_number(value) for value in row )
Example #7
0
    def __str__(self):

        return "(%s, %s, %s)" % (format_number(
            self._v[0]), format_number(self._v[1]), format_number(self._v[2]))
Example #8
0
 def format_row(row):
     return "%s" % " ".join(
         format_number(value).ljust(max_len) for value in row)
    def __str__(self):

        x, y = self._v
        return "(%s, %s)" % (format_number(x), format_number(y))