ImmutableParallelogram


public final class ImmutableParallelogram extends Parallelogram


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

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
fromCenterDimensionsAndRotation(
    @NonNull ImmutableVec center,
    @FloatRange(from = 0.0) float width,
    float height,
    @AngleRadiansFloat float rotation
)

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

static final @NonNull ImmutableParallelogram
fromCenterDimensionsRotationAndShear(
    @NonNull ImmutableVec center,
    @FloatRange(from = 0.0) float width,
    float height,
    @AngleRadiansFloat float rotation,
    float shearFactor
)

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

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 shearFactor is zero.

@NonNull ImmutableVec
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.

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

float

A Parallelogram may not have a negative width.

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

Public methods

equals

public boolean equals(Object other)

fromCenterAndDimensions

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

fromCenterDimensionsAndRotation

Added in 1.0.0-alpha06
public static final @NonNull ImmutableParallelogram fromCenterDimensionsAndRotation(
    @NonNull ImmutableVec center,
    @FloatRange(from = 0.0) float width,
    float height,
    @AngleRadiansFloat float rotation
)

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

fromCenterDimensionsRotationAndShear

Added in 1.0.0-alpha06
public static final @NonNull ImmutableParallelogram fromCenterDimensionsRotationAndShear(
    @NonNull ImmutableVec center,
    @FloatRange(from = 0.0) float width,
    float height,
    @AngleRadiansFloat float rotation,
    float shearFactor
)

Constructs an ImmutableParallelogram with 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π), the Parallelogram will be normalized.

fromSegmentAndPadding

Added in 1.0.0-alpha06
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 shearFactor 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()

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

toString

public @NonNull String toString()