/** * Sets this tuple's components {@code x}, {@code y} in order from the given array * {@code tupleArray} and sets this tuple frame to {@code referenceFrame}. * * @param referenceFrame the new reference frame for this tuple. * @param tupleArray the array containing the new values for this tuple's components. Not modified. */ default void setIncludingFrame(ReferenceFrame referenceFrame, double[] tupleArray) { setReferenceFrame(referenceFrame); set(tupleArray); }
/** * Sets all the components of this tuple to {@link Double#NaN} and sets the current reference frame * to {@code referenceFrame}. * * @param referenceFrame the new reference frame to be associated with this tuple. */ default void setToNaN(ReferenceFrame referenceFrame) { setReferenceFrame(referenceFrame); setToNaN(); }
/** * 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(); }
public void setOrCreate(int i, FrameTuple2DReadOnly frameTuple2d) { getAndGrowIfNeeded(i).setIncludingFrame(frameTuple2d); }
@Test public void testSetToNaN() throws Exception { Random random = new Random(574); for (int i = 0; i < ITERATIONS; i++) { ReferenceFrame[] referenceFrames = EuclidFrameRandomTools.nextReferenceFrameTree(random); ReferenceFrame initialFrame = referenceFrames[random.nextInt(referenceFrames.length)]; F frameGeometryObject = createRandomFrameTuple(random, initialFrame); assertEquals(initialFrame, frameGeometryObject.getReferenceFrame()); assertFalse(frameGeometryObject.containsNaN()); frameGeometryObject.setToNaN(); EuclidCoreTestTools.assertTuple2DContainsOnlyNaN(frameGeometryObject); frameGeometryObject = createRandomFrameTuple(random, initialFrame); ReferenceFrame newFrame = referenceFrames[random.nextInt(referenceFrames.length)]; assertEquals(initialFrame, frameGeometryObject.getReferenceFrame()); assertFalse(frameGeometryObject.containsNaN()); frameGeometryObject.setToNaN(newFrame); assertEquals(newFrame, frameGeometryObject.getReferenceFrame()); EuclidCoreTestTools.assertTuple2DContainsOnlyNaN(frameGeometryObject); } }
/** * 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); }
@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); } }
F frameTuple = createRandomFrameTuple(random, initialFrame); Tuple2DBasics tuple = new Vector2D(); assertEquals(initialFrame, frameTuple.getReferenceFrame()); frameTuple.setIncludingFrame(newFrame, x, y); tuple.set(x, y); assertEquals(newFrame, frameTuple.getReferenceFrame()); EuclidCoreTestTools.assertTuple2DEquals(tuple, frameTuple, EPSILON); F frameTuple = createRandomFrameTuple(random, initialFrame); Tuple2DBasics tuple = new Vector2D(); assertEquals(initialFrame, frameTuple.getReferenceFrame()); frameTuple.setIncludingFrame(newFrame, input); tuple.set(input); assertEquals(newFrame, frameTuple.getReferenceFrame()); EuclidCoreTestTools.assertTuple2DEquals(tuple, frameTuple, EPSILON); F frameTuple = createRandomFrameTuple(random, initialFrame); Tuple2DBasics tuple = new Vector2D(); assertEquals(initialFrame, frameTuple.getReferenceFrame()); frameTuple.setIncludingFrame(newFrame, input); tuple.set(input); assertEquals(newFrame, frameTuple.getReferenceFrame()); EuclidCoreTestTools.assertTuple2DEquals(tuple, frameTuple, EPSILON); assertEquals(initialFrame, frameTuple.getReferenceFrame()); Exception expectedException = null; frameTuple.setIncludingFrame(newFrame, input); if (expectedException != null)
actual.set(initialFrame, expected); assertEquals(initialFrame, actual.getReferenceFrame()); actual.set(createRandomFramelessTuple(random)); actual.set(differentFrame, createRandomFramelessTuple(random)); fail("Should have thrown a ReferenceFrameMismatchException"); actual.set(initialFrame, expected.getX(), expected.getY()); assertEquals(initialFrame, actual.getReferenceFrame()); actual.set(createRandomFramelessTuple(random)); actual.set(differentFrame, random.nextDouble(), random.nextDouble()); fail("Should have thrown a ReferenceFrameMismatchException");
/** * Performs the inverse of the transform to the given tuple {@code tupleOriginal} and stores the * result in {@code tupleTransformed}. * <p> * If the given tuple is expressed in the base frame in which this orientation is expressed, then * the tuple is transformed such that it is, after this method is called, expressed in the local * frame described by this orientation. * </p> * * @param tupleOriginal the tuple to transform. Not modified. * @param tupleTransformed the tuple to store the result. Modified. * @throws NotAMatrix2DException if this orientation does not represent a transformation in the XY * plane. */ default void inverseTransform(Tuple2DReadOnly tupleOriginal, FrameTuple2DBasics tupleTransformed) { tupleTransformed.setReferenceFrame(getReferenceFrame()); inverseTransform((Tuple2DReadOnly) tupleOriginal, (Tuple2DBasics) tupleTransformed); }
private void unsafeSet(int i, FrameTuple2DReadOnly frameTuple2d) { unsafeGet(i).setIncludingFrame(frameTuple2d); }
/** * 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); }
/** * Transforms the given tuple {@code tupleOriginal} by this orientation and stores the result in * {@code tupleTransformed}. * <p> * If the given tuple is expressed in the local frame described by this orientation, then the tuple * is transformed such that it is, after this method is called, expressed in the base frame in which * this orientation is expressed. * </p> * * @param tupleOriginal the tuple to transform. Not modified. * @param tupleTransformed the tuple to store the result. Modified. * @throws NotAMatrix2DException if this orientation does not represent a transformation in the XY * plane. */ default void transform(Tuple2DReadOnly tupleOriginal, FrameTuple2DBasics tupleTransformed) { tupleTransformed.setReferenceFrame(getReferenceFrame()); transform((Tuple2DReadOnly) tupleOriginal, (Tuple2DBasics) tupleTransformed); }
/** * Sets this tuple's components {@code x}, {@code y} in order from the given array * {@code tupleArray} and sets this tuple frame to {@code referenceFrame}. * * @param referenceFrame the new reference frame for this tuple. * @param startIndex the first index to start reading from in the array. * @param tupleArray the array containing the new values for this tuple's components. Not modified. */ default void setIncludingFrame(ReferenceFrame referenceFrame, int startIndex, double[] tupleArray) { setReferenceFrame(referenceFrame); set(startIndex, tupleArray); }
private void unsafeSet(int i, ReferenceFrame referenceFrame, Tuple2DReadOnly tuple2d) { unsafeGet(i).setIncludingFrame(referenceFrame, tuple2d); }
/** * 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); }
/** * Performs the inverse of the transform to the given tuple {@code tupleOriginal} and stores the * result in {@code tupleTransformed}. * <p> * If the given tuple is expressed in the base frame in which this orientation is expressed, then * the tuple is transformed such that it is, after this method is called, expressed in the local * frame described by this orientation. * </p> * * @param tupleOriginal the tuple to transform. Not modified. * @param tupleTransformed the tuple to store the result. Modified. * @param checkIfTransformInXYPlane whether this method should assert that this orientation * represents a transformation in the XY plane. * @throws NotAMatrix2DException if {@code checkIfTransformInXYPlane == true} and this orientation * does not represent a transformation in the XY plane. */ default void inverseTransform(Tuple2DReadOnly tupleOriginal, FrameTuple2DBasics tupleTransformed, boolean checkIfTransformInXYPlane) { tupleTransformed.setReferenceFrame(getReferenceFrame()); inverseTransform((Tuple2DReadOnly) tupleOriginal, (Tuple2DBasics) tupleTransformed, checkIfTransformInXYPlane); }
/** * Sets this frame tuple to {@code tuple2DReadOnly} and sets its current frame to * {@code referenceFrame}. * * @param referenceFrame the new reference frame for this frame tuple. * @param tuple2DReadOnly the tuple to copy the values from. Not modified. */ default void setIncludingFrame(ReferenceFrame referenceFrame, Tuple2DReadOnly tuple2DReadOnly) { setReferenceFrame(referenceFrame); set(tuple2DReadOnly); }
public void set(int i, FrameTuple2DReadOnly frameTuple2d) { get(i).setIncludingFrame(frameTuple2d); }
/** * 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); }