Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Punkt {
- final private double x;
- final private double y;
- public Punkt(double x, double y) {
- this.x = x;
- this.y = y;
- }
- public Punkt przesuniecie(double a, double b) {
- return new Punkt(x+a, y+b);
- }
- public double odlegloscOdPocz() {
- return Math.sqrt(x*x + y*y);
- }
- public double odlegloscOdPunktu(Punkt p){
- return Math.sqrt(Math.pow(p.x - x , 2) + Math.pow(p.y - y , 2));
- }
- public Punkt wzgledemOdcietej(){
- return new Punkt(x , -y);
- }
- public Punkt wzgledemRzednej(){
- return new Punkt(-x , y);
- }
- public Punkt wzgledemPoczatku(){
- return new Punkt(-x , -y);
- }
- public double odlegloscOdOX(){
- return Math.abs(y);
- }
- public double odlegloscOdOY() {
- return Math.abs(x);
- }
- public Punkt obrotLewo(double kat){
- double k = Math.toRadians(kat);
- return new Punkt(( (x * Math.cos(k)) - (y * Math.sin(k))) ,( (x * Math.sin(k)) + (y * Math.cos(k))));
- }
- public String toString() {
- return "(" + x + ", " + y + ")";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment