API reference - Class Trans

Notation used in Ruby API documentation

Description: A simple transformation

Simple transformations only provide rotations about angles which a multiples of 90 degree. Together with the mirror options, this results in 8 distinct orientations (fixpoint transformations). These can be combined with a displacement which is applied after the rotation/mirror. This version acts on integer coordinates. A version for floating-point coordinates is DTrans.

Here are some examples for using the Trans class:

t = RBA::Trans::new(0, 100)  # displacement by 100 DBU in y direction
# the inverse: -> "r0 0,-100"
t.inverted.to_s
# concatenation: -> "r90 -100,0"
(RBA::Trans::new(RBA::Trans::R90) * t).to_s
# apply to a point: -> "0,100"
RBA::Trans::new(RBA::Trans::R90).trans(RBA::Point::new(100, 0))

See The Database API for more details about the database objects.

Public constructors

new TransnewCreates a unit transformation
new Transnew(int f)Conversion constructor from a fixpoint transformation
new Transnew(int rot,
bool mirr,
Point u)
The standard constructor using angle and mirror flag
new Transnew(int rot,
bool mirr,
int x,
int y)
The standard constructor using angle and mirror flag and two coordinate values for displacement
new Transnew(int f,
const Point u)
The standard constructor using a code rather than angle and mirror
new Transnew(int f,
int x,
int y)
The standard constructor using a code rather than angle and mirror and two coordinate values for displacement
new Transnew(const Point u)The standard constructor using a displacement only
new Transnew(int x,
int y)
The standard constructor using a displacement given as two coordinates

Public methods

[const]bool!=(const Trans other)Inequality test
[const]Trans*(const Trans *)Multiplication (concatenation) of transformations
[const]bool<(const Trans other)A sorting criterion
[const]bool==(const Trans other)Equality test
[const]intangleGets the angle in units of 90 degree
voidangle=(int a)Sets the angle in units of 90 degree
[const]voidassign(const Trans other)Assign the contents of another object to self
voidcreateEnsures the C++ object is created
[const]intctrans(int d)The transformation of a distance
voiddestroyExplicitly destroy the object
[const]booldestroyed?Returns a value indicating whether the object was already destroyed
[const]PointdispAccessor to the point
voiddisp=(const Point u)Sets the displacement
[const]TransdupCreates a copy of self
TransinvertIn-place inversion
[const]TransinvertedInversion
[const]boolis_const_object?Returns a value indicating whether the reference is a const reference
[const]boolis_mirror?Gets the mirror flag
voidmirror=(bool m)Sets the mirror flag
[const]introtGets the angle/mirror code
voidrot=(int r)Sets the angle/mirror code
[const]stringto_sString conversion
[const]Pointtrans(const Point p)The transformation of a point

Public static methods and constants

intM0Angle/mirror code for the "mirrored at the x-axis" transformation
intM135Angle/mirror code for the "mirrored at the 135 degree axis" transformation
intM45Angle/mirror code for the "mirrored at the 45 degree axis" transformation
intM90Angle/mirror code for the "mirrored at the y (90 degree) axis" transformation
intR0Angle/mirror code for the "unrotated" transformation
intR180Angle/mirror code for the "rotated by 180 degree counterclockwise" transformation
intR270Angle/mirror code for the "rotated by 270 degree counterclockwise" transformation
intR90Angle/mirror code for the "rotated by 90 degree counterclockwise" transformation
Transfrom_dtrans(const DTrans double_trans)Conversion constructor from a floating-point transformation
new Transfrom_s(string s)Creates an object from a string

Deprecated methods (protected, public, static, non-static and constructors)

[static]intm0Use of this method is deprecated. Use M0 instead
[static]intm135Use of this method is deprecated. Use M135 instead
[static]intm45Use of this method is deprecated. Use M45 instead
[static]intm90Use of this method is deprecated. Use M90 instead
[static]new Transnew_f(int f)Use of this method is deprecated. Use new instead
[static]new Transnew_fu(int f,
const Point u)
Use of this method is deprecated. Use new instead
[static]new Transnew_fxy(int f,
int x,
int y)
Use of this method is deprecated. Use new instead
[static]new Transnew_rmu(int rot,
bool mirr,
Point u)
Use of this method is deprecated. Use new instead
[static]new Transnew_rmxy(int rot,
bool mirr,
int x,
int y)
Use of this method is deprecated. Use new instead
[static]new Transnew_u(const Point u)Use of this method is deprecated. Use new instead
[static]new Transnew_xy(int x,
int y)
Use of this method is deprecated. Use new instead
[static]intr0Use of this method is deprecated. Use R0 instead
[static]intr180Use of this method is deprecated. Use R180 instead
[static]intr270Use of this method is deprecated. Use R270 instead
[static]intr90Use of this method is deprecated. Use R90 instead

