「Unity/Csharp/数学」の版間の差分

提供: 初心者エンジニアの簡易メモ
ナビゲーションに移動 検索に移動
編集の要約なし
10行目: 10行目:
</pre>
</pre>
参考:https://kuroeveryday.blogspot.com/2015/03/Trigonometry.html
参考:https://kuroeveryday.blogspot.com/2015/03/Trigonometry.html
==整数化==
切り上げ
Mathf.Ceil((float)size);
切り捨て
Mathf.Floor((float)size);
丸め(Round)
Mathf.Round((float)size);

2021年5月19日 (水) 19:37時点における版

小数点第二位まで

float num = 1.1234f;
num.ToString("f2");

角度

int angle = 10; // 10度の場合
double x = Math.Sin(angle * (Math.PI / 180));
double y = Math.Cos(angle * (Math.PI / 180));

参考:https://kuroeveryday.blogspot.com/2015/03/Trigonometry.html

整数化

切り上げ

Mathf.Ceil((float)size);

切り捨て

Mathf.Floor((float)size);

丸め(Round)

Mathf.Round((float)size);