C

OrientedRectangle

A mutable oriented rectangle in 2D coordinate space with double precision values stored in an instance of IMutablePoint and IMutableSize as well as two doubles for the up vector components.
ImplementsInheritance Hierarchy

Remarks

This implementation delegates the storage to implementations of IMutablePoint for the anchor of the oriented rectangle, and IMutableSize for the size of the oriented rectangle members. As a convenience, it implements the IMutablePoint and the ICloneable interfaces.

See Also

API

IOrientedRectangle

Members

Show:

Constructors

Initializes a new instance of the OrientedRectangle class located at 0.0d,0.0d with an empty width and height (-1.0d).
Creates a new instance using the provided rectangle to initialize the anchor and size.
The anchor will be set to the lower left corner of the provided rectangle. Thus this instance will have the exact same bounds as the rectangle initially. The up vector will be initialized to (0, -1).

Parameters

rectangle: IRectangle
The rectangle to initialize the anchor and size from.
Creates a new instance using the provided values to initialize.
This will basically create a copy of the given rectangle.

Parameters

rectangle: IOrientedRectangle
The rectangle to initialize the anchor and size and up vector from.
Creates a new instance using the provided values to initialize the anchor and size.
The up vector will be initialized to (0, -1). The instances provided will be referenced by this instance. This instance will be used as a live view over the provided instances. Changes to them will indirectly change the state of this instance and changes applied through this instance will be written to the referenced implementations.

Parameters

anchor: IMutablePoint
The provider for the dynamic anchor of this instance.
size: IMutableSize
The provider for the dynamic size of this instance.
Creates a new instance using the provided values to initialize the anchor and size.
It is up to the caller to ensure that the up vector is normalized.

Parameters

anchorX: number
The x-coordinate of the anchor of the oriented rectangle.
anchorY: number
The y-coordinate of the anchor of the oriented rectangle.
width: number
The width of the rectangle.
height: number
The height of the rectangle.
upX?: number
The x component of the up vector.
upY?: number
The y component of the up vector.

Properties

Gets the anchor location of the oriented rectangle as Point.
readonly
Gets or sets the x-coordinate of the anchor of this instance from the dynamicAnchor instance.
Note that depending on the implementation used for holding the anchor, the results may vary. However, the default implementation will do just that: read and write the values without modifying them in any way.
final
Gets or sets the y-coordinate of the anchor of this instance from the dynamicAnchor instance.
Note that depending on the implementation used for holding the anchor, the results may vary. However, the default implementation will do just that: read and write the values without modifying them in any way.
final
Gets or sets the orientation of this rectangle measured in radians.

An angle of 0 means the up vector points up in direction (0,-1). The angle value is not stored and will be recalculated from upX and upY every time this is invoked, so this is a costly method. Setting the angle changes the upX and upY values accordingly.

The angle is between 0 and PI if the up vector points to quadrant 1 or 4 and between -PI and 0 if the up vector points to quadrant 2 or 3.

final
Calculates the paraxial bounds of this oriented rectangle.
readonlyfinal

Property Value

The paraxial bounds of this oriented rectangle.
Gets or sets the current center of this oriented rectangle.
conversionfinal

Property Value

The current center of the rectangle.
Gets or sets the anchor of this oriented rectangle.
This will return a live view of the anchor of this rectangle. However, setting an anchor instance will only copy the values of the point provided to the current anchor.
conversionfinal
Gets or sets the size of this rectangle.
This will return a live view of the size of this rectangle. However, setting a size instance will only copy the values of the size provided to the current size.
conversionfinal
Gets or sets the height of this instance from the dynamicSize instance.
Note that depending on the implementation used for holding the size the results may vary. However, the default implementation will do just that: read and write the values without modifying them in any way.
final

Implements

ISize.height
Determines whether the specified size is empty.
ISize instances are considered empty if their width or height is less than 0.0d.
readonly

Defined in

ISize.isEmpty
Gets the up vector of the oriented rectangle as Point.
readonly
Gets or sets the x component of the up vector to the new value.
It is up to the caller to ensure that the values describe a vector of length 1.
final

See Also

API
angle, setUpVector, upY
Gets or sets the y component of the up vector to the new value.
It is up to the caller to ensure that the values describe a vector of length 1.
final

See Also

API
angle, setUpVector, upX
Gets or sets the width of this instance from the dynamicSize instance.
Note that depending on the implementation used for holding the size, the results may vary. However, the default implementation will do just that: read and write the values without modifying them in any way.
final

Implements

ISize.width
Gets or sets the x-coordinate of the anchor of this instance from the dynamicAnchor instance.
Note that depending on the implementation used for holding the anchor, the results may vary. However, the default implementation will do just that: read and write the values without modifying them in any way.
final
Gets or sets the y-coordinate of the anchor of this instance from the dynamicAnchor instance.
Note that depending on the implementation used for holding the anchor, the results may vary. However, the default implementation will do just that: read and write the values without modifying them in any way.
final

