API reference - Class DCplxTrans

Notation used in Ruby API documentation

Description: A complex transformation

A complex transformation provides magnification, mirroring at the x-axis, rotation by an arbitary angle and a displacement. This is also the order, the operations are applied.

A complex transformation provides a superset of the simple transformation. In many applications, a complex transformation computes floating-point coordinates to minimize rounding effects. This version can transform floating-point coordinate objects.

Complex transformations are extensions of the simple transformation classes (DTrans in that case) and behave similar.

Transformations can be used to transform points or other objects. Transformations can be combined with the '*' operator to form the transformation which is equivalent to applying the second and then the first. Here is some code:

# Create a transformation that applies a magnication of 1.5, a rotation by 90 degree
# and displacement of 10 in x and 20 units in y direction:
t = RBA::CplxTrans::new(1.5, 90, false, 10.0, 20.0)
t.to_s            # r90 *1.5 10,20
# compute the inverse:
t.inverted.to_s   # r270 *0.666666667 -13,7
# Combine with another displacement (applied after that):
(RBA::CplxTrans::new(5, 5) * t).to_s    # r90 *1.5 15,25
# Transform a point:
t.trans(RBA::Point::new(100, 200)).to_s # -290,170

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

Public constructors

new DCplxTransnewCreates a unit transformation
new DCplxTransnew(int f)Conversion constructor from a fixpoint transformation
new DCplxTransnew(double x,
double y)
Constructor from a x and y displacement
new DCplxTransnew(double m)Constructor from a magnification
new DCplxTransnew(const DTrans t,
double m)
Constructor from a simple transformation and a magnification
new DCplxTransnew(const DTrans t)Constructor from a simple transformation alone
new DCplxTransnew(double mag,
double rot,
bool mirrx,
const DPoint u)
The standard constructor using magnification, angle, mirror flag and displacement
new DCplxTransnew(double mag,
double rot,
bool mirrx,
double x,
double y)
The standard constructor using magnification, angle, mirror flag and displacement

Public methods

[const]bool!=(const DCplxTrans other)Inequality test
[const]DCplxTrans*(const DCplxTrans t)Multiplication (concatenation) of transformations
[const]bool<(const DCplxTrans other)A sorting criterion
[const]bool==(const DCplxTrans other)Equality test
[const]doubleangleGets the angle
voidangle=(double a)Sets the angle
[const]voidassign(const DCplxTrans other)Assign the contents of another object to self
voidcreateEnsures the C++ object is created
[const]doublectrans(double d)The transformation of a distance
voiddestroyExplicitly destroy the object
[const]booldestroyed?Returns a value indicating whether the object was already destroyed
[const]DPointdispGets the displacement
voiddisp=(const DPoint u)Sets the displacement
[const]DCplxTransdupCreates a copy of self
DCplxTransinvertIn-place inversion
[const]DCplxTransinvertedInversion
[const]boolis_const_object?Returns a value indicating whether the reference is a const reference
[const]boolis_mag?Test, if the transformation is a magnifying one
[const]boolis_mirror?Gets the mirror flag
[const]boolis_ortho?Test, if the transformation is an orthogonal transformation
[const]boolis_unity?Test, whether this is a unit transformation
[const]doublemagGets the magnification
voidmag=(double m)Sets the magnification
voidmirror=(bool m)Sets the mirror flag
[const]introtReturns the respective simple transformation equivalent rotation code if possible
[const]DTranss_transExtract the simple transformation part
[const]stringto_sString conversion
[const]DPointtrans(const DPoint 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
DCplxTransfrom_itrans(const CplxTrans int_trans)Conversion constructor from an integer coordinate transformation
new DCplxTransfrom_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 DCplxTransnew_f(int f)Use of this method is deprecated. Use new instead
[static]new DCplxTransnew_m(double m)Use of this method is deprecated. Use new instead
[static]new DCplxTransnew_mrmu(double mag,
double rot,
bool mirrx,
const DPoint u)
Use of this method is deprecated. Use new instead
[static]new DCplxTransnew_mrmxy(double mag,
double rot,
bool mirrx,
double x,
double y)
Use of this method is deprecated. Use new instead
[static]new DCplxTransnew_t(const DTrans t)Use of this method is deprecated. Use new instead
[static]new DCplxTransnew_tm(const DTrans t,
double m)
Use of this method is deprecated. Use new instead
[static]new DCplxTransnew_xy(double x,
double 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 DCplxTrans other)

Description: Inequality test

[const] DCplxTrans *(const DCplxTrans t)

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 DCplxTrans 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 DCplxTrans 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] double angle

