# PhysicsMath

> A set of mathematical operations that are useful for physics. These operations do not form a fully comprehensive mathematics library, they simply provide operations that are usually required when interacting with physics.

## Definition

* **Type:** Struct
* **Namespace:** [Unity.U2D.Physics](/engine/6000.6/script-reference/unity/u2d/physics.md)
* **Assembly:** UnityEngine.PhysicsCore2DModule

```csharp
public readonly struct PhysicsMath
```

## Static Properties

| Property                                                                    | Description                                                                                                  |
| --------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| [PI](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/pi.md)   | Get the value of PI used internally by the physics system. Using this will help with determinism.            |
| [TAU](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/tau.md) | Get the value of tau (2 \* PI) used internally by the physics system. Using this will help with determinism. |

## Static Methods

| Method                                                                                                                      | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| --------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [AngularVelocityToQuaternion](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/angularvelocitytoquaternion.md) | Calculate a [Quaternion](/engine/6000.6/script-reference/unityengine/quaternion.md) given a 2D angular velocity and a time to integrate over using the selected transform plane. If [PhysicsWorld.TransformPlane.Custom](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/custom.md) is used,  [PhysicsWorld.TransformPlane.XY](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/xy.md) will be used instead which may not provide the correct results.                                                                                                                                                                        |
| [Atan2](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/atan2.md)                                             | Calculate the arc-tangent i.e. the angle of the provided slope y/x. This operates as deterministically as possible across platforms.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| [CosSin](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/cossin.md)                                           | Calculate both the Cosine and Sine of the specified angle.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| [GetRelativeMatrix](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/getrelativematrix.md)                     | Get the relative transformation matrix between the two specified transforms using the specified transform plane. If [PhysicsWorld.TransformPlane.Custom](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/custom.md) is used, [PhysicsWorld.TransformPlane.XY](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/xy.md) will be used instead which may not provide the correct results.                                                                                                                                                                                                                                         |
| [GetRelativeMatrix2D](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/getrelativematrix2d.md)                 | Get the relative transformation matrix between the two specified transform matrix using the specified transform plane to transform into 2D space i.e. XY position and Z rotation.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [GetRelativePose2D](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/getrelativepose2d.md)                     | Get the relative transformation pose (translation, rotation and scale) between the two specified transform matrix using the specified transform plane to transform into 2D space.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [GetRotationAxes](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/getrotationaxes.md)                         | Get the used rotation axes, given the specified transform plane. This is the inverse of [PhysicsMath.GetRotationIgnoredAxes](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/getrotationignoredaxes.md). If [PhysicsWorld.TransformPlane.Custom](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/custom.md) is used,  [PhysicsWorld.TransformPlane.XY](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/xy.md) will be used instead which may not provide the correct results.                                                                                                                                  |
| [GetRotationIgnoredAxes](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/getrotationignoredaxes.md)           | Get the ignored rotation axes, given the specified transform plane. This is the inverse of [PhysicsMath.GetRotationAxes](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/getrotationaxes.md). If [PhysicsWorld.TransformPlane.Custom](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/custom.md) is used,  [PhysicsWorld.TransformPlane.XY](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/xy.md) will be used instead which may not provide the correct results.                                                                                                                                             |
| [GetTranslationAxes](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/gettranslationaxes.md)                   | Get the used translation axes, given the specified transform plane. This is the inverse of [PhysicsMath.GetTranslationIgnoredAxes](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/gettranslationignoredaxes.md). If [PhysicsWorld.TransformPlane.Custom](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/custom.md) is used,  [PhysicsWorld.TransformPlane.XY](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/xy.md) will be used instead which may not provide the correct results.                                                                                                                         |
| [GetTranslationIgnoredAxes](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/gettranslationignoredaxes.md)     | Get the ignored translation axes, given the specified transform plane. This is the inverse of [PhysicsMath.GetTranslationAxes](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/gettranslationaxes.md). If [PhysicsWorld.TransformPlane.Custom](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/custom.md) is used,  [PhysicsWorld.TransformPlane.XY](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/xy.md) will be used instead which may not provide the correct results.                                                                                                                                    |
| [GetTranslationIgnoredAxis](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/gettranslationignoredaxis.md)     | Get the ignored translation axis, given the specified transform plane. If [PhysicsWorld.TransformPlane.Custom](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/custom.md) is used,  [PhysicsWorld.TransformPlane.XY](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/xy.md) will be used instead which may not provide the correct results.                                                                                                                                                                                                                                                                                  |
| [MaxAbsComponent](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/maxabscomponent.md)                         | Get the maximum absolute value component from the specified vector.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| [MinAbsComponent](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/minabscomponent.md)                         | Get the minimum absolute value component from the specified vector.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| [SetTransformFast2D](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/settransformfast2d.md)                   | Set the Transform position and rotation using the specified [PhysicsWorld.TransformPlane](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane.md). For position, only two axis will be updated with the others remaining unchanged. For rotation, only a single rotation axis will be changed with the others set to zero.                                                                                                                                                                                                                                                                                                                                     |
| [SetTransformSlow3D](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/settransformslow3d.md)                   | Set the Transform position and rotation using the specified [PhysicsWorld.TransformPlane](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane.md). For position, only two axis will be updated with the others remaining unchanged. For rotation, only a single rotation axis will be changed with the others remaining unchanged.                                                                                                                                                                                                                                                                                                                             |
| [SpringDamper](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/springdamper.md)                               | Calculate a one-dimensional mass-spring-damper simulation which drives towards a zero translation. You can then compute the new position using: "translation += newSpeed \* deltaTime;"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [Swizzle](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/swizzle.md)                                         | Transform a Matrix position (with perspective divide) into a Matrix position using the selected transform plane. If [PhysicsWorld.TransformPlane.Custom](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/custom.md) is used,  [PhysicsWorld.TransformPlane.XY](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/xy.md) will be used instead which may not provide the correct results.                                                                                                                                                                                                                                        |
| [ToDegrees](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/todegrees.md)                                     | Convert radians to degrees. This operates as deterministically as possible across platforms. See [PhysicsMath.ToRadians](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/toradians.md).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [ToPhysicsTransform](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/tophysicstransform.md)                   | Transform a 3D [Transform](/engine/6000.6/script-reference/unityengine/transform.md) position and rotation to a 2D [PhysicsTransform](/engine/6000.6/script-reference/unity/u2d/physics/physicstransform.md). Scale is not part of a [PhysicsTransform](/engine/6000.6/script-reference/unity/u2d/physics/physicstransform.md) therefore it is ignored. If [PhysicsWorld.TransformPlane.Custom](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/custom.md) is used,  [PhysicsWorld.TransformPlane.XY](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/xy.md) will be used instead which may not provide the correct results. |
| [ToPosition2D](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/toposition2d.md)                               | Transform a 3D position into a 2D position using the selected transform plane. If TransformPlane.Custom is used then [PhysicsWorld.TransformPlane.XY](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/xy.md) is used.                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| [ToPosition3D](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/toposition3d.md)                               | Transform a 2D position into a 3D position using the selected transform plane. If [PhysicsWorld.TransformPlane.Custom](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/custom.md) is used,  [PhysicsWorld.TransformPlane.XY](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/xy.md) will be used instead which may not provide the correct results.                                                                                                                                                                                                                                                                          |
| [ToRadians](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/toradians.md)                                     | Convert degrees to radians. This operates as deterministically as possible across platforms. See [PhysicsMath.ToDegrees](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/todegrees.md).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [ToRotation2D](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/torotation2d.md)                               | Transform a 3D rotation into a 2D angle using the selected transform plane. If TransformPlane.Custom is used then [PhysicsWorld.TransformPlane.XY](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/xy.md) is used.                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| [ToRotationFast3D](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/torotationfast3d.md)                       | Transform a 2D angle into a 3D rotation using the selected transform plane (Fast). The transformation is fast because the rotation is simplified by the fact that only a single axis of rotation is handled. All other axis rotations are reset to zero. If [PhysicsWorld.TransformPlane.Custom](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/custom.md) is used,  [PhysicsWorld.TransformPlane.XY](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/xy.md) will be used instead which may not provide the correct results.                                                                                                |
| [ToRotationSlow3D](/engine/6000.6/script-reference/unity/u2d/physics/physicsmath/torotationslow3d.md)                       | Transform a 2D angle into a 3D rotation using the selected transform plane (Slow). The transformation is slower because the rotation is more complex due to the fact that changing a single axis of rotation requires it to not affect any other axis rotations. If [PhysicsWorld.TransformPlane.Custom](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/custom.md) is used,  [PhysicsWorld.TransformPlane.XY](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld/transformplane/xy.md) will be used instead which may not provide the correct results.                                                                                        |