Methods

Create a clone of this object.
final

Return Value

Object
A clone of this object.
Determines whether the given oriented rectangle contains the provided point, using an epsilon value.

Parameters

point: IPoint
The coordinates of the point to test.
eps: number
A positive value allows for fuzzy hit testing. If the point lies outside the given object but its distance is less than or equal to that value, it will be considered a hit.

Return Value

boolean
true iff the point lies inside the rectangle.
Implements the Equals method by comparing the given object's values.
Note that only instances of this type and the ones returned by the factory methods of this type can be equal to each other.
final

Parameters

other: any
The other instance to compare the values against.

Return Value

boolean
Whether the other instance is of this type or the immutable types created by this class and whether their values are the same as for this type.
Creates an enlarged instance that is the same as this one but enlarged by the specified padding.

Parameters

padding: Insets
The padding to use to add to the instance.

Return Value

OrientedRectangle
A new OrientedRectangle instance which is enlarged by the given padding.
Yields a hash code for this type based on the values of upX, upY, width, anchorX, anchorY, and height.
final

Return Value

number
A hash code for the values of this instance.
Determines an intersection point of the given oriented rectangle and the line segment specified by the given endpoints.
Note: there might be more than one intersection point. However, this method only returns one intersection point or null if there is no intersection.

Parameters

lineP1: Point
The first endpoint of the line segment.
lineP2: Point
The second endpoint of the line segment.
eps: number
A positive value allows for fuzzy hit testing. The rectangle will be enlarged by the given value (or reduced in size by a negative value), so that an intersection point that otherwise would not be found may be returned.

Return Value

Point
An intersection point of the given oriented rectangle and the specified line segment or null if the rectangle and the segment do not intersect.
Determines whether an OrientedRectangle intersects another one.

Parameters

rect2: IOrientedRectangle
The second oriented rectangle to test.
eps: number
A positive value allows for fuzzy hit testing. If the point lies outside the given object but its distance is less than or equal to that value, it will be considered a hit.

Return Value

boolean
true if the rectangles intersect and false otherwise.
Determines whether the given oriented rectangle and the line segment defined by the two given points intersect.

Parameters

lineP1: Point
The first point defining the line segment.
lineP2: Point
The second point defining the line segment.
eps: number
A positive value allows for fuzzy hit testing. If the point lies outside the given object but its distance is less than or equal to that value, it will be considered a hit.

Return Value

boolean
true if the rectangle and the line segment intersect and false otherwise.
Moves this rectangle by applying the offset to the dynamicAnchor.
final

Parameters

delta: Point
The offset to move the rectangle's anchor by.
Moves this rectangle by applying the offset to the anchor.
final

Parameters

dx: number
The x offset to move the rectangle's position by.
dy: number
The y offset to move the rectangle's position by.
Sets the anchor of this oriented rectangle so that the center of the rectangle coincides with the given point.
final

Parameters

center: IPoint
The coordinates of the new center.
Sets the anchor of this oriented rectangle so that the center of the rectangle coincides with the given coordinate pair.
final

Parameters

cx: number
The x-coordinate of the center.
cy: number
The y-coordinate of the center.
Applies the values provided by the given instance to the values of this instance.
final

Parameters

rectangle: IOrientedRectangle
The instance to retrieve the values from.
Sets the up vector to the given value.
It is up to the caller to ensure that the values describe a vector of length 1.
final

Parameters

up: IPoint
The coordinates of the normalized up vector.
Sets the components of the up vector to the new values.
It is up to the caller to ensure that the values describe a vector of length 1.
final

Parameters

upx: number
The x component of the normalized up vector.
upy: number
The y component of the normalized up vector.

See Also

API
angle
Creates an immutable IOrientedRectangle from a given OrientedRectangle.
Creates an OrientedRectangle from a given IOrientedRectangle.
Creates a new Size instance with the current values of this size.

Return Value

Size
A new Size instance that has been initialized with the current values of size.

Defined in

ISize.toSize
Returns a that describes this instance.
final

Return Value

string
A that describes this instance.

Static Methods

Creates an immutable IOrientedRectangle with the given values.
static

Parameters

anchorX: number
The x-coordinate of the anchor of the oriented rectangle.
anchorY: number
The y-coordinate of the anchor of the oriented rectangle.
width: number
The width of the rectangle.
height: number
The height of the rectangle.
upX: number
The x component of the up vector.
upY: number
The y component of the up vector.

Return Value

IOrientedRectangle
An immutable IOrientedRectangle with the given values.