ImmutableParallelogram



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

Summary

Public companion functions

ImmutableParallelogram
fromCenterAndDimensions(
    center: ImmutableVec,
    width: @FloatRange(from = 0.0) Float,
    height: Float
)

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

android
ImmutableParallelogram
fromCenterDimensionsAndRotation(
    center: ImmutableVec,
    width: @FloatRange(from = 0.0) Float,
    height: Float,
    rotation: @AngleRadiansFloat Float
)

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

android
ImmutableParallelogram
fromCenterDimensionsRotationAndShear(
    center: ImmutableVec,
    width: @FloatRange(from = 0.0) Float,
    height: Float,
    rotation: @AngleRadiansFloat Float,
    shearFactor: Float
)

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

android
ImmutableParallelogram
fromSegmentAndPadding(segment: Segment, padding: Float)

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

android

Public functions

open operator Boolean
equals(other: Any?)
android
open Int
android
open String
android

Public properties

open ImmutableVec
android
open 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.

android
open Float
android
open 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).

android
open Float

A Parallelogram may not have a negative width.

android

Inherited functions

From androidx.ink.geometry.Parallelogram
ImmutableBox

Returns the minimum bounding box containing the Parallelogram.

android
MutableBox

Returns the minimum bounding box containing the Parallelogram.

android
List<ImmutableVec>

Returns a list containing the 4 corners of the Parallelogram.

android
Unit
computeCorners(
    outCorner1: MutableVec,
    outCorner2: MutableVec,
    outCorner3: MutableVec,
    outCorner4: MutableVec
)

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

android
List<ImmutableVec>

Returns the semi axes of this Parallelogram.

android
Unit
computeSemiAxes(outAxis1: MutableVec, outAxis2: MutableVec)

Fills the MutableVecs with the semi axes of this Parallelogram.

android
Float

Returns the signed area of the Parallelogram.

android
operator Boolean

Returns whether the given point is contained within the Box.

android
Boolean
isAlmostEqual(other: Parallelogram, tolerance: @FloatRange(from = 0.0) Float)

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.

android

Public companion functions

fromCenterAndDimensions

fun fromCenterAndDimensions(
    center: ImmutableVec,
    width: @FloatRange(from = 0.0) Float,
    height: Float
): ImmutableParallelogram

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

fun fromCenterDimensionsAndRotation(
    center: ImmutableVec,
    width: @FloatRange(from = 0.0) Float,
    height: Float,
    rotation: @AngleRadiansFloat Float
): ImmutableParallelogram

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

fun fromCenterDimensionsRotationAndShear(
    center: ImmutableVec,
    width: @FloatRange(from = 0.0) Float,
    height: Float,
    rotation: @AngleRadiansFloat Float,
    shearFactor: Float
): ImmutableParallelogram

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

fun fromSegmentAndPadding(segment: Segment, padding: Float): ImmutableParallelogram

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.

Public functions

equals

open operator fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

toString

open fun toString(): String

Public properties

center

open val centerImmutableVec

height

open val heightFloat

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.

rotation

open val rotationFloat

shearFactor

open val shearFactorFloat

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

width

open val widthFloat

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