aboutsummaryrefslogblamecommitdiff
path: root/ja_JP.eucJP/man/man3/atan2.3
blob: cdaa7f50c0b80e82a0768d5677b88978e0dfa817 (plain) (tree)































                                                                              
                                                          
   
             












































































































































































                                                                          
.\" Copyright (c) 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\"    must display the following acknowledgement:
.\"	This product includes software developed by the University of
.\"	California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\"    may be used to endorse or promote products derived from this software
.\"    without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\"     from: @(#)atan2.3	5.1 (Berkeley) 5/2/91
.\"	%Id: atan2.3,v 1.5 1997/02/22 15:09:25 peter Exp %
.\"
.\" $FreeBSD$
.Dd May 2, 1991
.Dt ATAN2 3
.Os
.Sh 名称
.Nm atan2 ,
.Nm atan2f
.Nd 2 つの変数の逆正接関数
.Sh 書式
.Fd #include <math.h>
.Ft double
.Fn atan2 "double y" "double x"
.Ft float
.Fn atan2f "float y" "float x"
.Sh 解説
.Fn atan2
関数と
.Fn atan2f
関数は、
.Fa y/ Ns Ar x
の逆正接の主値を計算します。その際、
両方の引数の符号を使用して戻り値の象限を判定します。
.Pp
.Sh 戻り値
.Fn atan2
関数と
.Fn atan2f
関数は、処理が成功すると、範囲
.Bk -words
.Bq \&- Ns \*)Pi , \&+ Ns \*(Pi
.Ek
ラジアン内の
.Fa y/ Ns Ar x
の逆正接を返します。
.Fa x
と
.Fa y
の両方がゼロの場合、
グローバル変数
.Va errno
が
.Er EDOM
に設定されます。
.Tn VAX
では次のとおりです。
.Bl -column atan2_(y,x)_:=____ sign(y)_(Pi_atan2(Xy_xX))___
.It Fn atan2 y x No := Ta
.Fn atan y/x Ta
.Ar x
> 0
の場合
.It Ta sign( Ns Ar y Ns )*(\*(Pi -
.Fn atan "\\*(Bay/x\\*(Ba" ) Ta
.Ar x
< 0
の場合
.It Ta
.No 0 Ta
x = y = 0
の場合、
.It Ta
.Pf sign( Ar y Ns )*\\*(Pi/2 Ta
.Ar x
= 0 \*(!=
.Ar y
の場合
.El
.Sh 注
関数
.Fn atan2
は
.Tn VAX
で ``x > 0 の場合''、
.Fn atan2 0 0
= 0
を定義します。以前は
.Fn atan2 0 0
はエラーメッセージを生成していた
可能性があるにもかかわらずです。
.Fn atan2 0 0
に値を割り当てる理由は次のとおりです。
.Bl -enum -offset indent
.It
.Fn atan2 0 0
の計算を回避するために引数をテストするプログラムは、この値に
無関係である必要があります。これが無効であることを要求するプログラムは、
さまざまなコンピュータシステム上でこれが無効であることに対するさまざまな
反応に対し脆弱です。
.It
.Fn atan2
関数は、矩形
(x,y)
を、極座標
.if n\
(r,theta)
.if t\
(r,\(*h)
に変換します。この座標は、
.if n\
r\(**cos theta
.if t\
r\(**cos\(*h
および
y =
.if n\
r\(**sin theta
.if t\
r\(**sin\(*h
を満たす必要があります。
.if n\
(r,theta)
.if t\
(r,\(*h)
極座標に変換するのに主に使用されます。これらの等式が
満たされるのは、(x=0,y=0) が
.Tn VAX
で
.if n \
(r=0,theta=0)
.if t \
(r=0,\(*h=0)
にマップされるときです。
一般に、極座標への変換は次のようにして計算する必要があります。
.Bd -unfilled -offset indent
.if n \{\
r	:= hypot(x,y); ... := sqrt(x\(**x+y\(**y)
theta   := atan2(y,x)
.\}
.if t \{\
r	:= hypot(x,y); ... := \(sr(x\u\s82\s10\d+y\u\s82\s10\d)
theta   := atan2(y,x)
.\}
.\"XX .XX sqrt x*x+y*y
.Ed
.It
上記の公式は、
.Tn IEEE 754
に準拠するマシンでは符号付きのゼロおよび無限に、
合理的な方法で、対処しようと変更する必要はありません。そのようなマシン用に
準備された
.Xr hypot 3
と
.Fn atan2
のバージョンがすべてのケースを処理するよう
設計されています。これがたとえば
.Fn atan2 \(+-0 \-0
= \(+-\*(Pi
である理由です。一般に、
上記の公式は次のものと同等です。
.Bd -unfilled -offset indent
.if n \
r := sqrt(x\(**x+y\(**y); r =0 の場合は、x := copysign(1,x);
.if t \
r := \(sr(x\(**x+y\(**y);\0\0 r =0 の場合は、x := copysign(1,x);
.Ed
.El
.Sh 関連項目
.Xr acos 3 ,
.Xr asin 3 ,
.Xr atan 3 ,
.Xr cos 3 ,
.Xr cosh 3 ,
.Xr math 3 ,
.Xr sin 3 ,
.Xr sinh 3 ,
.Xr tan 3 ,
.Xr tanh 3
.Pp
.Sh 規格
.Fn atan2
関数は
.St -ansiC
に準拠しています。
.\"X kuma