/ *   
 
   *   P R O J E C T :   N y A R T o o l k i t C S ( E x t e n s i o n ) 
 
   *   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
   *   T h e   N y A R T o o l k i t C S   i s   J a v a   e d i t i o n   A R T o o l K i t   c l a s s   l i b r a r y . 
 
   *   C o p y r i g h t   ( C ) 2 0 0 8 - 2 0 0 9   R y o   I i z u k a 
 
   * 
 
   *   T h i s   p r o g r a m   i s   f r e e   s o f t w a r e :   y o u   c a n   r e d i s t r i b u t e   i t   a n d / o r   m o d i f y 
 
   *   i t   u n d e r   t h e   t e r m s   o f   t h e   G N U   G e n e r a l   P u b l i c   L i c e n s e   a s   p u b l i s h e d   b y 
 
   *   t h e   F r e e   S o f t w a r e   F o u n d a t i o n ,   e i t h e r   v e r s i o n   3   o f   t h e   L i c e n s e ,   o r 
 
   *   ( a t   y o u r   o p t i o n )   a n y   l a t e r   v e r s i o n . 
 
   *   
 
   *   T h i s   p r o g r a m   i s   d i s t r i b u t e d   i n   t h e   h o p e   t h a t   i t   w i l l   b e   u s e f u l , 
 
   *   b u t   W I T H O U T   A N Y   W A R R A N T Y ;   w i t h o u t   e v e n   t h e   i m p l i e d   w a r r a n t y   o f 
 
   *   M E R C H A N T A B I L I T Y   o r   F I T N E S S   F O R   A   P A R T I C U L A R   P U R P O S E .     S e e   t h e 
 
   *   G N U   G e n e r a l   P u b l i c   L i c e n s e   f o r   m o r e   d e t a i l s . 
 
   * 
 
   *   Y o u   s h o u l d   h a v e   r e c e i v e d   a   c o p y   o f   t h e   G N U   G e n e r a l   P u b l i c   L i c e n s e 
 
   *   a l o n g   w i t h   t h i s   p r o g r a m .     I f   n o t ,   s e e   < h t t p : / / w w w . g n u . o r g / l i c e n s e s / > . 
 
   *   
 
   *   F o r   f u r t h e r   i n f o r m a t i o n   p l e a s e   c o n t a c t . 
 
   * 	 h t t p : / / n y a t l a . j p / n y a t o o l k i t / 
 
   * 	 < a i r m a i l ( a t ) e b o n y . p l a l a . o r . j p >   o r   < n y a t l a ( a t ) n y a t l a . j p > 
 
   *   
 
   * / 
 
 u s i n g   S y s t e m ; 
 
 n a m e s p a c e   j p . n y a t l a . n y a r t o o l k i t . c s . c o r e 
 
 { 
 
 
 
 
 
         / * * 
 
           *   S0n0000k0o00pef[pe0pef[[pe0[W0~0Y00
 
           * / 
 
         p u b l i c   c l a s s   N y A R M a t h 
 
         { 
 
         	 p u b l i c   c o n s t   d o u b l e   D B L _ E P S I L O N = 2 . 2 2 0 4 4 6 0 4 9 2 5 0 3 1 3 1 e - 0 1 6 ; 
 
 
 
                 / * *   [pe$P04 0 ^ 2 * / 
 
                 p u b l i c   c o n s t   i n t   S Q _ 4 0   =   4 0   *   4 0 ; 
 
                 / * *   [pe$P02 0 ^ 2 * / 
 
                 p u b l i c   c o n s t   i n t   S Q _ 2 0   =   2 0   *   2 0 ; 
 
                 / * *   [pe$P01 0 ^ 2 * / 
 
                 p u b l i c   c o n s t   i n t   S Q _ 1 0   =   1 0   *   1 0 ; 
 
                 / * *   [pe$P08 ^ 2 * / 
 
                 p u b l i c   c o n s t   i n t   S Q _ 8   =   8   *   8 ; 
 
                 / * *   [pe$P05 ^ 2 * / 
 
                 p u b l i c   c o n s t   i n t   S Q _ 5   =   5   *   5 ; 
 
                 / * *   [pe$P02 ^ 2 * / 
 
                 p u b l i c   c o n s t   i n t   S Q _ 2   =   2   *   2 ; 
 
 
 
                 / * *   [pe$P0c o s ( 3 0 ) n0я<O$P* / 
 
                 p u b l i c   c o n s t   d o u b l e   C O S _ D E G _ 3 0   =   0 . 8 6 6 0 ; 
 
                 / * *   [pe$P0c o s ( 2 5 ) n0я<O$P* / 
 
                 p u b l i c   c o n s t   d o u b l e   C O S _ D E G _ 2 5   =   0 . 9 0 6 3 ; 
 
                 / * *   [pe$P0c o s ( 2 0 ) n0я<O$P* / 
 
                 p u b l i c   c o n s t   d o u b l e   C O S _ D E G _ 2 0   =   0 . 9 3 9 6 ; 
 
                 / * *   [pe$P0c o s ( 1 5 ) n0я<O$P* / 
 
                 p u b l i c   c o n s t   d o u b l e   C O S _ D E G _ 1 5   =   0 . 9 3 9 5 ; 
 
                 / * *   [pe$P0c o s ( 1 0 ) n0я<O$P* / 
 
                 p u b l i c   c o n s t   d o u b l e   C O S _ D E G _ 1 0   =   0 . 9 8 4 8 ; 
 
                 / * *   [pe$P0c o s ( 8 ) n0я<O$P* / 
 
                 p u b l i c   c o n s t   d o u b l e   C O S _ D E G _ 8   =   0 . 9 9 0 2 ; 
 
                 / * *   [pe$P0c o s ( 5 ) n0я<O$P* / 
 
                 p u b l i c   c o n s t   d o u b l e   C O S _ D E G _ 5   =   0 . 9 9 6 1 ; 
 
                 / * * 
 
                   *   S0n0peo00pp 1 h0pp 2 n0ݍn0NWN$P0ԏW0~0Y00
 
                   *   @ p a r a m   i _ p 1 x 
 
                   *   p1 n0X ^j
 
                   *   @ p a r a m   i _ p 1 y 
 
                   *   p1 n0Y ^j
 
                   *   @ p a r a m   i _ p 2 x 
 
                   *   p2 n0X ^j
 
                   *   @ p a r a m   i _ p 2 y 
 
                   *   p2 n0Y ^j
 
                   *   @ r e t u r n 
 
                   *   NWNݍ$P
 
                   * / 
 
                 p u b l i c   s t a t i c   d o u b l e   s q N o r m ( d o u b l e   i _ p 1 x ,   d o u b l e   i _ p 1 y ,   d o u b l e   i _ p 2 x ,   d o u b l e   i _ p 2 y ) 
 
                 { 
 
                         d o u b l e   x ,   y ; 
 
                         x   =   i _ p 2 x   -   i _ p 1 x ; 
 
                         y   =   i _ p 2 y   -   i _ p 1 y ; 
 
                         r e t u r n   x   *   x   +   y   *   y ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00p1 h0p2 n0ݍ$P0ԏW0~0Y00
 
                   *   @ p a r a m   i _ x 1 
 
                   *   p1 n0X ^j
 
                   *   @ p a r a m   i _ y 1 
 
                   *   p1 n0Y ^j
 
                   *   @ p a r a m   i _ x 2 
 
                   *   p2 n0X ^j
 
                   *   @ p a r a m   i _ y 2 
 
                   *   p2 n0Y ^j
 
                   *   @ r e t u r n 
 
                   *   ݍ$P
 
                   * / 
 
                 p u b l i c   s t a t i c   d o u b l e   d i s t ( d o u b l e   i _ x 1 ,   d o u b l e   i _ y 1 ,   d o u b l e   i _ x 2 ,   d o u b l e   i _ y 2 ) 
 
                 { 
 
                         r e t u r n   M a t h . S q r t ( i _ x 1   *   i _ y 1   +   i _ x 2   +   i _ y 2 ) ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo003 WN9h0Bl0~0Y00
 
                   *   QxQ  h t t p : / / a o k i 2 . s i . g u n m a - u . a c . j p / J a v a S c r i p t / s r c / 3 j i s i k i . h t m l 
 
                   *   @ p a r a m   i _ i n 
 
                   *   3 WN9h0Bl00pe$P
 
                   *   @ r e t u r n 
 
                   *   	NWN9hn0$P
 
                   * / 
 
                 p u b l i c   s t a t i c   d o u b l e   c u b e R o o t ( d o u b l e   i _ i n ) 
 
                 { 
 
                         d o u b l e   r e s   =   M a t h . P o w ( M a t h . A b s ( i _ i n ) ,   1 . 0   /   3 . 0 ) ; 
 
                         r e t u r n   ( i _ i n   > =   0 )   ?   r e s   :   - r e s ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00000000n0Ndlk0000 g'YlQ}pe0Bl0~0Y00
 
                   *   QxQ  h t t p : / / j a . w i k i p e d i a . o r g / w i k i / % E 3 % 8 3 % A 6 % E 3 % 8 3 % B C % E 3 % 8 2 % A F % E 3 % 8 3 % A A % E 3 % 8 3 % 8 3 % E 3 % 8 3 % 8 9 % E 3 % 8 1 % A E % E 4 % B A % 9 2 % E 9 % 9 9 % A 4 % E 6 % B 3 % 9 5 
 
                   *   @ p a r a m   i _ x 
 
                   *    g'YlQ}pe0Bl00pe1 
 
                   *   @ p a r a m   i _ y 
 
                   *    g'YlQ}pe0Bl00pe2 
 
                   *   @ r e t u r n 
 
                   *    g'YlQ}pe
 
                   * / 
 
                 p u b l i c   s t a t i c   i n t   g c d ( i n t   i _ x ,   i n t   i _ y ) 
 
                 { 
 
                         i n t   x   =   i _ x ; 
 
                         i n t   y   =   i _ y ; 
 
                         i n t   r ; 
 
                         w h i l e   ( y   ! =   0 ) 
 
                         { 
 
                                 r   =   x   %   y ; 
 
                                 x   =   y ; 
 
                                 y   =   r ; 
 
                         } 
 
                         r e t u r n   x ; 
 
                 } 
 
                 / / 	 / * * 
 
                 / / 	   *   <h
}$P00000h0W0f00ݍ▒0ԏW0~0Y00
 
                 / / 	   *   @ r e t u r n 
 
                 / / 	   * / 
 
                 / / 	 p u b l i c   s t a t i c   c o n s t   d o u b l e   d i s t ( N y A R D o u b l e P o i n t 2 d   i _ v e c ) 
 
                 / / 	 { 
 
                 / / 	 	 r e t u r n   M a t h . s q r t ( i _ v e c . x * i _ v e c . x + i _ v e c . y + i _ v e c . y ) ; 
 
                 / / 	 } 
 
                 / / 	 / * * 
 
                 / / 	   *   <h
}$P00000h0W0f00ݍ▒0ԏW0~0Y00
 
                 / / 	   *   @ r e t u r n 
 
                 / / 	   * / 
 
                 / / 	 p u b l i c   s t a t i c   c o n s t   d o u b l e   d i s t ( N y A R D o u b l e P o i n t 3 d   i _ v e c ) 
 
                 / / 	 { 
 
                 / / 	 	 r e t u r n   M a t h . s q r t ( i _ v e c . x * i _ v e c . x + i _ v e c . y * i _ v e c . y + i _ v e c . z * i _ v e c . z ) ; 
 
                 / / 	 } 
 
         } 
 
 } 