OrientationSensor

Last Updated On 2021-07-16

Version 2MinSDK 7Tutorial Video

Non-visible component providing information about the device's physical orientation in three dimensions:

  • Roll: 0 degrees when the device is level, increases to 90 degrees as the device is tilted up on its left side, and decreases to -90 degrees when the device is tilted up on its right side.
  • Pitch: 0 degrees when the device is level, up to 90 degrees as the device is tilted so its top is pointing down, up to 180 degrees as it gets turned over. Similarly, as the device is tilted so its bottom points down, pitch decreases to -90 degrees, then further decreases to -180 degrees as it gets turned all the way over.
  • Azimuth: 0 degrees when the top of the device is pointing north, 90 degrees when it is pointing east, 180 degrees when it is pointing south, 270 degrees when it is pointing west, etc.
These measurements assume that the device itself is not moving.


Properties

You can set the below properties in the UI part of the builder.

  • Enabled - it's a boolean value which is set to true by default.

Block Properties

You can set the below blocks properties in the blocks section of the builder.

Angle

Returns an angle that tells the direction in which the device is tiled. That is, it tells the direction of the force that would be felt by a ball rolling on the surface of the device.


Available

Indicates whether the orientation sensor is present on the device.


Azimuth

Returns the azimuth angle of the device. To return meaningful values the sensor must be enabled.


Enabled

Specifies whether the orientation sensor is enabled.


Magnitude

Returns a number between 0 and 1 indicating how much the device is tilted. It gives the magnitude of the force that would be felt by a ball rolling on the surface of the device. For the angle of tilt, use


Pitch

Returns the pitch angle of the device. To return meaningful values the sensor must be enabled.


Roll

Returns the roll angle of the device. To return meaningful values the sensor must be enabled.



Events

You can set the below event blocks in the blocks section of the builder.

OrientationChanged

Called when the orientation has changed.