/** * Sets all the components of this frame tuple to zero and sets the current reference frame to * {@code referenceFrame}. * * @param referenceFrame the new reference frame to be associated with this tuple. */ default void setToZero(ReferenceFrame referenceFrame) { setReferenceFrame(referenceFrame); setToZero(); }
/** * Performs the inverse of the transform to the given {@code tupleOriginal} by the rotation about * the z-axis described by this and stores the result in {@code tupleTransformed}. * * <pre> * tupleTransformed = / cos(-yaw) -sin(-yaw) \ * tupleOriginal * \ sin(-yaw) cos(-yaw) / * </pre> * * @param tupleOriginal the tuple to be transformed. Not modified. * @param tupleTransformed the tuple in which the result is stored. Modified. */ default void transform(Tuple2DReadOnly tupleOriginal, FrameTuple2DBasics tupleTransformed) { tupleTransformed.setToZero(getReferenceFrame()); Orientation2DReadOnly.super.transform(tupleOriginal, tupleTransformed); }
/** * Performs the inverse of the transform to the given {@code tupleOriginal} by the rotation about * the z-axis described by this and stores the result in {@code tupleTransformed}. * * <pre> * tupleTransformed = / cos(-yaw) -sin(-yaw) \ * tupleOriginal * \ sin(-yaw) cos(-yaw) / * </pre> * * @param tupleOriginal the tuple to be transformed. Not modified. * @param tupleTransformed the tuple in which the result is stored. Modified. */ default void inverseTransform(Tuple2DReadOnly tupleOriginal, FrameTuple2DBasics tupleTransformed) { tupleTransformed.setToZero(getReferenceFrame()); Orientation2DReadOnly.super.inverseTransform(tupleOriginal, tupleTransformed); }
/** * Performs the inverse of the transform to the given {@code tupleOriginal} by the rotation about * the z-axis described by this and stores the result in {@code tupleTransformed}. * * <pre> * tupleTransformed = / cos(-yaw) -sin(-yaw) \ * tupleOriginal * \ sin(-yaw) cos(-yaw) / * </pre> * * @param tupleOriginal the tuple to be transformed. Not modified. * @param tupleTransformed the tuple in which the result is stored. Modified. * @throws ReferenceFrameMismatchException if reference frame of {@code this} and * {@code tupleOriginal} do not match. */ default void inverseTransform(FrameTuple2DReadOnly tupleOriginal, FrameTuple2DBasics tupleTransformed) { checkReferenceFrameMatch(tupleOriginal); tupleTransformed.setToZero(getReferenceFrame()); Orientation2DReadOnly.super.inverseTransform(tupleOriginal, tupleTransformed); }
/** * Transforms the given {@code tupleOriginal} by the rotation about the z-axis described by this and * stores the result in {@code tupleTransformed}. * * <pre> * tupleTransformed = / cos(yaw) -sin(yaw) \ * tupleOriginal * \ sin(yaw) cos(yaw) / * </pre> * * @param tupleOriginal the tuple to be transformed. Not modified. * @param tupleTransformed the tuple in which the result is stored. Modified. * @throws ReferenceFrameMismatchException if reference frame of {@code this} and * {@code tupleOriginal} do not match. */ default void transform(FrameTuple2DReadOnly tupleOriginal, FrameTuple2DBasics tupleTransformed) { checkReferenceFrameMatch(tupleOriginal); tupleTransformed.setToZero(getReferenceFrame()); Orientation2DReadOnly.super.transform(tupleOriginal, tupleTransformed); }
@Test public void testSetToZero() throws Exception { Random random = new Random(234234L); for (int i = 0; i < ITERATIONS; i++) { ReferenceFrame[] referenceFrames = EuclidFrameRandomTools.nextReferenceFrameTree(random); Tuple2DBasics expectedGeometryObject = createRandomFramelessTuple(random); expectedGeometryObject.setToZero(); ReferenceFrame initialFrame = referenceFrames[random.nextInt(referenceFrames.length)]; F frameGeometryObject = createRandomFrameTuple(random, initialFrame); assertEquals(initialFrame, frameGeometryObject.getReferenceFrame()); assertFalse(expectedGeometryObject.epsilonEquals(frameGeometryObject, EPSILON)); frameGeometryObject.setToZero(); EuclidCoreTestTools.assertTuple2DEquals(expectedGeometryObject, frameGeometryObject, EPSILON); frameGeometryObject = createRandomFrameTuple(random, initialFrame); ReferenceFrame newFrame = referenceFrames[random.nextInt(referenceFrames.length)]; assertEquals(initialFrame, frameGeometryObject.getReferenceFrame()); assertFalse(expectedGeometryObject.epsilonEquals(frameGeometryObject, EPSILON)); frameGeometryObject.setToZero(newFrame); assertEquals(newFrame, frameGeometryObject.getReferenceFrame()); EuclidCoreTestTools.assertTuple2DEquals(expectedGeometryObject, frameGeometryObject, EPSILON); } }