private YoArtifactLineSegment2d(String name, YoDouble startX, YoDouble startY, YoDouble endX, YoDouble endY, Color color, double arrowHeadWidth, double arrowHeadHeight) { this(name, new YoFrameLineSegment2D(startX, startY, endX, endY, ReferenceFrame.getWorldFrame()), color, arrowHeadWidth, arrowHeadHeight); }
public YoArtifactLineSegment2d(String name, YoFrameLineSegment2D lineSegment, Color color) { super(name, new double[0], color, lineSegment.getYoFirstEndpointX(), lineSegment.getYoFirstEndpointY(), lineSegment.getYoSecondEndpointX(), lineSegment.getYoSecondEndpointY()); this.lineSegment = lineSegment; this.drawArrow = false; }
graphics.setStroke(STROKE); if (lineSegment.getFirstEndpoint().equals(lineSegment.getSecondEndpoint())) tempFirstEndpoint.set(lineSegment.getFirstEndpointX(), lineSegment.getFirstEndpointY()); graphics.drawPoint(tempFirstEndpoint); arrowHeadVector.set(lineSegment.getSecondEndpointX() - lineSegment.getFirstEndpointX(), lineSegment.getSecondEndpointY() - lineSegment.getFirstEndpointY()); arrowHeadVector.normalize(); arrowHeadLateralVector.set(arrowHeadVector.getY(), -arrowHeadVector.getX()); arrowHeadLateralVector.scale(arrowHeadWidth / 2.0); ((Tuple2DBasics) tempArrowPolygon.getVertex(0)).set(lineSegment.getSecondEndpointX(), lineSegment.getSecondEndpointY()); ((Tuple2DBasics) tempArrowPolygon.getVertex(1)).set(lineSegment.getSecondEndpointX(), lineSegment.getSecondEndpointY()); ((Tuple2DBasics) tempArrowPolygon.getVertex(1)).sub(arrowHeadVector); ((Tuple2DBasics) tempArrowPolygon.getVertex(1)).sub(arrowHeadLateralVector); ((Tuple2DBasics) tempArrowPolygon.getVertex(2)).set(lineSegment.getSecondEndpointX(), lineSegment.getSecondEndpointY()); ((Tuple2DBasics) tempArrowPolygon.getVertex(2)).sub(arrowHeadVector); ((Tuple2DBasics) tempArrowPolygon.getVertex(2)).add(arrowHeadLateralVector);
@Override public YoArtifact duplicate(YoVariableRegistry newRegistry) { return new YoArtifactLineSegment2d(getName(), lineSegment.duplicate(newRegistry), color, arrowHeadWidth, arrowHeadHeight); } }
public YoArtifactLineSegment2d(String name, YoFrameLineSegment2D lineSegment, Color color, double arrowHeadWidth, double arrowHeadHeight) { super(name, new double[0], color, lineSegment.getYoFirstEndpointX(), lineSegment.getYoFirstEndpointY(), lineSegment.getYoSecondEndpointX(), lineSegment.getYoSecondEndpointY()); this.lineSegment = lineSegment; this.drawArrow = true; instatiateArrowObjects(arrowHeadWidth, arrowHeadHeight); }
/** * Creates a copy of {@code this} by finding the duplicated {@code YoVariable}s in the given * {@link YoVariableRegistry}. * <p> * This method does not duplicate {@code YoVariable}s. Assuming the given registry is a duplicate * of the registry that was used to create {@code this}, this method searches for the duplicated * {@code YoVariable}s and use them to duplicate {@code this}. * </p> * * @param newRegistry YoVariableRegistry to duplicate {@code this} to. * @return the duplicate of {@code this}. */ public YoFrameLineSegment2D duplicate(YoVariableRegistry newRegistry) { return new YoFrameLineSegment2D(firstEndpoint.duplicate(newRegistry), secondEndpoint.duplicate(newRegistry)); }
radii.set(1.0, 0.7); YoFrameLineSegment2D lineSegment = new YoFrameLineSegment2D("segmentGuy", "", ReferenceFrame.getWorldFrame(), registry); lineSegment.getYoFirstEndpointX().set(1.0); lineSegment.getYoFirstEndpointY().set(1.0); lineSegment.getYoSecondEndpointX().set(2.0); lineSegment.getYoSecondEndpointY().set(2.0);
private static YoArtifactLineSegment2d yoArtifactLineSegment2DFromMessage(String name, YoVariable<?>[] vars, double[] consts, AppearanceDefinition appearance) { YoFrameLineSegment2D segment = new YoFrameLineSegment2D((YoDouble) vars[0], (YoDouble) vars[1], (YoDouble) vars[2], (YoDouble) vars[3], ReferenceFrame.getWorldFrame()); return new YoArtifactLineSegment2d(name, segment, appearance.getColor().get()); }
public YoArtifactLineSegment2d(String name, YoFramePoint2D start, YoFramePoint2D end, Color color) { this(name, new YoFrameLineSegment2D(start.getYoX(), start.getYoY(), end.getYoX(), end.getYoY(), ReferenceFrame.getWorldFrame()), color); }
@Override public Artifact createArtifact() { MutableColor color3f = appearance.getColor(); YoDouble endPointX = new YoDouble(getName() + "ArtifactEndPointX", base.getYoX().getYoVariableRegistry()); YoDouble endPointY = new YoDouble(getName() + "ArtifactEndPointY", base.getYoY().getYoVariableRegistry()); base.getYoX().addVariableChangedListener(v -> endPointX.set(base.getX() + vector.getX())); base.getYoY().addVariableChangedListener(v -> endPointY.set(base.getY() + vector.getY())); vector.getYoX().addVariableChangedListener(v -> endPointX.set(base.getX() + vector.getX())); vector.getYoY().addVariableChangedListener(v -> endPointY.set(base.getY() + vector.getY())); return new YoArtifactLineSegment2d(getName(), new YoFrameLineSegment2D(base.getYoX(), base.getYoY(), endPointX, endPointY, ReferenceFrame.getWorldFrame()), color3f.get()); }