Class DBox (version 0.18)

Description: A box class

This object represents a box (a rectangular shape). Notation is: p1 is the lower left point, p2 the upper right one. A box can be empty. An empty box represents no area (not even a point). A box can be a point or a single line. In this case, the area is zero but the box still can overlap other boxes.

Class overview

Index

Method Overview

[static] DBox from_ibox( Box int_box )Construct a floating-point coordinate box from an integer coordinate box
[static] DBox newDefault constructor: creates an empty (invalid) box
[static] DBox new( double left, double bottom, double right, double top )Constructor with four coordinates
[static] DBox new( DPoint lower_left, DPoint upper_right )Constructor with two points
[const] const ref DPoint p1The lower left point of the box
[const] const ref DPoint p2The upper right point of the box
[const] DPoint centerThe center of the box
[const] double leftThe left coordinate of the box
[const] double rightThe right coordinate of the box
[const] double bottomThe bottom coordinate of the box
[const] double topThe top coordinate of the box
[const] double widthThe width of the box
[const] double heightThe height of the box
left=( double )Set the left coordinate of the box
right=( double )Set the right coordinate of the box
bottom=( double )Set the bottom coordinate of the box
top=( double )Set the top coordinate of the box
p1=( DPoint )Set the lower left point of the box
p2=( DPoint )Set the upper right point of the box
[const] bool contains?( DPoint point )"contains" test
[const] bool empty?Empty predicate
[const] bool inside?( DBox box )Test if this box is inside the argument box
[const] bool touches?( DBox box )Test if this box touches the argument box
[const] bool overlaps?( DBox box )Test if this box overlaps the argument box
[const] double areaCompute the box area
[const] bool is_point?Return true, if the box is a single point
[const] DBox +( DPoint point )Join box with a point.
DBox +( DBox box )Joining of boxes.
DBox &( DBox box )Intersection of boxes.
DBox *( DBox box )Convolve boxes.
ref DBox move( DPoint distance )Moves the box by a certain distance
[const] DBox moved( DPoint distance )Returns the box moved by a certain distance
ref DBox enlarge( DPoint enlargement )Enlarges the box by a certain amount.
[const] DBox enlarged( DPoint enlargement )Enlarges the box by a certain amount.
[const] DBox transformed( DTrans t )Transform the box with the given simple transformation
[const] DBox transformed_cplx( DCplxTrans t )Transform the box with the given complex transformation
[const] bool <( DBox box )Less operator
[const] bool ==( DBox box )Equality
[const] bool !=( DBox box )Inequality
[const] string to_sConvert to a string
assign( DBox other )Assign the contents of another object to self
[const] DBox dupCreates a copy of self.
destroyExplicitly destroy the object
[const] bool destroyedTell, if the object was destroyed

[const] bool !=( DBox box )

Description: Inequality

Return true, if this box and the given box are not equal

DBox &( DBox box )

Description: Intersection of boxes.

The intersection of two boxes is the largest box common to both boxes. The intersection may be empty if both boxes to not touch. If the boxes do not overlap but touch the result may be a single line or point with an area of zero. Overwrites this box with the result.

c:The box to take the intersection with
returns:The intersection box.

DBox *( DBox box )

Description: Convolve boxes.

The * operator convolves the firstbox with the one given as the second argument. The box resulting from "convolution" is the outer boundary of the union set formed by placing the second box at every point of the first. In other words, the returned box of (p1,p2)*(q1,q2) is (p1+q1,p2+q2).

box:The box to convolve with this box.
returns:The convolved box.

[const] DBox +( DPoint point )

Description: Join box with a point.

The + operator joins a point with the box. The resulting box will enclose both the original box and the point.

point:The point to join with this box.
returns:The box joined with the point.

DBox +( DBox box )

Description: Joining of boxes.

The + operator joins the first box with the one given as the second argument. Joining constructs a box that encloses both boxes given. Empty boxes are neutral: they do not change another box when joining. Overwrites this box with the result.

box:The box to join with this box.
returns:The joined box.

[const] bool <( DBox box )

Description: Less operator

Return true, if this box is 'less' with respect to first and second point (in this order)

[const] bool ==( DBox box )

Description: Equality

Return true, if this box and the given box are equal

[const] double area

Description: Compute the box area

Returns the box area or 0 if the box is empty

