Click or drag to resize

Motion1<T> and Motion2<T, TDerivative>

Motion1<T> and Motion2<T, TDerivative> are fundamental types used throughout DME Component Libraries. This topic will provide an overview of these types and how they work.

Motion Types

Motion1<T> holds a coordinate value and zero or more derivatives. For example, a Motion1<Cartesian> is typically used to represent translational motion and holds a Cartesian position vector plus an optional Cartesian velocity vector, Cartesian acceleration vector, etc.

Motion2<T, TDerivative> also holds a value and zero or more derivatives, but in this case the coordinate value and the derivatives are represented using different types. A common example of this is a Motion2<UnitQuaternion, Cartesian>, which is typically used to represent rotational motion and holds a UnitQuaternion rotation plus an optional Cartesian rotational velocity vector, Cartesian rotational acceleration vector, etc.

You can obtain the coordinate value of a Motion1<T> or Motion2<T, TDerivative> instance by accessing the Value (get) property. For example:

Java
Motion1<Cartesian> translationalMotion = anyOldFunction1();
Cartesian position = translationalMotion.getValue();

Motion2<UnitQuaternion, Cartesian> rotationalMotion = anyOldFunction2();
UnitQuaternion rotation = rotationalMotion.getValue();

Similarly, you can access the first and second derivatives:

Java
Motion1<Cartesian> translationalMotion = anyOldFunction1();
Cartesian velocity = translationalMotion.getFirstDerivative();
Cartesian acceleration = translationalMotion.getSecondDerivative();

Motion2<UnitQuaternion, Cartesian> rotationalMotion = anyOldFunction2();
Cartesian rotationalVelocity = rotationalMotion.getFirstDerivative();
Cartesian rotationalAcceleration = rotationalMotion.getSecondDerivative();

You can access higher-order derivatives by using Further derivatives can be accessed using the get method.

Java
Motion1<Cartesian> translationalMotion = anyOldFunction1();
Cartesian jerk = translationalMotion.get(3);

Motion2<UnitQuaternion, Cartesian> rotationalMotion = anyOldFunction2();
Cartesian rotationalJerk = rotationalMotion.get(3);

If an instance does not have a first, second, or higher-order derivative, it will throw an ArgumentOutOfRangeException when you attempt to access that derivative. You can determine the highest-order derivative available from a particular motion instance by accessing the Order (get) property.

Methods that return Motion1<T> or Motion2<T, TDerivative> often accept an order parameter. This parameter indicates the highest derivative that the caller of the function would like returned. The order parameter is primarily an optimization which allows the method to avoid wasting time computing higher derivatives if they will not be utilized. An order of 0 indicates that you require only the coordinate value and not any of its derivatives. An order of 1 requests the first derivative in addition to the coordinate value. An order of 2 requests the coordinate value, its first derivative, and its second derivative. An arbitrarily high order can be requested, though not all methods will be able to fulfill all requests.

If a method is not able to provide a requested derivative, an exception or other error will not occur. Instead, the method will simply provide the highest derivative that it is able to provide. It is up to the caller of the method to verify that a required derivative is present in the return value.