/** * Sets all the components of this spatial inertia to {@link Double#NaN}. */ @Override default void setToNaN() { getMomentOfInertia().setToNaN(); setMass(Double.NaN); getCenterOfMassOffset().setToNaN(); }
/** * Sets all the components of this spatial inertia to zero. */ @Override default void setToZero() { getMomentOfInertia().setToZero(); setMass(0.0); getCenterOfMassOffset().setToZero(); }
/** * Sets this spatial inertia to {@code other}. * * @param other the other spatial inertia to copy values from. Not modified. * @throws ReferenceFrameMismatchException if {@code other} does not have the same frames as * {@code this}. */ default void set(SpatialInertiaReadOnly other) { checkReferenceFrameMatch(other); getMomentOfInertia().set(other.getMomentOfInertia()); setMass(other.getMass()); getCenterOfMassOffset().set(other.getCenterOfMassOffset()); }
/** * Adds the other spatial inertia to this. * * @param other the other inertia to add. Not modified. * @throws ReferenceFrameMismatchException if {@code other} is not expressed in the same reference * frame as {@code this}. */ default void add(SpatialInertiaReadOnly other) { other.checkReferenceFrameMatch(getReferenceFrame()); getMomentOfInertia().add(other.getMomentOfInertia()); getCenterOfMassOffset().scale(getMass()); getCenterOfMassOffset().scaleAdd(other.getMass(), other.getCenterOfMassOffset(), getCenterOfMassOffset()); setMass(getMass() + other.getMass()); if (Math.abs(getMass()) >= 1.0e-7) getCenterOfMassOffset().scale(1.0 / getMass()); } }