/** * Compute the 2D equivalent of this line segment. * The 2D equivalent of each end point is computed as follows: * {@code endPoint2d = endPoint1d * direction2d + zero2d}. * @param zero2d position of the 2D equivalent of an endpoint equal to zero. * @param direction2d direction toward greater values of {@code endPoint1d}. * @return the 2D equivalent of this line segment. */ public LineSegment2d toLineSegment2d(Point2d zero2d, Vector2d direction2d) { LineSegment2d lineSegment2d = new LineSegment2d(); lineSegment2d.getFirstEndpoint().scaleAdd(endpoint1, direction2d, zero2d); lineSegment2d.getSecondEndpoint().scaleAdd(endpoint2, direction2d, zero2d); return lineSegment2d; }
public void setAndChangeFrame(FrameLineSegment2d lineSegment) { this.referenceFrame = lineSegment.referenceFrame; this.lineSegment.set(lineSegment.lineSegment); }
private static void checkEndpointsDistinct(Point2d[] endpoints) { if (areEndpointsTheSame(endpoints[0], endpoints[1])) { throw new RuntimeException("Line segment must have two distinct endpoints"); } }
private void getPartialDerivativesWithRespectToS(LineSegment2d segment, double[] partialDerivativesToPack) { double dsdx = (segment.getSecondEndpointX() - segment.getFirstEndpointX()) / segment.length(); double dsdy = (segment.getSecondEndpointY() - segment.getFirstEndpointY()) / segment.length(); partialDerivativesToPack[0] = dsdx; partialDerivativesToPack[1] = dsdy; }
@Override public LineSegment2d applyTransformCopy(RigidBodyTransform transform) { LineSegment2d copy = new LineSegment2d(this); copy.applyTransform(transform); return copy; }
@Override public LineSegment2d applyTransformAndProjectToXYPlaneCopy(RigidBodyTransform transform) { LineSegment2d copy = new LineSegment2d(this); copy.applyTransformAndProjectToXYPlane(transform); return copy; }
LineSegment2d lineSegmentInWorldFrame = new LineSegment2d(); Point3d pointOneInWorldFrame = new Point3d(); Point3d pointTwoInWorldFrame = new Point3d(); pointOneInWorldFrame.set(lineSegmentInSoleFrame.getFirstEndpointX(), lineSegmentInSoleFrame.getFirstEndpointY(), 0.0); pointTwoInWorldFrame.set(lineSegmentInSoleFrame.getSecondEndpointX(), lineSegmentInSoleFrame.getSecondEndpointY(), 0.0); lineSegmentInWorldFrame.set(pointOneInWorldFrame.getX(), pointOneInWorldFrame.getY(), pointTwoInWorldFrame.getX(), pointTwoInWorldFrame.getY()); highestLineSegmentInSoleFrameToPack.set(lineSegmentInSoleFrame);
public FrameLineSegment2d(ReferenceFrame referenceFrame, Point2d firstEndpoint, Point2d secondEndpoint) { this(referenceFrame, new LineSegment2d(firstEndpoint, secondEndpoint)); }
public void drawLineSegment(PlotterReferenceFrame frame, LineSegment2d lineSegment) { PlotterPoint2d firstEndpoint = pointBin[0]; PlotterPoint2d secondEndpoint = pointBin[1]; firstEndpoint.setIncludingFrame(frame, lineSegment.getFirstEndpoint()); secondEndpoint.setIncludingFrame(frame, lineSegment.getSecondEndpoint()); firstEndpoint.changeFrame(screenFrame); secondEndpoint.changeFrame(screenFrame); drawLineSegment(pixelate(firstEndpoint.getX()), pixelate(firstEndpoint.getY()), pixelate(secondEndpoint.getX()), pixelate(secondEndpoint.getY())); }
/** * Must provide a draw method for plotter to render artifact */ @Override public void draw(Graphics2DAdapter graphics) { graphics.setColor(color); graphics.setStroke(STROKE); if (LineSegment2d.areEndpointsTheSame(point1, point2)) { graphics.drawPoint(point1); } else { tempLineSegment.set(point1, point2); graphics.drawLineSegment(tempLineSegment); } }
private void setPointXValues(FramePoint nextContactFramePosition) double length = projectionSegment.length(); if (nextContactFramePosition != null) Line2d line2d = new Line2d(projectionSegment.getFirstEndpointCopy(), projectionSegment.getSecondEndpointCopy()); Point2d nextPoint2d = new Point2d(nextContactFramePosition.getX(), nextContactFramePosition.getY()); line2d.orthogonalProjectionCopy(nextPoint2d); xSNext = projectionSegment.percentageAlongLineSegment(nextPoint2d) * projectionSegment.length();
/** * Final phase helper method called if one range has a size of exactly one * @return The two points on each respective polygon which are closest to one another */ private static Point2d[] finalPhasePointAndEdge(Point2d edgePoint1, Point2d edgePoint2, Point2d lonePoint) { Point2d proj = GeometryTools.getOrthogonalProjectionOnLine(lonePoint, edgePoint1, edgePoint2); LineSegment2d p = new LineSegment2d(edgePoint1, edgePoint2); if (p.isBetweenEndpoints(proj, 0)) { return new Point2d[] {lonePoint, proj}; } else { return new Point2d[] {lonePoint, (lonePoint.distance(edgePoint1) < lonePoint.distance(edgePoint2)) ? edgePoint1 : edgePoint2}; } }
LineSegment2d middleToLeft = new LineSegment2d(0.0, 0.0, 0.0, minimumDistanceFromCliffBottoms); LineSegment2d middleToRight = new LineSegment2d(0.0, 0.0, 0.0, -minimumDistanceFromCliffBottoms); LineSegment2d frontToLeft = new LineSegment2d(forwardBackForSidewaysLook, 0.0, forwardBackForSidewaysLook, minimumDistanceFromCliffBottoms); LineSegment2d frontToRight = new LineSegment2d(forwardBackForSidewaysLook, 0.0, forwardBackForSidewaysLook, -minimumDistanceFromCliffBottoms); LineSegment2d backToLeft = new LineSegment2d(-forwardBackForSidewaysLook, 0.0, -forwardBackForSidewaysLook, minimumDistanceFromCliffBottoms); LineSegment2d backToRight = new LineSegment2d(-forwardBackForSidewaysLook, 0.0, -forwardBackForSidewaysLook, -minimumDistanceFromCliffBottoms); LineSegment2d backToBackFurther = new LineSegment2d(-0.0, 0.0, -minimumDistanceFromCliffBottoms, 0.0); LineSegment2d frontToFrontFurther = new LineSegment2d(-0.0, 0.0, minimumDistanceFromCliffBottoms, 0.0); LineSegment2d highestLineSegmentInSoleFrame = new LineSegment2d(); maximumCliffZInSoleFrame.set(findHighestPointInOriginalSoleFrame(planarRegionsList, soleTransform, inverseSoleTransform, lineSegmentsInSoleFrame, highestPointInSoleFrame, highestLineSegmentInSoleFrame)); maximumCliffXInSoleFrame.set(highestPointInSoleFrame.getX()); shiftVectorInSoleFrame.sub(highestLineSegmentInSoleFrame.getFirstEndpointCopy());
polygonAsLineSegment.set(vertex0, vertex1); double percentageAlongSegment = distance / polygonAsLineSegment.length(); polygonAsLineSegment.pointBetweenEndPointsGivenParameter(percentageAlongSegment, newVertex0); polygonAsLineSegment.pointBetweenEndPointsGivenParameter(1 - percentageAlongSegment, newVertex1);
private Point2d getPointInPolygonNearestPoint(ConvexPolygon2d polygon, Point2d point2d) { LineSegment2d closestEdge = new LineSegment2d(); polygon.getClosestEdge(closestEdge, point2d); return closestEdge.getClosestPointOnLineSegmentCopy(point2d); } }
public FramePoint2d getFirstEndpointCopy() { return new FramePoint2d(referenceFrame, lineSegment.getFirstEndpointCopy()); }
private void getYoValuesFromFrameLineSegment() { LineSegment2d lineSegment2d = frameLineSegment.getLineSegment2d(); firstEndpointX.set(lineSegment2d.getFirstEndpointX()); firstEndpointY.set(lineSegment2d.getFirstEndpointY()); secondEndpointX.set(lineSegment2d.getSecondEndpointX()); secondEndpointY.set(lineSegment2d.getSecondEndpointY()); }
public LineSegment2d getLineSegment2dCopy() { return new LineSegment2d(lineSegment); }
public void drawLineSegment(PlotterReferenceFrame frame, LineSegment2d lineSegment) { PlotterPoint2d firstEndpoint = pointBin[0]; PlotterPoint2d secondEndpoint = pointBin[1]; firstEndpoint.setIncludingFrame(frame, lineSegment.getFirstEndpoint()); secondEndpoint.setIncludingFrame(frame, lineSegment.getSecondEndpoint()); firstEndpoint.changeFrame(screenFrame); secondEndpoint.changeFrame(screenFrame); drawLineSegment(pixelate(firstEndpoint.getX()), pixelate(firstEndpoint.getY()), pixelate(secondEndpoint.getX()), pixelate(secondEndpoint.getY())); }
/** * Must provide a draw method for plotter to render artifact */ @Override public void draw(Graphics2DAdapter graphics) { graphics.setColor(color); graphics.setStroke(STROKE); if (LineSegment2d.areEndpointsTheSame(point1, point2)) { graphics.drawPoint(point1); } else { tempLineSegment.set(point1, point2); graphics.drawLineSegment(tempLineSegment); } }