|
From: Andre W. <wo...@us...> - 2005-09-14 13:06:06
|
On 14.09.05, Jörg Lehmann wrote:
> Log Message:
> - introduce _epsilon for checking the singularity of a trafo
> - only check for singularity in trafo constructor (this should catch
> all errors automatically)
Great. I like it. But I would also like to have a epsilon kwargs,
which I can set to None. Use-case is to be able to define a trafo with
determinate 0, which I'll not use for output. A stable epllise
implementation could then be as short as:
class ellipse_pt(path):
"""ellipse with center (x_pt, y_pt) in pts,
the two axes (a_pt, b_pt) in pts,
and the angle angle of the first axis"""
def __init__(self, x_pt, y_pt, a_pt, b_pt, angle, **kwargs):
t = trafo.scale(a_pt, b_pt, epsilon=None).rotated(angle).translated_pt(x_pt, y_pt)
return path.circle_pt(0, 0, 1, **kwargs).normpath(epsilon=None).transformed(t).path()
I'm aware that we need the epsilon in the constructor only, but still
I would do it very much like to keep it in the trafo as an instance
variable and inherit it to newly created trafos (like by rotated) ...
and at some point we might also want to have inplace modification (I
certainly would like to have them) and for that we should need to keep
and to check the trafo not just in the constructor. Any doubts left?
André
PS: I think we should set the default for trafo._epsilon to 1e-10 (or
even lower!), since a determinate for a 2x2 matrix has the
dimension of its items to the power of two. We should be able to
scale by a factor of 0.001 without any problems. Currently we
have:
andre@pb:~/python/pyx$ python
Python 2.3.3 (#1, Aug 23 2004, 20:06:57)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1640)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyx import trafo
>>> trafo.scale(0.001)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/Users/andre/python/pyx/pyx/trafo.py", line 244, in __init__
trafo.__init__(self, matrix=((sx,0), (0,sy)), vector=vector)
File "/Users/andre/python/pyx/pyx/trafo.py", line 185, in __init__
(unit.topt(vector[0]), unit.topt(vector[1])))
File "/Users/andre/python/pyx/pyx/trafo.py", line 78, in __init__
raise TrafoException("transformation matrix must not be singular")
pyx.trafo.TrafoException: transformation matrix must not be singular
>>> trafo.scale(0.01)
<pyx.trafo.scale instance at 0x12afb48>
>>>
;-(
--
by _ _ _ Dr. André Wobst
/ \ \ / ) wo...@us..., http://www.wobsta.de/
/ _ \ \/\/ / PyX - High quality PostScript and PDF figures
(_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/
|