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.
Implements
- I
- I
- I
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
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).
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.
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.
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.
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.
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
readonly
Defined in
IOrientedRectangle.anchorGets or sets the x-coordinate of the anchor of this instance from the dynamicAnchor instance.
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
Implements
IOrientedRectangle.anchorXGets or sets the y-coordinate of the anchor of this instance from the dynamicAnchor instance.
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
Implements
IOrientedRectangle.anchorYAn 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.
Calculates the paraxial bounds of this oriented rectangle.
readonlyfinal
Property Value
The paraxial bounds of this oriented rectangle.
Implements
IOrientedRectangle.boundsGets or sets the current center of this oriented rectangle.
Gets or sets the current center of this oriented rectangle.
conversionfinal
Property Value
The current center of the rectangle.
Implements
IOrientedRectangle.centerGets or sets the anchor of this oriented 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.
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.
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.heightDefined in
ISize.isEmptyreadonly
Defined in
IOrientedRectangle.upVectorIt is up to the caller to ensure that the values describe a vector of length 1.
final
See Also
API
- angle, setUpVector, upY
Implements
IOrientedRectangle.upXIt is up to the caller to ensure that the values describe a vector of length 1.
final
See Also
API
- angle, setUpVector, upX
Implements
IOrientedRectangle.upYGets or sets the width of this instance from the dynamicSize instance.
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.widthGets or sets the x-coordinate of the anchor of this instance from the dynamicAnchor instance.
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.
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.
Create a clone of this object.
Determines whether the given oriented rectangle contains the provided point, using an epsilon value.
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
trueiff the point lies inside the rectangle.
Defined in
IOrientedRectangle.containsNote 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.
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.
Defined in
IOrientedRectangle.getEnlargedfinal
Return Value
- number
- A hash code for the values of this instance.
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
nullif the rectangle and the segment do not intersect.
Defined in
IOrientedRectangle.intersectionPointDetermines whether an OrientedRectangle intersects another one.
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
trueif the rectangles intersect andfalseotherwise.
Defined in
IOrientedRectangle.intersectsParameters
- 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
trueif the rectangle and the line segment intersect andfalseotherwise.
Defined in
IOrientedRectangle.intersectsMoves this rectangle by applying the offset to the dynamicAnchor.
Moves this rectangle by applying the offset to the dynamicAnchor.
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.
Sets the anchor of this oriented rectangle so that the center of the rectangle coincides with the given point.
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.
Applies the values provided by the given instance to the values of this instance.
Sets the up vector to the given value.
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.
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 immutable IOrientedRectangle from a given OrientedRectangle.
Creates an OrientedRectangle from a given IOrientedRectangle.
Creates an OrientedRectangle from a given IOrientedRectangle.
Return Value
Defined in
ISize.toSizeStatic Methods
createImmutable
(anchorX: numberanchorY: numberwidth: numberheight: numberupX: numberupY: number): IOrientedRectanglestaticCreates an immutable IOrientedRectangle with the given values.
createImmutable
(anchorX: number
anchorY: number
width: number
height: number
upX: number
upY: number
): IOrientedRectanglestatic
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.