assign( DBox 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.

[const] double bottom

Description: The bottom coordinate of the box

bottom=( double )

Description: Set the bottom coordinate of the box

[const] DPoint center

Description: The center of the box

[const] bool contains?( DPoint point )

Description: "contains" test

Tests whether a point is inside the box. This includes if the point is on the box contour.

p:The point to test against.
returns:true if the point is inside p.

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: Tell, if the object was 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] DBox dup

Description: Creates a copy of self.

[const] bool empty?

Description: Empty predicate

An empty box may be created with the default constructor for example. Such a box is neutral when combining it with other boxes and renders empty boxes if used in box intersections and false in geometrical relationship tests.

ref DBox enlarge( DPoint enlargement )

Description: Enlarges the box by a certain amount.

Enlarges the box by x and y value specified in the vector passed. Positive values with grow the box, negative ones will shrink the box. The result may be an empty box if the box disappears. The amount specifies the grow or shrink per edge. The width and height will change by twice the amount. Does not check for coordinate overflows.

enlargement:The grow or shrink amount in x and y direction
returns:A reference to this box.

[const] DBox enlarged( DPoint enlargement )

Description: Enlarges the box by a certain amount.

Enlarges the box by x and y value specified in the vector passed. Positive values with grow the box, negative ones will shrink the box. The result may be an empty box if the box disappears. The amount specifies the grow or shrink per edge. The width and height will change by twice the amount. Does not modify this box. Does not check for coordinate overflows.

enlargement:The grow or shrink amount in x and y direction
returns:The enlarged box.

[static] DBox from_ibox( Box int_box )

Description: Construct a floating-point coordinate box from an integer coordinate box

Create a floating-point coordinate box from an integer coordinate box

[const] double height

Description: The height of the box

[const] bool inside?( DBox box )

Description: Test if this box is inside the argument box

Returns true, if this box is inside the given box, i.e. the box intersection renders this box

[const] bool is_point?

Description: Return true, if the box is a single point

[const] double left

Description: The left coordinate of the box

left=( double )

Description: Set the left coordinate of the box

ref DBox move( DPoint distance )

Description: Moves the box by a certain distance

Moves the box by a given offset and returns the moved box. Does not check for coordinate overflows.

distance:The offset to move the box.
returns:A reference to this box.

[const] DBox moved( DPoint distance )

Description: Returns the box moved by a certain distance

Moves the box by a given offset and returns the moved box. Does not modify this box. Does not check for coordinate overflows.

distance:The offset to move the box.
returns:The moved box.

[static] DBox new( double left, double bottom, double right, double top )
synonym: [static] DBox new_lbrt( double left, double bottom, double right, double top )

Description: Constructor with four coordinates

Four coordinates are given to create a new box. If the coordinates are not provided in the correct order (i.e. right < left), these are swapped.

[static] DBox new

Description: Default constructor: creates an empty (invalid) box

[static] DBox new( DPoint lower_left, DPoint upper_right )
synonym: [static] DBox new_pp( DPoint lower_left, DPoint upper_right )

Description: Constructor with two points

Two points are given to create a new box. If the coordinates are not provided in the correct order (i.e. right < left), these are swapped.

[const] bool overlaps?( DBox box )

Description: Test if this box overlaps the argument box

Returns true, if the intersection box of this box with the argument box exists and has a non-vanishing area

[const] const ref DPoint p1

Description: The lower left point of the box

p1=( DPoint )

Description: Set the lower left point of the box

[const] const ref DPoint p2

Description: The upper right point of the box

p2=( DPoint )

Description: Set the upper right point of the box

[const] double right

Description: The right coordinate of the box

right=( double )

Description: Set the right coordinate of the box

[const] string to_s

Description: Convert to a string

[const] double top

Description: The top coordinate of the box

top=( double )

Description: Set the top coordinate of the box

[const] bool touches?( DBox box )

Description: Test if this box touches the argument box

Returns true, if this box has at least one point common with the argument box

[const] DBox transformed( DTrans t )

Description: Transform the box with the given simple transformation

t:The transformation to apply
returns:The transformed box

[const] DBox transformed_cplx( DCplxTrans t )

Description: Transform the box with the given complex transformation

t:The magnifying transformation to apply
returns:The transformed box (a DBox now)

[const] double width

Description: The width of the box