Convert newer API from radians to degrees.

This commit is contained in:
sk89q
2014-07-15 20:10:14 -07:00
parent 9b5c112e5c
commit 9feafcfc30
12 changed files with 36 additions and 35 deletions

View File

@ -600,8 +600,7 @@ public class Vector implements Comparable<Vector> {
* @param translateZ what to add after rotation
* @return
*/
public Vector transform2D(double angle,
double aboutX, double aboutZ, double translateX, double translateZ) {
public Vector transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) {
angle = Math.toRadians(angle);
double x = this.x - aboutX;
double z = this.z - aboutZ;
@ -667,7 +666,7 @@ public class Vector implements Comparable<Vector> {
double x2 = x * x;
double z2 = z * z;
double xz = Math.sqrt(x2 + z2);
return (float) Math.atan(-getY() / xz);
return (float) Math.toDegrees(Math.atan(-getY() / xz));
}
}
@ -683,7 +682,7 @@ public class Vector implements Comparable<Vector> {
double t = Math.atan2(-x, z);
double _2pi = 2 * Math.PI;
return (float) ((t + _2pi) % _2pi);
return (float) Math.toDegrees(((t + _2pi) % _2pi));
}
/**

View File

@ -517,8 +517,7 @@ public class Vector2D {
* @param translateZ what to add after rotation
* @return
*/
public Vector2D transform2D(double angle,
double aboutX, double aboutZ, double translateX, double translateZ) {
public Vector2D transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) {
angle = Math.toRadians(angle);
double x = this.x - aboutX;
double z = this.z - aboutZ;

View File

@ -190,9 +190,9 @@ public class ClipboardCommands {
ClipboardHolder holder = session.getClipboard();
AffineTransform transform = new AffineTransform();
transform = transform.rotateY(-Math.toRadians(yRotate != null ? yRotate : 0));
transform = transform.rotateX(-Math.toRadians(xRotate != null ? xRotate : 0));
transform = transform.rotateZ(-Math.toRadians(zRotate != null ? zRotate : 0));
transform = transform.rotateY(-(yRotate != null ? yRotate : 0));
transform = transform.rotateX(-(xRotate != null ? xRotate : 0));
transform = transform.rotateZ(-(zRotate != null ? zRotate : 0));
holder.setTransform(holder.getTransform().combine(transform));
player.print("The clipboard copy has been rotated.");
}

View File

@ -206,8 +206,8 @@ public class SchematicWriter implements ClipboardWriter {
private Tag writeRotation(Location location, String name) {
List<FloatTag> list = new ArrayList<FloatTag>();
list.add(new FloatTag("", (float) Math.toDegrees(location.getYaw())));
list.add(new FloatTag("", (float) Math.toDegrees(location.getPitch())));
list.add(new FloatTag("", location.getYaw()));
list.add(new FloatTag("", location.getPitch()));
return new ListTag(name, FloatTag.class, list);
}

View File

@ -244,6 +244,7 @@ public class AffineTransform implements Transform {
}
public AffineTransform rotateX(double theta) {
theta = Math.toRadians(theta);
double cot = Math.cos(theta);
double sit = Math.sin(theta);
return concatenate(
@ -254,6 +255,7 @@ public class AffineTransform implements Transform {
}
public AffineTransform rotateY(double theta) {
theta = Math.toRadians(theta);
double cot = Math.cos(theta);
double sit = Math.sin(theta);
return concatenate(
@ -264,6 +266,7 @@ public class AffineTransform implements Transform {
}
public AffineTransform rotateZ(double theta) {
theta = Math.toRadians(theta);
double cot = Math.cos(theta);
double sit = Math.sin(theta);
return concatenate(

View File

@ -97,8 +97,8 @@ public class Location {
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
* @param yaw the yaw, in radians
* @param pitch the pitch, in radians
* @param yaw the yaw, in degrees
* @param pitch the pitch, in degrees
*/
public Location(Extent extent, double x, double y, double z, float yaw, float pitch) {
this(extent, new Vector(x, y, z), yaw, pitch);
@ -122,8 +122,8 @@ public class Location {
*
* @param extent the extent
* @param position the position vector
* @param yaw the yaw, in radians
* @param pitch the pitch, in radians
* @param yaw the yaw, in degrees
* @param pitch the pitch, in degrees
*/
public Location(Extent extent, Vector position, float yaw, float pitch) {
checkNotNull(extent);
@ -154,9 +154,9 @@ public class Location {
}
/**
* Get the yaw in radians.
* Get the yaw in degrees.
*
* @return the yaw in radians
* @return the yaw in degrees
*/
public float getYaw() {
return yaw;
@ -173,9 +173,9 @@ public class Location {
}
/**
* Get the pitch in radians.
* Get the pitch in degrees.
*
* @return the pitch in radians
* @return the pitch in degrees
*/
public float getPitch() {
return pitch;
@ -208,8 +208,8 @@ public class Location {
* @return the direction vector
*/
public Vector getDirection() {
double yaw = this.getYaw();
double pitch = this.getPitch();
double yaw = Math.toRadians(this.getYaw());
double pitch = Math.toRadians(this.getPitch());
double xz = Math.cos(pitch);
return new Vector(
-xz * Math.sin(yaw),

View File

@ -52,7 +52,7 @@ public final class NBTConversions {
return new Location(
extent,
positionTag.asDouble(0), positionTag.asDouble(1), positionTag.asDouble(2),
((float) Math.toRadians(directionTag.asDouble(0))), ((float) Math.toRadians(directionTag.asDouble(1))));
(float) directionTag.asDouble(0), (float) directionTag.asDouble(1));
}
}