public Vector getPerpendicularVectorPointedTowards( Point2D startPoint, double magnitude, Point2D directionPoint) { Vector perpVect = this.moveTo(startPoint); if (perpVect.relativeCCW(directionPoint) > 0) { // we need to turn counter clockwise perpVect = perpVect.rotate(-1 * Math.PI / 2.0); } else { // we'll rotate clockwise perpVect = perpVect.rotate(Math.PI / 2.0); } return perpVect.rescale(magnitude); }
public Vector getPerpendicularVector(Point2D startPoint, double magnitude) { Vector perpVect = this.moveTo(startPoint); perpVect = perpVect.rotate(Math.PI / 2.0); return perpVect.rescale(magnitude); }