MutableParallelogram
public final class MutableParallelogram extends Parallelogram
Mutable parallelogram (i.e. a quadrilateral with parallel sides), defined by its center, width, height, rotation, and skew.
Summary
Public constructors |
|---|
|
Constructs an empty |
Public methods |
|
|---|---|
boolean |
|
@NonNull MutableVec |
|
float |
The height of the |
@FloatRange(from = 0.0, to = 360.0, toInclusive = false) @AngleDegreesFloat float |
The rotation of the |
float |
getSkew()The horizontal displacement between the two horizontal edges of the |
@FloatRange(from = 0.0) float |
getWidth()The width of the |
int |
hashCode() |
final @NonNull MutableParallelogram |
populateFrom(@NonNull Parallelogram input)Fills this |
final @NonNull MutableParallelogram |
populateFromCenterAndDimensions(Populates a |
final @NonNull MutableParallelogram |
populateFromCenterDimensionsAndRotationInDegrees(Populates the |
final @NonNull MutableParallelogram |
populateFromCenterDimensionsRotationInDegreesAndSkew(Populates the |
final @NonNull MutableParallelogram |
populateFromSegmentAndPadding(@NonNull Segment segment, float padding)Populates the |
void |
setCenter(@NonNull MutableVec center) |
void |
setHeight(float height)The height of the |
void |
setRotationDegrees(float rotationDegrees)The rotation of the |
void |
setSkew(float skew)The horizontal displacement between the two horizontal edges of the |
void |
setWidth(float width)The width of the |
@NonNull String |
toString() |
Inherited methods |
||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
MutableParallelogram
public MutableParallelogram()
Constructs an empty MutableParallelogram with a center at the origin, a zero width, a zero height, zero rotation, and zero skew. This is intended for subsequent population with one of the populateFrom methods.
Public methods
getHeight
public float getHeight()
The height of the Parallelogram. May be positive or negative, corresponding to whether the angle from the first semi-axis to the second is also positive or negative.
getRotationDegrees
public @FloatRange(from = 0.0, to = 360.0, toInclusive = false) @AngleDegreesFloat float getRotationDegrees()
The rotation of the Parallelogram in degrees from its original axis-aligned orientation in the direction from the positive x-axis towards the positive y-axis.
getSkew
public float getSkew()
The horizontal displacement between the two horizontal edges of the Parallelogram pre-rotation, as a multiple of the height. Equivalently, this is the cotangent of the absolute angle between the semi-axes. A Parallelogram may have a positive or negative skew, a greater skew indicates a smaller absolute angle between the semi-axes.
getWidth
public @FloatRange(from = 0.0) float getWidth()
The width of the Parallelogram. A Parallelogram may not have a negative width. If an operation on a parallelogram would result in a negative width, it is instead normalized, by negating both the width and the height, adding 180 to rotationDegrees and normalizing that to the range [0, 360).
populateFrom
public final @NonNull MutableParallelogram populateFrom(@NonNull Parallelogram input)
Fills this MutableParallelogram with the same values contained in input.
Returns the modified instance to allow chaining calls.
| Returns | |
|---|---|
@NonNull MutableParallelogram |
|
populateFromCenterAndDimensions
public final @NonNull MutableParallelogram populateFromCenterAndDimensions(
@NonNull MutableVec center,
@FloatRange(from = 0.0) float width,
float height
)
Populates a MutableParallelogram to have a given center, width and height. The resulting Parallelogram has zero rotation and skew. If the width is less than zero, the Parallelogram will be normalized.
See the corresponding fields on Parallelogram for details about these parameters.
| Returns | |
|---|---|
@NonNull MutableParallelogram |
|
populateFromCenterDimensionsAndRotationInDegrees
public final @NonNull MutableParallelogram populateFromCenterDimensionsAndRotationInDegrees(
@NonNull MutableVec center,
@FloatRange(from = 0.0) float width,
float height,
@FloatRange(from = 0.0, to = 360.0, toInclusive = false) @AngleDegreesFloat float rotationDegrees
)
Populates the MutableParallelogram to have a given center, width, height and rotationDegrees, with zero skew. If the width is less than zero or if the rotationDegrees is not in the range [0, 360), it will be normalized.
See the corresponding fields on Parallelogram for details about these parameters.
| Returns | |
|---|---|
@NonNull MutableParallelogram |
|
populateFromCenterDimensionsRotationInDegreesAndSkew
public final @NonNull MutableParallelogram populateFromCenterDimensionsRotationInDegreesAndSkew(
@NonNull MutableVec center,
@FloatRange(from = 0.0) float width,
float height,
@FloatRange(from = 0.0, to = 360.0, toInclusive = false) @AngleDegreesFloat float rotationDegrees,
float skew
)
Populates the MutableParallelogram to have a given center, width, height, rotationDegrees and skew. If the width is less than zero or if rotationDegrees is not within the range [0, 360.0), it will be normalized.
See the corresponding fields on Parallelogram for details about these parameters.
| Returns | |
|---|---|
@NonNull MutableParallelogram |
|
populateFromSegmentAndPadding
public final @NonNull MutableParallelogram populateFromSegmentAndPadding(@NonNull Segment segment, float padding)
Populates the MutableParallelogram to be aligned with the segment with its bounds padding units away from the segment and skew of zero.
| Returns | |
|---|---|
@NonNull MutableParallelogram |
|
setHeight
public void setHeight(float height)
The height of the Parallelogram. May be positive or negative, corresponding to whether the angle from the first semi-axis to the second is also positive or negative.
setRotationDegrees
public void setRotationDegrees(float rotationDegrees)
The rotation of the Parallelogram in degrees from its original axis-aligned orientation in the direction from the positive x-axis towards the positive y-axis.
setSkew
public void setSkew(float skew)
The horizontal displacement between the two horizontal edges of the Parallelogram pre-rotation, as a multiple of the height. Equivalently, this is the cotangent of the absolute angle between the semi-axes. A Parallelogram may have a positive or negative skew, a greater skew indicates a smaller absolute angle between the semi-axes.
setWidth
public void setWidth(float width)
The width of the Parallelogram. A Parallelogram may not have a negative width. If an operation on a parallelogram would result in a negative width, it is instead normalized, by negating both the width and the height, adding 180 to rotationDegrees and normalizing that to the range [0, 360).