3

So I've found this class called Vecter2f in Slick2D and inside of it there is a method called getTheta. I don't know what this does but I got the source to the method if that will help. And what use is this method?

public strictfp double getTheta() {
    double theta = StrictMath.toDegrees(StrictMath.atan2(this.y, this.x));
    if ((theta < -360.0D) || (theta > 360.0D)) {
        theta %= 360.0D;
    }
    if (theta < 0.0D) {
        theta += 360.0D;
    }

    return theta;
}
almightyGOSU
  • 3,731
  • 6
  • 31
  • 41
user2223779
  • 47
  • 1
  • 3

2 Answers2

2

It returns the(noramlized) angle(in degrees) that the x-axis forms with the segment connecting the given point and the origin of the coordinate system. So when the point is converted in polar form, this function returns its argument.

Ivaylo Strandjev
  • 69,226
  • 18
  • 123
  • 176
2

Consider the following right-angled triangle:

RIght-angled triangle

Given Rx and Ry, the function computes θ. The result is expressed in degrees and is normalized to [0; 360).

NPE
  • 486,780
  • 108
  • 951
  • 1,012