ImmutableParallelogram


public final class ImmutableParallelogram extends Parallelogram


Immutable parallelogram (i.e. a quadrilateral with parallel sides), defined by its center, width, height, rotationDegrees, and skew.

Summary

Public methods

boolean
equals(Object other)
static final @NonNull ImmutableParallelogram
fromCenterAndDimensions(
    @NonNull ImmutableVec center,
    @FloatRange(from = 0.0) float width,
    float height
)

Constructs an ImmutableParallelogram with a given center, width and height.

static final @NonNull ImmutableParallelogram
fromCenterDimensionsAndRotationInDegrees(
    @NonNull ImmutableVec center,
    @FloatRange(from = 0.0) float width,
    float height,
    @AngleDegreesFloat float rotationDegrees
)

Constructs an ImmutableParallelogram with a given center, width, height and rotationDegrees.

static final @NonNull ImmutableParallelogram
fromCenterDimensionsRotationInDegreesAndSkew(
    @NonNull ImmutableVec center,
    @FloatRange(from = 0.0) float width,
    float height,
    @AngleDegreesFloat float rotationDegrees,
    float skew
)

Constructs an ImmutableParallelogram with a given center, width, height, rotationDegrees and skew.

static final @NonNull ImmutableParallelogram
fromSegmentAndPadding(@NonNull Segment segment, float padding)

Constructs an ImmutableParallelogram that is aligned with the segment and whose bounds are padding units away from the segment and whose skew is zero.

@NonNull ImmutableVec
float

The height of the Parallelogram.

@FloatRange(from = 0.0, to = 360.0, toInclusive = false) float

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.

float

The horizontal displacement between the two horizontal edges of the Parallelogram pre-rotation, as a multiple of the height.

@FloatRange(from = 0.0) float

The width of the Parallelogram.

int
@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 skew.

Public methods

equals

public boolean equals(Object other)

fromCenterAndDimensions

Added in 1.0.0-alpha07
public static final @NonNull ImmutableParallelogram fromCenterAndDimensions(
    @NonNull ImmutableVec center,
    @FloatRange(from = 0.0) float width,
    float height
)

Constructs an ImmutableParallelogram with a given center, width and height. The resulting Parallelogram has zero rotationDegrees 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.

fromCenterDimensionsAndRotationInDegrees

Added in 1.0.0-alpha07
public static final @NonNull ImmutableParallelogram fromCenterDimensionsAndRotationInDegrees(
    @NonNull ImmutableVec center,
    @FloatRange(from = 0.0) float width,
    float height,
    @AngleDegreesFloat float rotationDegrees
)

Constructs an ImmutableParallelogram with a given center, width, height and rotationDegrees. The resulting Parallelogram has zero skew. If the width is less than zero or if the rotationDegrees is not in the range [0, 360), the Parallelogram will be normalized.

See the corresponding fields on Parallelogram for details about these parameters.

fromCenterDimensionsRotationInDegreesAndSkew

Added in 1.0.0-alpha07
public static final @NonNull ImmutableParallelogram fromCenterDimensionsRotationInDegreesAndSkew(
    @NonNull ImmutableVec center,
    @FloatRange(from = 0.0) float width,
    float height,
    @AngleDegreesFloat float rotationDegrees,
    float skew
)

Constructs an ImmutableParallelogram with a given center, width, height, rotationDegrees and skew. If the width is less than zero or if the rotationDegrees is not in the range [0, 360), the Parallelogram will be normalized.

See the corresponding fields on Parallelogram for details about these parameters.

fromSegmentAndPadding

Added in 1.0.0-alpha07
public static final @NonNull ImmutableParallelogram fromSegmentAndPadding(@NonNull Segment segment, float padding)

Constructs an ImmutableParallelogram that is aligned with the segment and whose bounds are padding units away from the segment and whose skew is zero. This makes it a rectangle, that is axis-aligned only if segment is axis-aligned.

getCenter

public @NonNull ImmutableVec getCenter()

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) 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).

hashCode

public int hashCode()

toString

public @NonNull String toString()