/// <summary> /// Creates a new <c>JointValues</c> instance that contains only values for joints of the given <c>JointSet</c>. /// The <paramref name="subset"/> parameter defines the new order of the joints in the resulting <c>JointValues</c> object. /// </summary> /// <param name="subset">A <c>JointSet</c> with a subset of the joints.</param> /// <returns>A new instance of <c>JointValues</c>.</returns> /// <exception cref="ArgumentException">Thrown when the given <paramref name="subset"/> is not a subset of the names the <c>JointSet</c>.</exception> public JointValues Select(JointSet subset) { if (!subset.IsSubset(this.JointSet)) { throw new ArgumentException("The given joint set needs to be a subset of the current joint set.", nameof(subset)); } return(new JointValues(subset, subset.Select(x => this[x]))); }
/// <summary> /// Reorders the values to match the order of the given <c>JointSet</c>. /// </summary> /// <param name="newOrder">A <c>JointSet</c> with the same name of joints, but in a different order than the current <c>JointSet</c>.</param> /// <returns>A new instance of <c>JointValues</c>.</returns> /// <exception cref="ArgumentException">Thrown when the given <paramref name="newOrder"/> is not a permutation of the names in the <c>JointSet</c>.</exception> public JointValues Reorder(JointSet newOrder) { if (!newOrder.IsSimilar(this.JointSet)) { throw new ArgumentException("The given joint set must be similar to the current joint set.", nameof(newOrder)); } return(new JointValues(newOrder, newOrder.Select(x => this[x]))); }