ImmutableParallelogram



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

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.

Cmn
ImmutableParallelogram
fromCenterDimensionsAndRotationInDegrees(
    center: ImmutableVec,
    width: @FloatRange(from = 0.0) Float,
    height: Float,
    rotationDegrees: @AngleDegreesFloat Float
)

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

Cmn
ImmutableParallelogram
fromCenterDimensionsRotationInDegreesAndSkew(
    center: ImmutableVec,
    width: @FloatRange(from = 0.0) Float,
    height: Float,
    rotationDegrees: @AngleDegreesFloat Float,
    skew: Float
)

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

Cmn
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 skew is zero.

Cmn

Public functions

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

Public properties

open ImmutableVec
Cmn
open Float

The height of the Parallelogram.

Cmn
open 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.

Cmn
open Float

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

Cmn
open Float

The width of the Parallelogram.

Cmn

Inherited functions

From androidx.ink.geometry.Parallelogram
ImmutableBox

Returns the minimum bounding box containing the Parallelogram.

Cmn
MutableBox

Returns the minimum bounding box containing the Parallelogram.

Cmn
List<ImmutableVec>

Returns a list containing the 4 corners of the Parallelogram.

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

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

Cmn
List<ImmutableVec>

Returns the semi axes of this Parallelogram.

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

Fills the MutableVecs with the semi axes of this Parallelogram.

Cmn
Float

Returns the signed area of the Parallelogram.

Cmn
operator Boolean

Returns whether the given point is contained within the Box.

Cmn
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, rotationDegrees, and skew.

Cmn

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

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

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

fun fromCenterDimensionsRotationInDegreesAndSkew(
    center: ImmutableVec,
    width: @FloatRange(from = 0.0) Float,
    height: Float,
    rotationDegrees: @AngleDegreesFloat Float,
    skew: Float
): ImmutableParallelogram

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

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 skew 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

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.

rotationDegrees

open val rotationDegreesFloat

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.

skew

open val skewFloat

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.

width

open val widthFloat

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