use of org.csstudio.swt.widgets.figureparts.PolarPoint in project yamcs-studio by yamcs.
the class PolylineFigure method calcArrowPoints.
/**
* Calculate the three points for an arrow.
*
* @param startPoint
* the start point of the line
* @param endPoint
* the end point of the line
* @param l
* the length of the arrow line
* @param angle
* the radians angle between the line and the arrow line.
* @return A point list which includes the three points: <br>
* 0: Right arrow point; <br>
* 1: Left arrow point; <br>
* 2: Intersection point.
*/
public static PointList calcArrowPoints(Point startPoint, Point endPoint, int l, double angle) {
PointList result = new PointList();
PolarPoint ppE = PolarPoint.point2PolarPoint(endPoint, startPoint);
PolarPoint ppR = new PolarPoint(l, ppE.theta - angle);
PolarPoint ppL = new PolarPoint(l, ppE.theta + angle);
// the intersection point bettwen arrow and line.
PolarPoint ppI = new PolarPoint((int) (l * Math.cos(angle)), ppE.theta);
Point pR = ppR.toPoint().translate(endPoint);
Point pL = ppL.toPoint().translate(endPoint);
Point pI = ppI.toPoint().translate(endPoint);
result.addPoint(pR);
result.addPoint(pL);
result.addPoint(pI);
return result;
}
Aggregations