Detailed description

[const] bool !=(const Trans other)

Description: Inequality test

[const] Trans *(const Trans *)

Description: Multiplication (concatenation) of transformations

t:The transformation to apply before
Returns:The modified transformation

The * operator returns self*t ("t is applied before this transformation").

[const] bool <(const Trans other)

Description: A sorting criterion

This method is provided to implement a sorting order. The definition of 'less' is opaque and might change in future versions.

[const] bool ==(const Trans other)

Description: Equality test

[static] int M0

Description: Angle/mirror code for the "mirrored at the x-axis" transformation

[static] int M135

Description: Angle/mirror code for the "mirrored at the 135 degree axis" transformation

[static] int M45

Description: Angle/mirror code for the "mirrored at the 45 degree axis" transformation

[static] int M90

Description: Angle/mirror code for the "mirrored at the y (90 degree) axis" transformation

[static] int R0

Description: Angle/mirror code for the "unrotated" transformation

[static] int R180

Description: Angle/mirror code for the "rotated by 180 degree counterclockwise" transformation

[static] int R270

Description: Angle/mirror code for the "rotated by 270 degree counterclockwise" transformation

[static] int R90

Description: Angle/mirror code for the "rotated by 90 degree counterclockwise" transformation

[const] int angle

Description: Gets the angle in units of 90 degree

This value delivers the rotation component. In addition, a mirroring at the x axis may be applied before if the is_mirror? property is true.

void angle=(int a)

Description: Sets the angle in units of 90 degree

a:The new angle

This method was introduced in version 0.20.

[const] void assign(const Trans other)

Description: Assign the contents of another object to self

This method assigns the contents of another object to self. This is a deep copy that does not only copy the reference but the actual content.

void create

Description: Ensures the C++ object is created

Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. Usually C++ objects are created on demand and not necessarily when the script object is created.

[const] int ctrans(int d)

Description: The transformation of a distance

d:The distance to transform
Returns:The transformed distance

The "ctrans" method transforms the given distance. e = t(d). For the simple transformations, there is no magnification and no modification of the distance therefore.

void destroy

Description: Explicitly destroy the object

Explicitly destroy the object on C++ side if it was owned by the Ruby interpreter. Subsequent access to this object will throw an exception. If the object is not owned by Ruby, this method will do nothing.

[const] bool destroyed?

Description: Returns a value indicating whether the object was already destroyed

This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself.

[const] Point disp

Description: Accessor to the point

void disp=(const Point u)

Description: Sets the displacement

u:The new displacement

This method was introduced in version 0.20.

[const] Trans dup

Description: Creates a copy of self

[static] Trans from_dtrans(const DTrans double_trans)

Description: Conversion constructor from a floating-point transformation

[static] new Trans from_s(string s)

Description: Creates an object from a string

Creates the object from a string representation (as returned by to_s)

This method has been added in version 0.23.

Trans invert

Description: In-place inversion

Returns:The inverted transformation

Inverts the transformation and replaces this object by the inverted one.

[const] Trans inverted

Description: Inversion

Returns:The inverted transformation

Returns the inverted transformation

[const] bool is_const_object?

Description: Returns a value indicating whether the reference is a const reference

This method returns true, if self is a const reference. In that case, only const methods may be called on self.

[const] bool is_mirror?

Description: Gets the mirror flag

If this property is true, the transformation is composed of a mirroring at the x-axis followed by a rotation by the angle given by the angle property.

[static] int m0

Description: Angle/mirror code for the "mirrored at the x-axis" transformation

This method is deprecated. Use method 'M0' instead

[static] int m135

Description: Angle/mirror code for the "mirrored at the 135 degree axis" transformation

This method is deprecated. Use method 'M135' instead

[static] int m45

Description: Angle/mirror code for the "mirrored at the 45 degree axis" transformation

This method is deprecated. Use method 'M45' instead

[static] int m90

Description: Angle/mirror code for the "mirrored at the y (90 degree) axis" transformation

This method is deprecated. Use method 'M90' instead

void mirror=(bool m)

Description: Sets the mirror flag

m:The new mirror flag

"mirroring" describes a reflection at the x-axis which is included in the transformation prior to rotation.

