フィルターのクリア

Doubt regarding angles of tan inverse

4 ビュー (過去 30 日間)
Pallov Anand
Pallov Anand 2023 年 2 月 23 日
編集済み: John D'Errico 2023 年 2 月 23 日
If I have some error in angles which is defined as:
e = psi - psi_d
psi and psi_d are assumed to be defined. If I want this angle "e" to be remain between -pi to +pi, i.e.,
-pi < e <= +pi.
How can I do this? Do i need to use atan2 ? If yes, can you plz say, how to use atan2 ?

回答 (1 件)

John D'Errico
John D'Errico 2023 年 2 月 23 日
編集済み: John D'Errico 2023 年 2 月 23 日
atan2 has nothing to do with it. At least not based on anything you said.
The difference between angles can exceed the range you want it to live in. So use mod instead. That is:
e = mod(e,2*pi);
e = e - 2*pi*(e > pi);
So, mod insures the angle will always live in the interval [0,2*pi]. It did that by effectively adding multiples of 2*pi. Then, if the number fell in the upper half of the interval [0,2*pi], I subtract 2*pi. The result will now always live in [-pi,pi].

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by