Curve Class

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Stores an arbitrary collection of 2D CurveKey points, and provides methods for evaluating features of the curve they define.

Inheritance Hierarchy

System.Object
  Microsoft.Xna.Framework.Curve

Namespace:  Microsoft.Xna.Framework
Assembly:  Microsoft.Xna.Framework.Math (in Microsoft.Xna.Framework.Math.dll)

Syntax

'Declaration
Public Class Curve
public class Curve

The Curve type exposes the following members.

Constructors

  Name Description
Public method Curve Initializes a new instance of Curve.

Top

Properties

  Name Description
Public property IsConstant Gets a value indicating whether the curve is constant.
Public property Keys The points that make up the curve.
Public property PostLoop Specifies how to handle weighting values that are greater than the last control point in the curve.
Public property PreLoop Specifies how to handle weighting values that are less than the first control point in the curve.

Top

Methods

  Name Description
Public method Clone Creates a copy of the Curve.
Public method ComputeTangent(Int32, CurveTangent) Computes both the TangentIn and the TangentOut for a CurveKey specified by its index.
Public method ComputeTangent(Int32, CurveTangent, CurveTangent) Computes a specified type of TangentIn and a specified type of TangentOut for a given CurveKey.
Public method ComputeTangents(CurveTangent) Computes all tangents for all CurveKeys in this Curve, using a specified tangent type for both TangentIn and TangentOut.
Public method ComputeTangents(CurveTangent, CurveTangent) Computes all tangents for all CurveKeys in this Curve, using different tangent types for TangentOut and TangentIn.
Public method Evaluate Finds the value at a position on the Curve.

Top

Remarks

The Curve class describes how two float values vary with respect to each other even when you cannot easily define their relationship by a formula. Instead, the relationship is defined by an ordered set of value pairs that exemplify it.

You specify a Curve by adding a sequence of CurveKey objects to its Keys collection, each of which must contain at minimum a Position greater than that of the preceding CurveKey, and a corresponding Value. In practice, the Position is almost always used to represent a point in time, while the Value property generally represents a coordinate value corresponding to that point in time.

To represent a time path in two or three dimensions, you can define two or three Curve objects, each of which corresponds to a different spatial axis. Coordinates of a given time's point on the resulting 2D or 3D curve are calculated very efficiently.

The Curve.Evaluate method returns a (coordinate) value corresponding to a (time) position that you specify. The position doesn't have to be contained in any of the CurveKey points, because Curve interpolates between points depending on the CurveKey characteristics you have defined.

Not only is Curve useful for controlling animation and spatial motion, it can also be used anywhere you want to define a response that changes over time. For example, if you are using a button to accelerate a car in your game, you might want to define a complex velocity curve that varies with how long the button is held down to simulate gear shifts.

A CurveKey point need not always be part of a smoothly varying curve; you can also set a CurveKey to represent a step or sharp inflection point.

Version Information

Silverlight

Supported in: 5

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.