<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreMotion",
  "identifier" : "/documentation/CoreMotion/CMQuaternion",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Core Motion"
    ],
    "preciseIdentifier" : "c:@SA@CMQuaternion"
  },
  "title" : "CMQuaternion"
}
-->

# CMQuaternion

The type for a quaternion representing a measurement of attitude.

```
struct CMQuaternion
```

## Overview

A quaternion offers a way to parameterize attitude. If `q` is an instance of `CMQuaternion`, mathematically it represents the following unit quaternion: `q.x*i + q.y*j + q.z*k + q.w`. A unit quaternion represents a rotation of theta radians about the unit vector `{x,y,z}`, and `{q.x, q.y, q.z, q.w}` satisfies the following:

```objc
q.x = x * sin(theta / 2)
q.y = y * sin(theta / 2)
q.z = z * sin(theta / 2)
q.w = cos(theta / 2)
```

## Topics

### Initializing the Quaternion

[`init()`](/documentation/CoreMotion/CMQuaternion/init())

[`init(x:y:z:w:)`](/documentation/CoreMotion/CMQuaternion/init(x:y:z:w:))

### Getting the Quaternion Values

[`w`](/documentation/CoreMotion/CMQuaternion/w)

The value for the w axis.

[`x`](/documentation/CoreMotion/CMQuaternion/x)

The value for the x axis.

[`y`](/documentation/CoreMotion/CMQuaternion/y)

The value for the y axis.

[`z`](/documentation/CoreMotion/CMQuaternion/z)

The value for the z axis.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)