LoginSignup
0
0

More than 1 year has passed since last update.

円を使う -In spigot-

Last updated at Posted at 2022-12-02

円を描く

int radius = 3;
for(double theta = 0;theta <= (2*Math.PI);theta+=(2*Math.PI/360)){
  double x = radius * Math.cos(theta);
  double z = radius * Math.sin(theta);
  double y = 0;
  Location L = new Location(world,x,y,z);
  L.getBlock().setType(Material.DIAMOND_BLOCK);
}

半径3の円周上にダイヤモンドブロックを設置します。
(world , y は適当です)

どうして <= 2 * Math.PIなの?

角度をラジアンで表現しているため。
(ラジアンは 360° を 0 ~ 2π で表現します。)

2*Math.PI/360 ってなあに?

前述のラジアンを360で割った数値です。
要するに 1° に対応するラジアンの値を表しています。

なんでラジアンなんか使うの?

三角関数のメソッドは引数をラジアンにしなさいと指定されているからです。
プログラミングに限らず、三角関数を使うほとんどの場面でラジアンを用いるのでそれに倣っただけでしょう。

参考

0
0
0

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
0
0