-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPunto.java
65 lines (62 loc) · 1.62 KB
/
Punto.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package treD ;
public class Punto
{
private float x ;
private float y ;
private float z ;
public Punto ( float x , float y , float z) {
this.x = x ;
this.y = y ;
this.z = z ;
}
public Punto () {
this (0.0f , 0.0f , 0.0f );
}
public Punto clona() { return new Punto (x,y,z) ; }
public void setX (float x) { this.x = x; }
public void setY (float y ){ this.y = y ; }
public void setZ (float z) { this.z = z ; }
public float getX () { return x ; }
public float getY () { return y ; }
public float getZ () { return z ; }
public void ruota ( float ang )
// ritorna le coord nel vecchio sistema
// angolo positivo dall' asse y in
// senso orario
{
float seno= (float) Math.sin(ang) ;
float coseno=(float) Math.cos(ang) ;
float newx = (float) (x * coseno + y * seno);
y= (float) ((- x )* seno + y * coseno) ;
x=newx ;
}
public void trasla (Punto newCentro ) // coord nel vecchio sistema
{
x+= newCentro.x ;
y+= newCentro.y ;
z+= newCentro.z ;
}
public void rotoTrasla (Posizione newPos)
{
ruota (newPos.getAngolo ()) ;
trasla(newPos) ;
}
public Punto simmeO () {
return new Punto (-x,-y,-z) ;
}
public Punto simmeXZ () {
return new Punto (x,-y,z) ;
}
public Punto simmeYZ () {
return new Punto (-x,y,z) ;
}
public Punto simmeXY () {
return new Punto (x,y,-z) ;
}
public String toString () {
return ("x = " +x+" , y = " +y + ", z = " +z) ;
}
void stampa () {
System.out.println (toString()) ;
}
}