Skip to content
This repository was archived by the owner on May 15, 2024. It is now read-only.

Proposal for an Orientation Sensor #245

Closed
charlespetzold opened this issue May 11, 2018 · 3 comments
Closed

Proposal for an Orientation Sensor #245

charlespetzold opened this issue May 11, 2018 · 3 comments
Labels
proposal Proposed feature or enhancement. ready-to-implement Feature approved, specs written, and ready to implement.

Comments

@charlespetzold
Copy link
Contributor

An orientation sensor combines data from the accelerometer and magnetometer to provide a complete orientation of the device in 3D space. This information is vital for VR and AR applications. One common usage is a "night sky" astronomy program.

On iOS, this information is available from the Device Motion subset of the CMMotionManager API.

On Android, it's the SensorType.RotationVector subset of the SensorManager API.

On UWP, it's the OrientationSensor class.

I think OrientationSensor is probably the best name for the class in Xamarin.Essentials, and distinguishes it from an Orientation API that might only provide portrait and landscape orientation.

A description of an orientation in 3D space is sometimes given in Euler angles; in roll, pitch, and yaw; or as a 3D rotation matrix. However, all three platforms provide a quaternion, and this is probably the simplest for the Xamarin.Essentials API. (System.Numerics includes a Quaternion type that can be used for this.)

In fact, it is extremely easy to create OrientationSensor classes using the Accelerometer classes as a guide. (In fact, I've already done it.) Rather than passing three numbers to the shared partial class, you pass four, and then set an Orientation property of type Quaternion.

From what I can determine, the three platforms are consistent in the relationship of the quaternion to the orientation of the device (as long as you hold a UWP tablet in portrait mode). So in that sense, it's simpler than the Accelerometer!

Although the quaternion might be frightful to some people, it's convertible into other types. For example, the System.Numerics.Matrix4x4 class has a CreateFromQuaternion method. Plus, we can write documentation that describe how to use it. (I wrote several orientation-sensor samples for MSDN Magazine several years ago, and I'd love to port them to Forms + Essentials.)

@charlespetzold charlespetzold added the proposal Proposed feature or enhancement. label May 11, 2018
@jamesmontemagno jamesmontemagno added the ready-to-implement Feature approved, specs written, and ready to implement. label May 11, 2018
@mattleibow
Copy link
Contributor

This sounds like a nice API, and I feel a game coming on...

@charlespetzold
Copy link
Contributor Author

Let me know if you want a PR with the implementation!

@mattleibow
Copy link
Contributor

Create a PR and we will start commenting!

jamesmontemagno pushed a commit that referenced this issue May 14, 2018
* Add Orientation Sensor

* Add Orientation Sensor

* Remove .csproj clutter

* "orientationsensor" --> "orientation sensor" or just "orientation"
jamesmontemagno added a commit that referenced this issue Jun 21, 2018
* GH-221: Add iOS SecAccessible properties (#223)

* Address #221, use AfterFirstUnlockThisDeviceOnly to match other platforms. Although allow a platform specific override to set accessible state.

* Add tests

* Added iOS specific prop to set SecAccessible

* Default to AfterFirstUnlock on iOS SecureStorage

* A few fixes for the release. (#228)

* Setting the correct flags for Chrome Tabs. Fixes #225

* Make sure that there is data to decrypt before starting. Fixes #226

* Fixes for TTS. Fixes #227

* A bit of the fixes for emails on iOS. Relates to #224

* Update the email bit for iOS #224

* Cleaning up the code #224

* Make sure to set the email properties. Fixes #229

* Update SDK Extras

This fixes a lot of references that were required on android that aren't.

* Update Readme with Installation information. (#237)

* Update Readme with Installation information.

* Update README.md

* Update README.md

* Adding the initial work to get Tizen started. #23

* Revert "Adding the initial work to get Tizen started. #23"

This reverts commit 58b6041.

* Update the docs with the latest APIs (#233)

Add docs for SecAccessible

* GH-245: Add Orientation Sensor (#249)

* Add Orientation Sensor

* Add Orientation Sensor

* Remove .csproj clutter

* "orientationsensor" --> "orientation sensor" or just "orientation"

* GH-192: Added DateTime to Preferences (#232)

* Added DateTime to preferences. Fixes #192
 - also properly using overloads

* Added some unit tests

* Added the docs for the new Preferences APIs

* Update Readme with Device Display Information

Added link to Current Features for Device Display Information

* Fixes #258 and Fixes #255 (#259)

* Fixes #258
* put vectors nuget everywhere.
* NuGet is broken - https://developercommunity.visualstudio.com/content/problem/232996/warning-nu1603-runtimenativesystemiocompression-41.html
* The NuGet doesn't add the assembly references from the GAC
* We need to use a later version of the iOS SDK

* Fix typo (#274)

* Fix up null checks when getting lask known location.

* Additional Null checks

* GH-240 Add IsMainThread detection API (#277)

* Add IsMainThread detection API

* Add platform tests for main thread

* Update docs and add more platform tests

* iOS secure storage simulator tests (#247) (#278)

* iOS secure storage simulator tests (#247)

* Remove line that skips test on virtual devices

* Adding keychain-access-groups in Entitlements.plist

* Setting CodeSign entitlements for Debug configuration

* Making same entitlement.plist changes for iOS sample

* Removing specific code sign key

* Removing physical device trait for iOS SecureStorageTests

* Update DeviceTests.iOS.csproj

* Update Samples.iOS.csproj

* Add configs for codesign on release

* Fixes #181 Allowing setting of calibration for heading. (#282)

* GH-254 Update Support Packages, Forms, and Reference Vectors (#279)

* Update Support Packages, Forms, and Reference Vectors

* Bump targetsdk

* Fix android build :)

* Fix build
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
proposal Proposed feature or enhancement. ready-to-implement Feature approved, specs written, and ready to implement.
Projects
None yet
Development

No branches or pull requests

3 participants