MutableParallelogram


public final class MutableParallelogram extends Parallelogram


Mutable parallelogram (i.e. a quadrilateral with parallel sides), defined by its center, width, height, rotation, and shearFactor.

Summary

Public constructors

Constructs an empty MutableParallelogram with a center at the origin, a zero width, a zero height, zero rotation, and zero shear factor.

Public methods

boolean
equals(Object other)
@NonNull MutableVec
float

A Parallelogram may have a positive or negative height; a positive height indicates that the angle from the first semi-axis to the second will also be positive.

@AngleRadiansFloat float
float

A Parallelogram] may have a positive or negative shear factor; a positive shear factor indicates a smaller absolute angle between the semi-axes (the shear factor is, in fact, the cotangent of that angle).

@FloatRange(from = 0.0) float

A Parallelogram may not have a negative width.

int
final @NonNull MutableParallelogram

Fills this MutableParallelogram with the same values contained in input.

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.

final @NonNull MutableParallelogram
populateFromCenterDimensionsAndRotation(
    @NonNull MutableVec center,
    @FloatRange(from = 0.0) float width,
    float height,
    @AngleRadiansFloat float rotation
)

Populates the MutableParallelogram to have a given center, width, height and rotation and zero shearFactor.

final @NonNull MutableParallelogram
populateFromCenterDimensionsRotationAndShear(
    @NonNull MutableVec center,
    @FloatRange(from = 0.0) float width,
    float height,
    @AngleRadiansFloat float rotation,
    float shearFactor
)

Populates the MutableParallelogram to have a given center, width, height, rotation and shearFactor.

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 shear of zero.

void
void
setHeight(float height)

A Parallelogram may have a positive or negative height; a positive height indicates that the angle from the first semi-axis to the second will also be positive.

void
setRotation(float rotation)
void
setShearFactor(float shearFactor)

A Parallelogram] may have a positive or negative shear factor; a positive shear factor indicates a smaller absolute angle between the semi-axes (the shear factor is, in fact, the cotangent of that angle).

void
setWidth(float width)

A Parallelogram may not have a negative width.

@NonNull String

Inherited methods

From androidx.ink.geometry.Parallelogram
final @NonNull ImmutableBox

Returns the minimum bounding box containing the Parallelogram.

final @NonNull MutableBox

Returns the minimum bounding box containing the Parallelogram.

final @NonNull List<@NonNull ImmutableVec>

Returns a list containing the 4 corners of the Parallelogram.

final void
computeCorners(
    @NonNull MutableVec outCorner1,
    @NonNull MutableVec outCorner2,
    @NonNull MutableVec outCorner3,
    @NonNull MutableVec outCorner4
)

Populates the 4 output points with the corners of the Parallelogram.

final @NonNull List<@NonNull ImmutableVec>

Returns the semi axes of this Parallelogram.

final void

Fills the MutableVecs with the semi axes of this Parallelogram.

final float

Returns the signed area of the Parallelogram.

final boolean

Returns whether the given point is contained within the Box.

final boolean
isAlmostEqual(
    @NonNull Parallelogram other,
    @FloatRange(from = 0.0) float tolerance
)

Compares this Parallelogram with other, and returns true if both center points are considered almost equal with the given tolerance, and the difference between width and other.width is less than tolerance, and likewise for height, rotation, and shearFactor.

Public constructors

MutableParallelogram

Added in 1.0.0-alpha06
public MutableParallelogram()

Constructs an empty MutableParallelogram with a center at the origin, a zero width, a zero height, zero rotation, and zero shear factor. This is intended for subsequent population with one of the populateFrom methods.

Public methods

equals

public boolean equals(Object other)

getCenter

public @NonNull MutableVec getCenter()

getHeight

public float getHeight()

A Parallelogram may have a positive or negative height; a positive height indicates that the angle from the first semi-axis to the second will also be positive.

getRotation

public @AngleRadiansFloat float getRotation()

getShearFactor

public float getShearFactor()

A Parallelogram] may have a positive or negative shear factor; a positive shear factor indicates a smaller absolute angle between the semi-axes (the shear factor is, in fact, the cotangent of that angle).

getWidth

public @FloatRange(from = 0.0) float getWidth()

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 π to the angle of rotation, and normalizing rotation to the range [0, 2π).

hashCode

public int hashCode()

populateFrom

Added in 1.0.0-alpha06
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.

populateFromCenterAndDimensions

Added in 1.0.0-alpha06
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 shearFactor. If the width is less than zero, the Parallelogram will be normalized.

populateFromCenterDimensionsAndRotation

Added in 1.0.0-alpha06
public final @NonNull MutableParallelogram populateFromCenterDimensionsAndRotation(
    @NonNull MutableVec center,
    @FloatRange(from = 0.0) float width,
    float height,
    @AngleRadiansFloat float rotation
)

Populates the MutableParallelogram to have a given center, width, height and rotation and zero shearFactor. If the width is less than zero or if the rotation is not in the range [0, 2π), it will be normalized.

populateFromCenterDimensionsRotationAndShear

Added in 1.0.0-alpha06
public final @NonNull MutableParallelogram populateFromCenterDimensionsRotationAndShear(
    @NonNull MutableVec center,
    @FloatRange(from = 0.0) float width,
    float height,
    @AngleRadiansFloat float rotation,
    float shearFactor
)

Populates the MutableParallelogram to have a given center, width, height, rotation and shearFactor. If the width is less than zero or if the rotation is not in the range [0, 2π), it will be normalized.

populateFromSegmentAndPadding

Added in 1.0.0-alpha06
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 shear of zero.

setCenter

Added in 1.0.0-alpha06
public void setCenter(@NonNull MutableVec center)

setHeight

Added in 1.0.0-alpha06
public void setHeight(float height)

A Parallelogram may have a positive or negative height; a positive height indicates that the angle from the first semi-axis to the second will also be positive.

setRotation

Added in 1.0.0-alpha06
public void setRotation(float rotation)

setShearFactor

Added in 1.0.0-alpha06
public void setShearFactor(float shearFactor)

A Parallelogram] may have a positive or negative shear factor; a positive shear factor indicates a smaller absolute angle between the semi-axes (the shear factor is, in fact, the cotangent of that angle).

setWidth

Added in 1.0.0-alpha06
public void setWidth(float width)

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 π to the angle of rotation, and normalizing rotation to the range [0, 2π).

toString

public @NonNull String toString()