Description: Gets the angle

Returns:The rotation angle this transformation provides in degree units (0..360 deg).

Note that the simple transformation returns the angle in units of 90 degree. Hence for a simple trans (i.e. Trans), a rotation angle of 180 degree delivers a value of 2 for the angle attribute. The complex transformation, supporting any rotation angle returns the angle in degree.

void angle=(double a)

Description: Sets the angle

a:The new angle

See angle for a description of that attribute.

[const] void assign(const DCplxTrans 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] double ctrans(double 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] DPoint disp

Description: Gets the displacement

void disp=(const DPoint u)

Description: Sets the displacement

u:The new displacement

[const] DCplxTrans dup

Description: Creates a copy of self

[static] DCplxTrans from_itrans(const CplxTrans int_trans)

Description: Conversion constructor from an integer coordinate transformation

[static] new DCplxTrans 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.

DCplxTrans invert

Description: In-place inversion

Returns:The inverted transformation

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

[const] DCplxTrans 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_mag?

Description: Test, if the transformation is a magnifying one

This is the recommended test for checking if the transformation represents a magnification.

[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.

[const] bool is_ortho?

Description: Test, if the transformation is an orthogonal transformation

If the rotation is by a multiple of 90 degree, this method will return true.

[const] bool is_unity?

Description: Test, whether this is a unit transformation

[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

[const] double mag

Description: Gets the magnification

void mag=(double m)

Description: Sets the magnification

m:The new magnification

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.

[static] new DCplxTrans new

Description: Creates a unit transformation

[static] new DCplxTrans 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 DCplxTrans new(double x,double y)

Description: Constructor from a x and y displacement

x:The x displacement
y:The y displacement

This constructor will create a transformation with the specified displacement but no rotation.

[static] new DCplxTrans new(double m)

Description: Constructor from a magnification

Creates a magnifying transformation without displacement and rotation given the magnification m.

[static] new DCplxTrans new(const DTrans t,double m)

Description: Constructor from a simple transformation and a magnification

Creates a magnifying transformation from a simple transformation and a magnification.

[static] new DCplxTrans new(const DTrans t)

Description: Constructor from a simple transformation alone

Creates a magnifying transformation from a simple transformation and a magnification of 1.0.

[static] new DCplxTrans new(double mag,double rot,bool mirrx,const DPoint u)

Description: The standard constructor using magnification, angle, mirror flag and displacement

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

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

[static] new DCplxTrans new(double mag,double rot,bool mirrx,double x,double y)

Description: The standard constructor using magnification, angle, mirror flag and displacement

mag:The magnification
rot:The rotation angle in units of degree
mirrx:True, if mirrored at x axis
x:The x displacement
y:The y displacement

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

[static] new DCplxTrans 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 DCplxTrans new_m(double m)

Description: Constructor from a magnification

This method is deprecated. Use method 'new' instead

[static] new DCplxTrans new_mrmu(double mag,double rot,bool mirrx,const DPoint u)

Description: The standard constructor using magnification, angle, mirror flag and displacement

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

This method is deprecated. Use method 'new' instead

[static] new DCplxTrans new_mrmxy(double mag,double rot,bool mirrx,double x,double y)

Description: The standard constructor using magnification, angle, mirror flag and displacement

mag:The magnification
rot:The rotation angle in units of degree
mirrx:True, if mirrored at x axis
x:The x displacement
y:The y displacement

This method is deprecated. Use method 'new' instead

[static] new DCplxTrans new_t(const DTrans t)

Description: Constructor from a simple transformation alone

This method is deprecated. Use method 'new' instead

[static] new DCplxTrans new_tm(const DTrans t,double m)

Description: Constructor from a simple transformation and a magnification

This method is deprecated. Use method 'new' instead

[static] new DCplxTrans new_xy(double x,double y)

Description: Constructor from a x and y displacement

x:The x displacement
y:The y 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: Returns the respective simple transformation equivalent rotation code if possible

If this transformation is orthogonal (is_ortho () == true), then this method will return the corresponding fixpoint transformation, not taking into account magnification and displacement. If the transformation is not orthogonal, the result reflects the quadrant the rotation goes into.

[const] DTrans s_trans

Description: Extract the simple transformation part

The simple transformation part does not reflect magnification or arbitrary angles. Rotation angles are rounded down to multiples of 90 degree. Magnification is fixed to 1.0.

[const] string to_s

Description: String conversion

[const] DPoint trans(const DPoint 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)