/** * Static member function for creating an angle object from to 2D vector's data. * Returns new angle instance and sets it's angle to angle between given 2D points. */ Angle Angle::getAngleBetween(Vector2<double> p1, Vector2<double> p2) { Angle angle; double dX = p2.getX() - p1.getX(); double dY = p2.getY() - p1.getY(); angle.setRadians(atan2(dY, dX)); return angle; }
Angle Vector2D::getAngle() const { Angle angle; angle.setRadians(atan2(yComp, xComp)); if (angle.getDegrees() < 0) angle = angle + H_TAU; return angle; }
Angle Angle::arcTangent2(float y, float x) { Angle a; a.setRadians(atan2f(y, x)); return a; }
Angle Angle::arcTangent(float x) { Angle a; a.setRadians(atanf(x)); return a; }
Angle Angle::arcSine(float x) { Angle a; a.setRadians(asinf(x)); return a; }
Angle Angle::arcCosine(float x) { Angle a; a.setRadians(acosf(x)); return a; }
/** * Static member function for creating an angle object from radians. * Returns new angle instance and sets it's angle to given radian value. */ Angle Angle::fromRadians(double radians) { Angle angle; angle.setRadians(radians); return angle; }