Frage

Gibt es eine Möglichkeit, eine relative Drehung aus der Kernbewegung zu erhalten?

was ich brauche ist: wie viel es in einer Achse gedreht und welche Richtung (+ Zeichen= gegen den Uhrzeigersinn, -= im Uhrzeigersinn, entsprechend der rechten Regel).

Ich habe die Immobilienrotation gefunden, aber ich bin jetzt sicher, wie ich den Winkel daraus extrahieren würde, da dies mir den Radiant pro Sekunde gibt.

Ich habe in den letzten Tagen alle Arten von Sachen gemacht, aber nichts gibt mir stabile Werte.Ich habe versucht, eine zeitgesteuerte Probe von Kernbewegungsdaten mit einem NSTImer mit einem NSTIMER mitzunehmen und den Unterschied zwischen zwei Proben zu berechnen, also hätte ich, wie viel es seit der letzten Probe gedreht hat, aber von Zeiten zu Zeiten gibt es verrückte Zahlen wie 13600 GradAuch wenn das iPhone auf dem Tisch ruht.

Alle Gedanken darüber, wie dies erreicht werden kann?

danke

War es hilfreich?

Lösung

There is indeed. You can get what you're looking for by drilling down into the properties of CMMotionManager, through CMDeviceMotion and finally to CMAttitude. The attitude of the device is defined as:

the orientation of a body relative to a given frame of reference.

In the case of DeviceMotion's CMAttitude, that frame of reference is established by the framework when starting device motion updates. From that point in time on, the attitude of the device is reported relative to that reference frame (not relative to the previous frame).

The CMAttitude class provides some handy built in functionality to convert a CMAttitude to a form that is actually useful for something, like Euler Angles, a rotation matrix, or a quaternion. You sound like you're looking for the Euler Angle representation (Pitch, Yaw, Roll).

Andere Tipps

The answer provided above isn't quite accurate, though it's probably sufficient to answer this question. Core Motion tries to determine the device's absolute attitude at all times, meaning that the definition of the axes can vary depending on the device's orientation. For example, if the device is face-up, then pitch up/down is a rotation about the y-axis, but if the device is in landscape orientation, then pitch is a rotation about the z-axis (perpendicular to the plane of the screen). This is somewhat helpful if your application will only be used in one orientation, or you want a delta like the question asked for, but makes it excessively complicated if you want to know absolute orientation.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top