Instance Methodmigueldeicaza.swiftgodot 0.45.0SwiftGodot
isEqualApprox(xform:)
Returns true
if this transform and xform
are approximately equal, by running @GlobalScope.is_equal_approx
on each component.
func isEqualApprox(xform: Transform2D) -> Bool
Other members in extension
Type members
init(
) Constructs a default-initialized
Transform2D
set toIDENTITY
.init(from: Transform2D
) Constructs a
Transform2D
as a copy of the givenTransform2D
.init(rotation: Float, position: Vector2
) Constructs the transform from a given angle (in radians) and position.
init(rotation: Float, scale: Vector2, skew: Float, position: Vector2
) Constructs the transform from a given angle (in radians), scale, skew (in radians) and position.
init(xAxis: Vector2, yAxis: Vector2, origin: Vector2
) Constructs the transform from 3
Vector2
values representingx
,y
, and theorigin
(the three column vectors).static let flipX: Transform2D
The
Transform2D
that will flip something along the X axis.static let flipY: Transform2D
The
Transform2D
that will flip something along the Y axis.static var godotType: Variant.GType
static let identity: Transform2D
The identity
Transform2D
with no translation, rotation or scaling applied. When applied to other data structures,IDENTITY
performs no transformation.static func != (lhs: Transform2D, rhs: Transform2D
) -> Bool Returns
true
if the transforms are not equal.static func * (lhs: Transform2D, rhs: Transform2D
) -> Transform2D This operator multiplies all components of the
Transform2D
, including theorigin
vector, which scales it uniformly.static func * (lhs: Transform2D, rhs: Double
) -> Transform2D This operator multiplies all components of the
Transform2D
, including theorigin
vector, which scales it uniformly.static func * (lhs: Transform2D, rhs: Int64
) -> Transform2D This operator multiplies all components of the
Transform2D
, including theorigin
vector, which scales it uniformly.static func * (lhs: Transform2D, rhs: PackedVector2Array
) -> PackedVector2Array This operator multiplies all components of the
Transform2D
, including theorigin
vector, which scales it uniformly.static func * (lhs: Transform2D, rhs: Rect2
) -> Rect2 This operator multiplies all components of the
Transform2D
, including theorigin
vector, which scales it uniformly.static func * (lhs: Transform2D, rhs: Vector2
) -> Vector2 This operator multiplies all components of the
Transform2D
, including theorigin
vector, which scales it uniformly.static func == (lhs: Transform2D, rhs: Transform2D
) -> Bool Returns
true
if the transforms are exactly equal.
Instance members
var origin: Vector2
The origin vector (column 2, the third column). Equivalent to array index
2
. The origin vector represents translation.var x: Vector2
The basis matrix’s X vector (column 0). Equivalent to array index
0
.var y: Vector2
The basis matrix’s Y vector (column 1). Equivalent to array index
1
.subscript(Int64
) -> Vector2 func affineInverse(
) -> Transform2D Returns the inverse of the transform, under the assumption that the basis is invertible (must have non-zero determinant).
func basisXform(v: Vector2
) -> Vector2 Returns a vector transformed (multiplied) by the basis matrix.
func basisXformInv(v: Vector2
) -> Vector2 Returns a vector transformed (multiplied) by the inverse basis matrix, under the assumption that the basis is orthonormal (i.e. rotation/reflection is fine, scaling/skew is not).
func determinant(
) -> Double Returns the determinant of the basis matrix. If the basis is uniformly scaled, then its determinant equals the square of the scale factor.
func getOrigin(
) -> Vector2 Returns the transform’s origin (translation).
func getRotation(
) -> Double Returns the transform’s rotation (in radians).
func getScale(
) -> Vector2 Returns the scale.
func getSkew(
) -> Double Returns the transform’s skew (in radians).
func interpolateWith(xform: Transform2D, weight: Double
) -> Transform2D Returns a transform interpolated between this transform and another by a given
weight
(on the range of 0.0 to 1.0).func inverse(
) -> Transform2D Returns the inverse of the transform, under the assumption that the transformation basis is orthonormal (i.e. rotation/reflection is fine, scaling/skew is not). Use
affineInverse
for non-orthonormal transforms (e.g. with scaling).func isConformal(
) -> Bool Returns
true
if the transform’s basis is conformal, meaning it preserves angles and distance ratios, and may only be composed of rotation and uniform scale. Returnsfalse
if the transform’s basis has non-uniform scale or shear/skew. This can be used to validate if the transform is non-distorted, which is important for physics and other use cases.func isFinite(
) -> Bool Returns
true
if this transform is finite, by calling@GlobalScope.is_finite
on each component.func lookingAt(target: Vector2
) -> Transform2D Returns a copy of the transform rotated such that the rotated X-axis points towards the
target
position.func orthonormalized(
) -> Transform2D Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors (scale of 1 or -1).
func rotated(angle: Double
) -> Transform2D Returns a copy of the transform rotated by the given
angle
(in radians).func rotatedLocal(angle: Double
) -> Transform2D Returns a copy of the transform rotated by the given
angle
(in radians).func scaled(scale: Vector2
) -> Transform2D Returns a copy of the transform scaled by the given
scale
factor.func scaledLocal(scale: Vector2
) -> Transform2D Returns a copy of the transform scaled by the given
scale
factor.func translated(offset: Vector2
) -> Transform2D Returns a copy of the transform translated by the given
offset
.func translatedLocal(offset: Vector2
) -> Transform2D Returns a copy of the transform translated by the given
offset
.