/** {@inheritDoc} */ @Override public void clear() { numberOfVertices = 0; area = Double.NaN; centroid.setToNaN(); boundingBox.setToNaN(); isUpToDate = false; }
bisectorSegmentStartToPack.checkReferenceFrameMatch(lineSegmentStart); bisectorSegmentEndToPack.checkReferenceFrameMatch(lineSegmentStart); return EuclidGeometryTools.perpendicularBisectorSegment2D(lineSegmentStart, lineSegmentEnd, bisectorSegmentHalfLength, bisectorSegmentStartToPack, bisectorSegmentEndToPack);
/** * Sets this point coordinate to the given {@code referenceFrame}'s origin coordinate in this frame * tuple current frame. * * @param referenceFrame the reference frame of interest. */ default void setFromReferenceFrame(ReferenceFrame referenceFrame) { setToZero(); referenceFrame.transformFromThisToDesiredFrame(getReferenceFrame(), this); } }
/** {@inheritDoc} */ @Override public void addVertexMatchingFrame(ReferenceFrame referenceFrame, Point2DReadOnly vertex, boolean checkIfTransformInXYPlane) { // Check for the trivial case: the geometry is already expressed in the desired frame. if (getReferenceFrame() == referenceFrame) { addVertex(vertex); } else { referenceFrame.getTransformToDesiredFrame(transformToDesiredFrame, getReferenceFrame()); addVertex(vertex); getVertexUnsafe(getNumberOfVertices() - 1).applyTransform(transformToDesiredFrame, checkIfTransformInXYPlane); } }
graphics.setStroke(STROKE); if (lineSegment.getFirstEndpoint().equals(lineSegment.getSecondEndpoint()))
/** {@inheritDoc} */ @Override public void addVertexMatchingFrame(ReferenceFrame referenceFrame, Point2DReadOnly vertex, boolean checkIfTransformInXYPlane) { // Check for the trivial case: the geometry is already expressed in the desired frame. if (getReferenceFrame() == referenceFrame) { addVertex(vertex); } else { referenceFrame.getTransformToDesiredFrame(transformToDesiredFrame, getReferenceFrame()); addVertex(vertex); getVertexUnsafe(getNumberOfVertices() - 1).applyTransform(transformToDesiredFrame, checkIfTransformInXYPlane); } }
/** {@inheritDoc} */ @Override public void clear() { numberOfVertices.set(0); area = Double.NaN; centroid.setToNaN(); boundingBox.setToNaN(); isUpToDate = false; }
projectionToPack.checkReferenceFrameMatch(lineSegmentStart); return EuclidGeometryTools.orthogonalProjectionOnLineSegment2D(pointToProjectX, pointToProjectY, lineSegmentStart, lineSegmentEnd, projectionToPack);
/** * Given a triangle defined by three points (A,B,C), this methods the point X ∈ AC such that the * line (B, X) is the angle bisector of B. As a result, the two angles CBX and XBA are equal. * <a href="https://en.wikipedia.org/wiki/Angle_bisector_theorem"> Useful link</a>. * <p> * Edge cases: * <ul> * <li>if any the triangle's edge is shorter than {@link EuclidGeometryTools#ONE_TRILLIONTH}, this * method fails and returns {@code false}. * </ul> * </p> * * @param A the first vertex of the triangle. Not modified. * @param B the second vertex of the triangle, this is the first endpoint of the bisector. Not * modified. * @param C the third vertex of the triangle. Not modified. * @param XToPack point in which the second endpoint of the bisector is stored. Modified. * @return whether the bisector could be calculated or not. * @throws ReferenceFrameMismatchException if the arguments are not all expressed in the same * reference frame. */ public static boolean triangleBisector2D(FramePoint2DReadOnly A, FramePoint2DReadOnly B, FramePoint2DReadOnly C, FixedFramePoint2DBasics XToPack) { A.checkReferenceFrameMatch(B); A.checkReferenceFrameMatch(C); XToPack.checkReferenceFrameMatch(A); return EuclidGeometryTools.triangleBisector2D(A, B, C, XToPack); }
/** * Computes the orthogonal projection of a 2D point on an infinitely long 2D line defined by a 2D * line segment. * <p> * Edge cases: * <ul> * <li>if the two given points on the line are too close, i.e. * {@code firstPointOnLine.distanceSquared(secondPointOnLine) < }{@link EuclidGeometryTools#ONE_TRILLIONTH}, * this method fails and returns {@code false}. * </ul> * </p> * * @param pointToProject the point to compute the projection of. Not modified. * @param firstPointOnLine a first point located on the line. Not modified. * @param secondPointOnLine a second point located on the line. Not modified. * @param projectionToPack point in which the projection of the point onto the line is stored. * Modified. * @return whether the method succeeded or not. * @throws ReferenceFrameMismatchException if the arguments are not all expressed in the same * reference frame. */ public static boolean orthogonalProjectionOnLine2D(FramePoint2DReadOnly pointToProject, FramePoint2DReadOnly firstPointOnLine, FramePoint2DReadOnly secondPointOnLine, FixedFramePoint2DBasics projectionToPack) { pointToProject.checkReferenceFrameMatch(firstPointOnLine); pointToProject.checkReferenceFrameMatch(secondPointOnLine); projectionToPack.checkReferenceFrameMatch(pointToProject); return EuclidGeometryTools.orthogonalProjectionOnLine2D(pointToProject, firstPointOnLine, secondPointOnLine, projectionToPack); }
/** * Computes the perpendicular bisector of line segment defined by its two endpoints. The bisector * starts off the the middle of the line segment and points toward the left side of the line * segment. * <p> * Edge cases: * <ul> * <li>when the line segment endpoints are equal, more precisely when * {@code lineSegmentStart.distance(lineSegmentEnd) < }{@link EuclidGeometryTools#ONE_TRILLIONTH}, * the method fails and returns {@code false}. * </ul> * </p> * * @param lineSegmentStart the first endpoint of the line segment. Not modified. * @param lineSegmentEnd the second endpoint of the line segment. Not modified. * @param bisectorStartToPack a 2D point in which the origin of the bisector is stored. Modified. * @param bisectorDirectionToPack a 2D vector in which the direction of the bisector is stored. * Modified. * @return whether the perpendicular bisector could be determined or not. * @throws ReferenceFrameMismatchException if the arguments are not all expressed in the same * reference frame. */ public static boolean perpendicularBisector2D(FramePoint2DReadOnly lineSegmentStart, FramePoint2DReadOnly lineSegmentEnd, FixedFramePoint2DBasics bisectorStartToPack, FixedFrameVector2DBasics bisectorDirectionToPack) { lineSegmentStart.checkReferenceFrameMatch(lineSegmentEnd); bisectorStartToPack.checkReferenceFrameMatch(lineSegmentStart); bisectorDirectionToPack.checkReferenceFrameMatch(lineSegmentStart); return EuclidGeometryTools.perpendicularBisector2D(lineSegmentStart, lineSegmentEnd, bisectorStartToPack, bisectorDirectionToPack); }
projectionToPack.checkReferenceFrameMatch(pointToProject); return EuclidGeometryTools.orthogonalProjectionOnLineSegment2D(pointToProject, lineSegmentStart, lineSegmentEnd, projectionToPack);
/** * Computes the orthogonal projection of a 2D point on an infinitely long 2D line defined by a 2D * point and a 2D direction. * <p> * Edge cases: * <ul> * <li>if the given line direction is too small, i.e. * {@code lineDirection.lengthSquared() < }{@link EuclidGeometryTools#ONE_TRILLIONTH}, this method * fails and returns {@code false}. * </ul> * </p> * * @param pointToProject the point to compute the projection of. Not modified. * @param pointOnLine a point located on the line. Not modified. * @param lineDirection the direction of the line. Not modified. * @param projectionToPack point in which the projection of the point onto the line is stored. * Modified. * @return whether the method succeeded or not. * @throws ReferenceFrameMismatchException if the arguments are not all expressed in the same * reference frame. */ public static boolean orthogonalProjectionOnLine2D(FramePoint2DReadOnly pointToProject, FramePoint2DReadOnly pointOnLine, FrameVector2DReadOnly lineDirection, FixedFramePoint2DBasics projectionToPack) { pointToProject.checkReferenceFrameMatch(pointOnLine); pointToProject.checkReferenceFrameMatch(lineDirection); projectionToPack.checkReferenceFrameMatch(pointToProject); return EuclidGeometryTools.orthogonalProjectionOnLine2D(pointToProject, pointOnLine, lineDirection, projectionToPack); }