API reference - Class DVector

Notation used in Ruby API documentation

Module: db

Description: A vector class with double (floating-point) coordinates

A vector is a distance in cartesian, 2 dimensional space. A vector is given by two coordinates (x and y) and represents the distance between two points. Being the distance, transformations act differently on vectors: the displacement is not applied. Vectors are not geometrical objects by itself. But they are frequently used in the database API for various purposes. Other than the integer variant (Vector), points with floating-point coordinates can represent fractions of a database unit or vectors in physical (micron) units.

This class has been introduced in version 0.25.

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

Public constructors

new DVector ptrnew(const Vector vector)Creates a floating-point coordinate vector from an integer coordinate vector
new DVector ptrnewDefault constructor: creates a null vector with coordinates (0,0)
new DVector ptrnew(const DPoint p)Default constructor: creates a vector from a point
new DVector ptrnew(double x,
double y)
Constructor for a vector from two coordinate values

Public methods

[const]bool!=(const DVector v)Inequality test operator
[const]DVector*(double f)Scaling by some factor
[const]double*(const DVector v)Computes the scalar product between self and the given vector
DVector*=(double f)Scaling by some factor
[const]DVector+(const DVector v)Adds two vectors
[const]DPoint+(const DPoint p)Adds a vector and a point
[const]DVector-(const DVector v)Subtract two vectors
[const]DVector-@Compute the negative of a vector
[const]DVector/(double d)Division by some divisor
DVector/=(double d)Division by some divisor
[const]bool<(const DVector v)"less" comparison operator
[const]bool==(const DVector v)Equality test operator
void_createEnsures the C++ object is created
void_destroyExplicitly destroys the object
[const]bool_destroyed?Returns a value indicating whether the object was already destroyed
[const]bool_is_const_object?Returns a value indicating whether the reference is a const reference
void_manageMarks the object as managed by the script side.
void_unmanageMarks the object as no longer owned by the script side.
[const]doubleabsReturns the length of the vector
voidassign(const DVector other)Assigns another object to self
[const]new DVector ptrdupCreates a copy of self
[const]unsigned longhashComputes a hash value
[const]doublelengthReturns the length of the vector
[const]doublesprod(const DVector v)Computes the scalar product between self and the given vector
[const]intsprod_sign(const DVector v)Computes the scalar product between self and the given vector and returns a value indicating the sign of the product
[const]doublesq_absThe square length of the vector
[const]doublesq_lengthThe square length of the vector
[const]Vectorto_itype(double dbu = 1)Converts the point to an integer coordinate point
[const]DPointto_pTurns the vector into a point
[const]stringto_sString conversion
[const]doublevprod(const DVector v)Computes the vector product between self and the given vector
[const]intvprod_sign(const DVector v)Computes the vector product between self and the given vector and returns a value indicating the sign of the product
[const]doublexAccessor to the x coordinate
voidx=(double coord)Write accessor to the x coordinate
[const]doubleyAccessor to the y coordinate
voidy=(double coord)Write accessor to the y coordinate

Public static methods and constants

new DVector ptrfrom_s(string s)Creates an object from a string

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

voidcreateUse of this method is deprecated. Use _create instead
voiddestroyUse of this method is deprecated. Use _destroy instead
[const]booldestroyed?Use of this method is deprecated. Use _destroyed? instead
[const]boolis_const_object?Use of this method is deprecated. Use _is_const_object? instead

Detailed description

!=

Signature: [const] bool != (const DVector v)

Description: Inequality test operator

*

(1) Signature: [const] DVector * (double f)

Description: Scaling by some factor

Returns the scaled object. All coordinates are multiplied with the given factor and if necessary rounded.

Python specific notes:
This method is also available as '__rmul__'

(2) Signature: [const] double * (const DVector v)

Description: Computes the scalar product between self and the given vector

The scalar product of a and b is defined as: vp = ax*bx+ay*by.

Python specific notes:
This method is also available as '__rmul__'

*=

Signature: DVector *= (double f)

Description: Scaling by some factor

Scales object in place. All coordinates are multiplied with the given factor and if necessary rounded.

+

(1) Signature: [const] DVector + (const DVector v)

Description: Adds two vectors

Adds vector v to self by adding the coordinates.

(2) Signature: [const] DPoint + (const DPoint p)

Description: Adds a vector and a point

Returns the point p shifted by the vector.

-

Signature: [const] DVector - (const DVector v)

Description: Subtract two vectors

Subtract vector v from self by subtracting the coordinates.

-@

Signature: [const] DVector -@

Description: Compute the negative of a vector

Returns a new vector with -x,-y.

/

Signature: [const] DVector / (double d)

Description: Division by some divisor

Returns the scaled object. All coordinates are divided with the given divisor and if necessary rounded.

/=

Signature: DVector /= (double d)

Description: Division by some divisor

Divides the object in place. All coordinates are divided with the given divisor and if necessary rounded.

<

Signature: [const] bool < (const DVector v)

Description: "less" comparison operator

This operator is provided to establish a sorting order

==

Signature: [const] bool == (const DVector v)

Description: Equality test operator

_create

Signature: 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.

_destroy

Signature: void _destroy

Description: Explicitly destroys the object

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

