diff --git a/src/lay/lay/doc/about/transformations.xml b/src/lay/lay/doc/about/transformations.xml index 991ac0b9a..c961cb9b9 100644 --- a/src/lay/lay/doc/about/transformations.xml +++ b/src/lay/lay/doc/about/transformations.xml @@ -4,6 +4,7 @@ Transformations in KLayout +

KLayout supports a subset of affine transformations with the following contributions: @@ -37,7 +38,9 @@ given displacement vector.

+

+

The notation shown here is used in many places within KLayout. It is basically composed of the following parts @@ -75,7 +78,9 @@ multiples of 90 degree:

+

+

KLayout is not restricted to these basic operations. Arbitrary angles are supported (i.e. "r45" or "m22.5"). Usually however, @@ -83,5 +88,160 @@ simple transformations involving only rotations by multiples of 90 degree and do not use scaling.

+

Coding transformations

+ + +

+ Note that mirroring at an axis with a given angle "a" is equivalent to mirroring at the x axis followed by a rotation + by twice the angle "a". For example: +

+ +
m45 == m0 followed by r90
+ +

+ When coding transformations, two parameters are used to represent the rotation/mirror part: + a rotation angle and a flag indicating mirroring at the x axis. The mirroring is applied before + the rotation. In terms of these parameters, the basic transformations are: +

+ + + + + + + +
Rotation angle
(degree)
Mirror flag
= False
Mirror flag
= True
0r0m0
90r90m45
180r180m90
270r270m135
+ +

Transformation objects

+ +

+ Transformation objects are convenient objects to operate with. They represent a + transformation (technically a matrix) consisting of an angle/mirror and a displacement + part. They support some basic operations: +

+ +
    +
  • Concatenation: T = T1 * T2
    T is transformation T2 applied, then T1 (note this order)
  • +
  • Inversion: TI = T.inverted()
    TI is the inverse of T, i.e. TI * T = T * TI = 1 where 1 is the neutral transformation which does not modify coordinates
  • +
  • Application to geometrical objects: q = T * p
    where p is a box, polygon, path, text, point, vector etc. and q is the transformed object
  • +
+ +

Vectors and Points

+ + + +

+ In KLayout there are two two-dimensional coordinate objects: the vector and the point. + Basically, the vector is the difference between two points: +

+ +
v = p2 - p1
+ +

Here v is a vector object while p1 and p2 are points.

+ +

+ Regarding transformations, vectors and points behave differently. While for a point, the + displacement is applied, it is not for vectors. So +

+ +
p' = T * p = M * p + d
+v' = T * v = M * v
+ +

+ Here M is the 2x2 rotation/mirror matrix part of the transformation and d is the + displacement vector +

+ +

+ The reason why the displacement is not applied to a vector is seen here: +

+ +
+ v' = T * v 
+    = T * (p2 - p1) 
+    = T * p2 - T * p1
+    = (M * p2 + d) - (M * p1 + d)
+    = M * p2 + d - M * p1 - d
+    = M * p2 - M * p1 
+    = M * (p2 - p1)
+ +

where the latter simply is:

+ +
v' = M * v
+ +

Simple transformations

+ + + + +

+ Simple transformations are represented by or objects. + The first operates with floating-point displacements in units of micrometers while the second one with integer displacements + in database units. "DTrans" objects act on "D" type floating-point coordinate shapes (e.g. ) while "Trans" objects act + on the integer coordinate shapes (e.g. ). +

+ +

+ The basic construction parameters of "DTrans" and "Trans" are: +

+ +
Trans(angle, mirror, displacement)
+DTrans(angle, mirror, displacement)
+ +

"displacement" is a (for DTrans) or a (for Trans).

+ +

"angle" is the rotation angle in units of 90 degree and "mirror" is the mirror flag:

+ + + + + + + +
anglemirror
= False
mirror
= True
0r0m0
1r90m45
2r180m90
3r270m135
+ +

Complex transformations

+ + + + + + +

+ Complex transformations in addition to the simple transformations feature + scaling (magnification) and arbitrary rotation angles. Other than simple transformations + they do not necessarily preserve a grid and rounding is implied. Furthermore they imply a shift is physical scale + which renders them difficult to use in physical frameworks (e.g. DRC). Hence their + use is discouraged for certain applications. +

+ +

+ The basic classes are for the micrometer-unit (floating-point) version + and for the database-unit (integer) version. The + construction parameters are: +

+ +
ICplxTrans(angle, mirror, magnification, displacement)
+DCplxTrans(angle, mirror, magnification, displacement)
+ +

+ Here, "angle" is the rotation angle in degree (note the difference to "Trans" and "DTrans" where the + rotation angle is in units for 90 degree. "magnification" is a factor (1.0 for "no change in scale"). +

+ +

+ There are two other variants useful for transforming coordinate systems: takes + integer-unit objects and converts them to floating-point unit objects. It can be used to convert + from database units to micrometer units when configured with a magnification equal to the database unit value: +

+ +
T = CplxTrans(magnification: dbu)
+q = T * p
+ +

+ The other variant is which converts floating-point unit objects + to integer-unit ones. These objects are generated when inverting "CplxTrans" objects. +

+