It looks like you're new here. If you want to get involved, click one of these buttons!
Hi Matthias, we're in the process of migrating our existing Ruby scripts to the latest KLayout version.
I just came across something that I didn't expect and wanted to check with you whether that's intentional or a bug:
RBA::Trans.new(1000,6610).trans(RBA::Trans.new(780,-3670).disp)
While I don't care so much about the type of the resulting object, I would've expected the resulting coordinates to be the same.
Reading the API documentation, I realise Trans.disp was changed to return a Vector instead of a Point and also support for Vector inputs was added to the Trans.trans method.
I find the 0.25.8 result particularly puzzling as it appears to be simply (a copy of?) the 2nd Trans instance at 780,-3670.
Ideally, I'd like the scripts to be compatible with both KLayout versions, is there an alternative way to code what version 0.24.10 does, so it works the same in 0.25.8?
Comments
Hi,
I see I need to explain the concept here. The main difference between 0.25.x and 0.24.10 was a cleaner type system of geometrical primitive types.
One concept is that of vector vs. point (see https://www.klayout.de/doc-qt4/programming/geometry_api.html#h2-43 ).
In short, a point in an absolute location in 2d cartesian space and a vector connects two points. So:
A major difference between points and vectors is the transformation behaviour:
The reasoning is that with this definition the following intuitive equivalence is true:
because the displacements cancel.
As the "disp" part of the transformation is a vector, it will behave differently with 0.25 than with 0.24.
These are ways to achieve your desired behaviour in a portable way:
Matthias
Hi Matthias, thanks for the explanation and the documentation link. The following section cleared up my question about why the vector in my example wasn't transformed:
Also thanks for the code examples. To keep my scripts as close to the original as possible, I used the following variant:
This actually simplified the original code and made the intention more clear. Great!
Christian