Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


TryGetRelativeMatrix2D

Try to get the relative transformation matrix between the two specified transform matrix using the specified transform plane to transform into 2D space, the same as PhysicsMath.GetRelativeMatrix2D but never returning a NaN result. Each matrix is checked first: if its scale on the plane's ignored axis is at or near zero, such as a matrix built from flattened 2D data, that axis is treated as one instead of leaving the matrix singular. Returns false, instead of a matrix with a NaN rotation, when either matrix has too small an in-plane scale to work with, or the relative transform itself is too close to singular to invert cleanly.
Read time 2 minutesLast updated 13 days ago

Definition

  • Type: Method
  • Namespace: Unity.U2D.Physics
  • Assembly: UnityEngine.PhysicsCore2DModule

TryGetRelativeMatrix2D(Matrix4x4, Matrix4x4, TransformPlane, TransformPlaneCustom, Matrix4x4)

Try to get the relative transformation matrix between the two specified transform matrix using the specified transform plane to transform into 2D space, the same as PhysicsMath.GetRelativeMatrix2D but never returning a NaN result. Each matrix is checked first: if its scale on the plane's ignored axis is at or near zero, such as a matrix built from flattened 2D data, that axis is treated as one instead of leaving the matrix singular. Returns false, instead of a matrix with a NaN rotation, when either matrix has too small an in-plane scale to work with, or the relative transform itself is too close to singular to invert cleanly.
public static bool TryGetRelativeMatrix2D(in Matrix4x4 transformFrom, in Matrix4x4 transformTo, PhysicsWorld.TransformPlane transformPlane, in PhysicsWorld.TransformPlaneCustom transformPlaneCustom, out Matrix4x4 relative)

Parameters

transformFrom

The transform used as a reference to transform from.

transformTo

The transform used as a reference to transform to.

transformPlane

The transform plane to use.

transformPlaneCustom

The custom transform plane to use (if required).

relative

The calculated relative transformation matrix, or the identity matrix if this returns false.

Returns

Type

Description

boolWhether a valid relative transformation matrix was calculated.

TryGetRelativeMatrix2D(Matrix4x4, Matrix4x4, PhysicsWorld, Matrix4x4)

Try to get the relative transformation matrix between the two specified transform matrix using the specified world's transform plane, never returning a NaN result.
public static bool TryGetRelativeMatrix2D(in Matrix4x4 transformFrom, in Matrix4x4 transformTo, PhysicsWorld world, out Matrix4x4 relative)

Parameters

transformFrom

The transform used as a reference to transform from.

transformTo

The transform used as a reference to transform to.

The world whose transform plane is used.

relative

The calculated relative transformation matrix, or the identity matrix if this returns false.

Returns

Type

Description

boolWhether a valid relative transformation matrix was calculated.