This method was introduced in version 0.20.

[static] new Trans new

Description: Creates a unit transformation

[static] new Trans new(int f)

Description: Conversion constructor from a fixpoint transformation

f:The rotation/mirror code (R0 .. M135 constants)

This constructor will create a transformation with a fixpoint transformation but no displacement.

[static] new Trans new(int rot,bool mirr,Point u)

Description: The standard constructor using angle and mirror flag

rot:The rotation in units of 90 degree
mirrx:True, if mirrored at x axis
u:The displacement

The sequence of operations is: mirroring at x axis, rotation, application of displacement.

[static] new Trans new(int rot,bool mirr,int x,int y)

Description: The standard constructor using angle and mirror flag and two coordinate values for displacement

rot:The rotation in units of 90 degree
mirrx:True, if mirrored at x axis
x:The horizontal displacement
y:The vertical displacement

The sequence of operations is: mirroring at x axis, rotation, application of displacement.

[static] new Trans new(int f,const Point u)

Description: The standard constructor using a code rather than angle and mirror

f:The rotation/mirror code (R0 .. M135 constants)
u:The displacement

[static] new Trans new(int f,int x,int y)

Description: The standard constructor using a code rather than angle and mirror and two coordinate values for displacement

f:The rotation/mirror code (R0 .. M135 constants)
x:The horizontal displacement
y:The vertical displacement

[static] new Trans new(const Point u)

Description: The standard constructor using a displacement only

u:The displacement

[static] new Trans new(int x,int y)

Description: The standard constructor using a displacement given as two coordinates

x:The horizontal displacement
y:The vertical displacement

[static] new Trans new_f(int f)

Description: Conversion constructor from a fixpoint transformation

f:The rotation/mirror code (R0 .. M135 constants)

This method is deprecated. Use method 'new' instead

[static] new Trans new_fu(int f,const Point u)

Description: The standard constructor using a code rather than angle and mirror

f:The rotation/mirror code (R0 .. M135 constants)
u:The displacement

This method is deprecated. Use method 'new' instead

[static] new Trans new_fxy(int f,int x,int y)

Description: The standard constructor using a code rather than angle and mirror and two coordinate values for displacement

f:The rotation/mirror code (R0 .. M135 constants)
x:The horizontal displacement
y:The vertical displacement

This method is deprecated. Use method 'new' instead

[static] new Trans new_rmu(int rot,bool mirr,Point u)

Description: The standard constructor using angle and mirror flag

rot:The rotation in units of 90 degree
mirrx:True, if mirrored at x axis
u:The displacement

This method is deprecated. Use method 'new' instead

[static] new Trans new_rmxy(int rot,bool mirr,int x,int y)

Description: The standard constructor using angle and mirror flag and two coordinate values for displacement

rot:The rotation in units of 90 degree
mirrx:True, if mirrored at x axis
x:The horizontal displacement
y:The vertical displacement

This method is deprecated. Use method 'new' instead

[static] new Trans new_u(const Point u)

Description: The standard constructor using a displacement only

u:The displacement

This method is deprecated. Use method 'new' instead

[static] new Trans new_xy(int x,int y)

Description: The standard constructor using a displacement given as two coordinates

x:The horizontal displacement
y:The vertical displacement

This method is deprecated. Use method 'new' instead

[static] int r0

Description: Angle/mirror code for the "unrotated" transformation

This method is deprecated. Use method 'R0' instead

[static] int r180

Description: Angle/mirror code for the "rotated by 180 degree counterclockwise" transformation

This method is deprecated. Use method 'R180' instead

[static] int r270

Description: Angle/mirror code for the "rotated by 270 degree counterclockwise" transformation

This method is deprecated. Use method 'R270' instead

[static] int r90

Description: Angle/mirror code for the "rotated by 90 degree counterclockwise" transformation

This method is deprecated. Use method 'R90' instead

[const] int rot

Description: Gets the angle/mirror code

The angle/mirror code is one of the constants R0, R90, R180, R270, M0, M45, M90 and M135. rx is the rotation by an angle of x counter clockwise. mx is the mirroring at the axis given by the angle x (to the x-axis).

void rot=(int r)

Description: Sets the angle/mirror code

r:The new angle/rotation code (see rot property)

This method was introduced in version 0.20.

[const] string to_s

Description: String conversion

[const] Point trans(const Point p)

Description: The transformation of a point

p:The point to transform
Returns:The transformed point

The "trans" method transforms the given point. q = t(p)