Fixed Vector[2D].transform2D not using the aboutX/Z arguments properly.

Dieser Commit ist enthalten in:
TomyLobo 2012-01-05 15:57:54 +01:00
Ursprung a7530b7f89
Commit 8c68cdf4a8
2 geänderte Dateien mit 22 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -577,22 +577,25 @@ public class Vector {
* 2D transformation.
*
* @param angle in degrees
* @param aboutX
* @param aboutZ
* @param translateX
* @param translateZ
* @param aboutX about which x coordinate to rotate
* @param aboutZ about which z coordinate to rotate
* @param translateX what to add after rotation
* @param translateZ what to add after rotation
* @return
*/
public Vector transform2D(double angle,
double aboutX, double aboutZ, double translateX, double translateZ) {
angle = Math.toRadians(angle);
double x = this.x;
double z = this.z;
double x = this.x - aboutX;
double z = this.z - aboutZ;
double x2 = x * Math.cos(angle) - z * Math.sin(angle);
double z2 = x * Math.sin(angle) + z * Math.cos(angle);
return new Vector(x2 + aboutX + translateX,
y,
z2 + aboutZ + translateZ);
return new Vector(
x2 + aboutX + translateX,
y,
z2 + aboutZ + translateZ
);
}
/**

Datei anzeigen

@ -503,21 +503,23 @@ public class Vector2D {
* 2D transformation.
*
* @param angle in degrees
* @param aboutX
* @param aboutZ
* @param translateX
* @param translateZ
* @param aboutX about which x coordinate to rotate
* @param aboutZ about which z coordinate to rotate
* @param translateX what to add after rotation
* @param translateZ what to add after rotation
* @return
*/
public Vector2D transform2D(double angle,
double aboutX, double aboutZ, double translateX, double translateZ) {
angle = Math.toRadians(angle);
double x = this.x;
double z = this.z;
double x = this.x - aboutX;
double z = this.z - aboutZ;
double x2 = x * Math.cos(angle) - z * Math.sin(angle);
double z2 = x * Math.sin(angle) + z * Math.cos(angle);
return new Vector2D(x2 + aboutX + translateX,
z2 + aboutZ + translateZ);
return new Vector2D(
x2 + aboutX + translateX,
z2 + aboutZ + translateZ
);
}
/**