public class Point2D { //properties of Point2D private final double x; private final double y; //Contructors Point2D(){ this.x=0; this.y=0; } Point2D(double x, double y){ this.x=x; this.y=y; } // double getX () { return this.x; } double getY () { return this.y; } double norm2 () { return this.getX()*this.getX()+this.getY()*this.getY(); } double distanceFrom (Point2D pointQ) { return Math.sqrt(Math.pow(pointQ.getX()-this.getX(),2) + Math.pow(pointQ.getY()+this.getY(), 2)); } +translate(double, double):point2D which returns the point obtained by translating on the axes X and Y Point2D translate (double dx, double dy) { return new Point2D(this.getX()+dx, this.getY()+dy); } Point2D translate (Point2D vect) { return new Point2D(this.getX()+vect.getX(), this.getY()+vect.getY()); } Point2D rotateOf(double angle) { if(this.getX()==0 && this.getY()==0) { return this; } else { return new Point2D( this.getX()+(Math.cos(angle)/this.norm2()), this.getY()+(Math.sin(angle)/this.norm2()) ); } } Point2D rotateOfWithCenter(double angle, Point2D center) { Point2D Pprime = this.translate(-center.getX(), -center.getY()); Point2D Psecond = Pprime.rotateOf(angle); Point2D Pthird = Psecond.translate(center); return Pthird; // return this.translate(-center.getX(),-center.getY()).rotateOf(angle).translate(center); } }