1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

平面上における2点間の距離と角度の求め方

Last updated at Posted at 2020-08-27

概要

XY座標の2点間の角度と距離の求め方をまとめる。
言語はJava

距離の求め方

// 2点の座標
double x = 0;
double y = 0;
double x2 = 1;
double y2 = 1;

// 2点の座標から距離を求める
double distance = Math.sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y));

角度の求め方

// 2点の座標
double x = 0;
double y = 0;
double x2 = 1;
double y2 = 1;

// 2点の座標からラジアンを求める
doble radian = Math.atan2(y2 - y, x2 - x);

// ラジアンから度を求める
double degree = radian * 180 / Math.PI;
1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?