Está en la página 1de 2

/*

* To change this license header, choose License Headers in Project Properties.


* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication242;

import static java.lang.Math.pow;

/**
*
* @author Alumno
*/
public class punto {

/**
* @return the x
*/
public int getX() {
return x;
}

/**
* @param x the x to set
*/
public void setX(int x) {
this.x = x;
}

/**
* @return the y
*/
public int getY() {
return y;
}

/**
* @param y the y to set
*/
public void setY(int y) {
this.y = y;
}
private int x;
private int y;
punto(int xx, int yy){
this.x = xx;
this.y = yy;
}
public void CalculaDistancia(int a, int b){
double d;
d = (double)Math.pow((pow(x-a,2)+pow(y-b,2)),0.5);
System.out.println("La distancia es: "+d);
}
public void Rotar(double c){
double a,b,ang;
ang=c*Math.PI/180;
a = (x)*Math.cos(ang) + (y) * Math.sin(ang);
b = (-y) * Math.cos(ang) - (x) * Math.sin(ang);
System.out.println("El nuevo punto es: "+a +b);
}
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication242;

import java.util.Scanner;

/**
*
* @author Alumno
*/
public class JavaApplication242 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Ingrese x");
int x1=sc.nextInt();
System.out.println("Ingrese y");
int y1=sc.nextInt();
System.out.println("Ingrese x");
int x2=sc.nextInt();
System.out.println("Ingrese y");
int y2=sc.nextInt();
punto xy=new punto(x1,y1);
xy.CalculaDistancia(x2, y2);
System.out.println("Ingrese y");
double angulo=sc.nextInt();
xy.Rotar(angulo);
}

También podría gustarte