_destroyed?

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

_is_const_object?

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

_manage

Signature: void _manage

Description: Marks the object as managed by the script side.

After calling this method on an object, the script side will be responsible for the management of the object. This method may be called if an object is returned from a C++ function and the object is known not to be owned by any C++ instance. If necessary, the script side may delete the object if the script's reference is no longer required.

Usually it's not required to call this method. It has been introduced in version 0.24.

_unmanage

Signature: void _unmanage

Description: Marks the object as no longer owned by the script side.

Calling this method will make this object no longer owned by the script's memory management. Instead, the object must be managed in some other way. Usually this method may be called if it is known that some C++ object holds and manages this object. Technically speaking, this method will turn the script's reference into a weak reference. After the script engine decides to delete the reference, the object itself will still exist. If the object is not managed otherwise, memory leaks will occur.

Usually it's not required to call this method. It has been introduced in version 0.24.

abs

Signature: [const] double abs

Description: Returns the length of the vector

'abs' is an alias provided for compatibility with the former point type.

assign

Signature: void assign (const DVector other)

Description: Assigns another object to self

create

Signature: void create

Description: Ensures the C++ object is created

Use of this method is deprecated. Use _create instead

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.

destroy

Signature: void destroy

Description: Explicitly destroys the object

Use of this method is deprecated. Use _destroy instead

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

destroyed?

Signature: [const] bool destroyed?

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

Use of this method is deprecated. Use _destroyed? instead

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.

dup

Signature: [const] new DVector ptr dup

Description: Creates a copy of self

Python specific notes:
This method also implements '__copy__'

from_s

Signature: [static] new DVector ptr from_s (string s)

Description: Creates an object from a string

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

hash

Signature: [const] unsigned long hash

Description: Computes a hash value

Returns a hash value for the given vector. This method enables vectors as hash keys.

This method has been introduced in version 0.25.

Python specific notes:
This method is also available as 'hash(object)'

is_const_object?

Signature: [const] bool is_const_object?

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

Use of this method is deprecated. Use _is_const_object? instead

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

length

Signature: [const] double length

Description: Returns the length of the vector

'abs' is an alias provided for compatibility with the former point type.

new

(1) Signature: [static] new DVector ptr new (const Vector vector)

Description: Creates a floating-point coordinate vector from an integer coordinate vector

Python specific notes:
This method is the default initializer of the object

(2) Signature: [static] new DVector ptr new

Description: Default constructor: creates a null vector with coordinates (0,0)

Python specific notes:
This method is the default initializer of the object

(3) Signature: [static] new DVector ptr new (const DPoint p)

Description: Default constructor: creates a vector from a point

This constructor is equivalent to computing p-point(0,0). This method has been introduced in version 0.25.

Python specific notes:
This method is the default initializer of the object

(4) Signature: [static] new DVector ptr new (double x, double y)

Description: Constructor for a vector from two coordinate values

Python specific notes:
This method is the default initializer of the object

sprod

Signature: [const] double sprod (const DVector v)

Description: Computes the scalar product between self and the given vector

The scalar product of a and b is defined as: vp = ax*bx+ay*by.

sprod_sign

Signature: [const] int sprod_sign (const DVector v)

Description: Computes the scalar product between self and the given vector and returns a value indicating the sign of the product

Returns:1 if the scalar product is positive, 0 if it is zero and -1 if it is negative.

sq_abs

Signature: [const] double sq_abs

Description: The square length of the vector

'sq_abs' is an alias provided for compatibility with the former point type.

sq_length

Signature: [const] double sq_length

Description: The square length of the vector

'sq_abs' is an alias provided for compatibility with the former point type.

to_itype

Signature: [const] Vector to_itype (double dbu = 1)

Description: Converts the point to an integer coordinate point

The database unit can be specified to translate the floating-point coordinate vector in micron units to an integer-coordinate vector in database units. The vector's' coordinates will be divided by the database unit.

to_p

Signature: [const] DPoint to_p

Description: Turns the vector into a point

This method returns the point resulting from adding the vector to (0,0). This method has been introduced in version 0.25.

to_s

Signature: [const] string to_s

Description: String conversion

Python specific notes:
This method is also available as 'str(object)'

vprod

Signature: [const] double vprod (const DVector v)

Description: Computes the vector product between self and the given vector

The vector product of a and b is defined as: vp = ax*by-ay*bx.

vprod_sign

Signature: [const] int vprod_sign (const DVector v)

Description: Computes the vector product between self and the given vector and returns a value indicating the sign of the product

Returns:1 if the vector product is positive, 0 if it is zero and -1 if it is negative.

x

Signature: [const] double x

Description: Accessor to the x coordinate

Python specific notes:
The object exposes a readable attribute 'x'. This is the getter.

x=

Signature: void x= (double coord)

Description: Write accessor to the x coordinate

Python specific notes:
The object exposes a writable attribute 'x'. This is the setter.

y

Signature: [const] double y

Description: Accessor to the y coordinate

Python specific notes:
The object exposes a readable attribute 'y'. This is the getter.

y=

Signature: void y= (double coord)

Description: Write accessor to the y coordinate

Python specific notes:
The object exposes a writable attribute 'y'. This is the setter.