Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help me write mehtod Point rotate90() in java import java.lang.*; class P

ID: 3706753 • Letter: P

Question

Please help me write mehtod Point rotate90() in java

import java.lang.*;

class Point

{

private final double x;

private final double y;

public Point(double x, double y)

{

this.x =x;

this.y = y;

}

public double getX()

{

return this.x;

}

public double getY()

{

return this.y;

}

public double getRadius()

{

double rad = Math.sqrt(Math.pow(this.getX(), 2) + Math.pow(this.getY(), 2));

return rad;

}

public double getAngle()

{

double angle = Math.atan2(this.getY(),this.getX());

return angle;

}

public Point rotate90()

{

//Help here PLEASE!

  return new Point(-y, x); //THis does not work b/c it only can rotate it once and is for 45 degree angle points

}

}

Explanation / Answer

import java.lang.*; class Point { private final double x; private final double y; public Point(double x, double y) { this.x =x; this.y = y; } public double getX() { return this.x; } public double getY() { return this.y; } public double getRadius() { double rad = Math.sqrt(Math.pow(this.getX(), 2) + Math.pow(this.getY(), 2)); return rad; } public double getAngle() { double angle = Math.atan2(this.getY(),this.getX()); return angle; } public Point rotate90() { //Help here PLEASE! //This is clock wise 90 degree rotation return new Point(y, -x); //THis does not work b/c it only can rotate it once and is for 45 degree angle points } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote