---
title: "calculateRotation"
description: "Returns the rotation, in degrees, of the pointers between the
[PointerInputChange.previousPosition] and [PointerInputChange.position] states. Only the pointers
that are down in both previous and current states are considered.

Example Usage:"
type: "function"
---

<div class='type'>Function</div>


<a id='references'></a>
<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun PointerEvent.calculateRotation(): Float
```


Returns the rotation, in degrees, of the pointers between the
`PointerInputChange.previousPosition` and `PointerInputChange.position` states. Only the pointers
that are down in both previous and current states are considered.

Example Usage:



## Code Examples
### CalculateRotation
```kotlin
@Composable
fun CalculateRotation() {
    var angle by remember { mutableStateOf(0f) }
    Box(
        Modifier.graphicsLayer(rotationZ = angle)
            .background(Color.Blue)
            .pointerInput(Unit) {
                awaitEachGesture {
                    awaitFirstDown()
                    do {
                        val event = awaitPointerEvent()
                        val rotation = event.calculateRotation()
                        angle += rotation
                    } while (event.changes.any { it.pressed })
                }
            }
            .fillMaxSize()
    )
}
```

