angle static method

double angle(
  1. Sp3dV2D a,
  2. Sp3dV2D b, {
  3. Sp3dV2D origin = const Sp3dV2D(0, 0),
})

(en)Computes and returns the angle between vectorA and the vectorB. The unit of the return value is radians.

(ja)このベクトルaとベクトルbとの間の角度を計算して返します。 戻り値の単位はラジアンです。

  • a : vector a.
  • b : vector b.
  • origin : the origin.

Implementation

static double angle(Sp3dV2D a, Sp3dV2D b,
    {Sp3dV2D origin = const Sp3dV2D(0, 0)}) {
  double v1 = (a.x - origin.x) * (b.y - origin.y) -
      (a.y - origin.y) * (b.x - origin.x);
  double v2 = (a.x - origin.x) * (b.x - origin.x) +
      (a.y - origin.y) * (b.y - origin.y);
  return atan2(v1, v2);
}