QuaternionKeyFrameAnimation QuaternionKeyFrameAnimation QuaternionKeyFrameAnimation QuaternionKeyFrameAnimation Class

Definition

A time-based animation that targets the Orientation property with one or more key frames.

The QuaternionKeyFrameAnimation class is one of the supported types of KeyFrameAnimation s that is used to animate the Orientation property on a Visual. Quaternions are a useful and sometimes simpler way to think about rotations – Quaternions take the shortest path between angles and avoid issues like Gimbal Lock that rotation angle/axis and rotation matrices run into. A Quaternion is made up of two components: a scalar and vector part.

public : sealed class QuaternionKeyFrameAnimation : KeyFrameAnimation, IQuaternionKeyFrameAnimationpublic sealed class QuaternionKeyFrameAnimation : KeyFrameAnimation, IQuaternionKeyFrameAnimationPublic NotInheritable Class QuaternionKeyFrameAnimation Inherits KeyFrameAnimation Implements IQuaternionKeyFrameAnimation// This API is not available in Javascript.
Inheritance
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10586.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v2)

Inherited Members

Inherited methods

Inherited properties

Examples


void QuaternionAnimation(SpriteVisual visual)
{
  // Create the QuaternionKeyFrameAnimation
  var quaternionKFA = _compositor.CreateQuaternionKeyFrameAnimation();

  // Create a Quaternion that represents a 45 degree rotation around X Axis
  Quaternion quaternion = new Quaternion(0.380f, 0f, 0.0f, 0.92f);

  // Insert the Quaternion into the KeyFrame
  quaternionKFA.InsertKeyFrame(1.0f, quaternion);
  quaternionKFA.Duration = TimeSpan.FromSeconds(1);

  // Attach to the Orientation property of Visual
  visual.StartAnimation("Orientation", quaternionKFA);
}

Remarks

An animation is associated with an object's property by calling CompositionObject::StartAnimation and specifying the property name and the animation. See the remarks section of CompositionObject::StartAnimation for a list of animatable properties.

A Quaternion is made up of two distinguishable parts: A vector and scalar component. When using with KeyFrame Animations, the Quaternion can be defined by the notation of System.Numerics of 4 floats or a Vector3 and a scalar. System.Numerics provides constructors for either of these notations.

When translating a rotation into a Quaternion, you can utilize System.Numerics Quaternion helper functions that allow you to create Quaternions out of an Axis/Angle combo, Rotation Matrix or Yaw/Pitch/Roll. In the example above, the same Quaternion could be constructed from the below helper:

Quaternion quaternion = Quaternion.CreateFromAxisAngle(new Vector3(1.0f, 0.0f, 0.0f), 0.78f);

Methods

InsertKeyFrame(Single, Quaternion) InsertKeyFrame(Single, Quaternion) InsertKeyFrame(Single, Quaternion) InsertKeyFrame(Single, Quaternion)

Inserts a key frame.

public : void InsertKeyFrame(float normalizedProgressKey, Quaternion value)public void InsertKeyFrame(Single normalizedProgressKey, Quaternion value)Public Function InsertKeyFrame(normalizedProgressKey As Single, value As Quaternion) As void// This API is not available in Javascript.
Parameters
normalizedProgressKey
float Single Single Single

The time the key frame should occur at, expressed as a percentage of the animation Duration. Allowed value is from 0.0 to 1.0.

value
Quaternion Quaternion Quaternion Quaternion

The value of the key frame.

See Also

InsertKeyFrame(Single, Quaternion, CompositionEasingFunction) InsertKeyFrame(Single, Quaternion, CompositionEasingFunction) InsertKeyFrame(Single, Quaternion, CompositionEasingFunction) InsertKeyFrame(Single, Quaternion, CompositionEasingFunction)

Inserts a key frame with the specified easing function.

public : void InsertKeyFrame(float normalizedProgressKey, Quaternion value, CompositionEasingFunction easingFunction)public void InsertKeyFrame(Single normalizedProgressKey, Quaternion value, CompositionEasingFunction easingFunction)Public Function InsertKeyFrame(normalizedProgressKey As Single, value As Quaternion, easingFunction As CompositionEasingFunction) As void// This API is not available in Javascript.
Parameters
normalizedProgressKey
float Single Single Single

The time the key frame should occur at, expressed as a percentage of the animation Duration. Allowed value is from 0.0 to 1.0.

value
Quaternion Quaternion Quaternion Quaternion

The value of the key frame.

easingFunction
CompositionEasingFunction CompositionEasingFunction CompositionEasingFunction CompositionEasingFunction

The easing function to use to interpolate between key frames.

See Also

See Also