/ *   
 
   *   P R O J E C T :   N y A R T o o l k i t C S 
 
   *   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
   *   T h i s   w o r k   i s   b a s e d   o n   t h e   o r i g i n a l   A R T o o l K i t   d e v e l o p e d   b y 
 
   *       H i r o k a z u   K a t o 
 
   *       M a r k   B i l l i n g h u r s t 
 
   *       H I T L a b ,   U n i v e r s i t y   o f   W a s h i n g t o n ,   S e a t t l e 
 
   *   h t t p : / / w w w . h i t l . w a s h i n g t o n . e d u / a r t o o l k i t / 
 
   * 
 
   *   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 > 
 
   *   
 
   * / 
 
 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 
 
 { 
 
 
 
 
 
         / * * 
 
           *   S0n0000o0000Wg0Y00
 
           *   !kCQn0nmR\pep^j0<h
}W0~0Y00
 
           * / 
 
         p u b l i c   c l a s s   N y A R D o u b l e P o i n t 2 d 
 
         { 
 
                 / * *   X ^jn0$Pg0Y00* / 
 
                 p u b l i c   d o u b l e   x ; 
 
                 / * *   Y ^jn0$Pg0Y00* / 
 
                 p u b l i c   d o u b l e   y ; 
 
                 / * * 
 
                   *   S0n0peo00000000n0 N!kCQMR0\O0~0Y00
 
                   *   @ p a r a m   i _ n u m b e r 
 
                   *   \ObY00MRn0wU0
 
                   *   @ r e t u r n 
 
                   *   eW0D0MR0
 
                   * / 
 
                 p u b l i c   s t a t i c   N y A R D o u b l e P o i n t 2 d [ ]   c r e a t e A r r a y ( i n t   i _ n u m b e r ) 
 
                 { 
 
                         N y A R D o u b l e P o i n t 2 d [ ]   r e t   =   n e w   N y A R D o u b l e P o i n t 2 d [ i _ n u m b e r ] ; 
 
                         f o r   ( i n t   i   =   0 ;   i   <   i _ n u m b e r ;   i + + ) 
 
                         { 
 
                                 r e t [ i ]   =   n e w   N y A R D o u b l e P o i n t 2 d ( ) ; 
 
                         } 
 
                         r e t u r n   r e t ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00000000n0N!kCQMR0\O0~0Y00
 
                   *   @ p a r a m   i _ l e n g t h _ x 
 
                   *   \ObY00MRn0Rpe
 
                   *   @ p a r a m   i _ l e n g t h _ y 
 
                   *   \ObY00MRn0Lpe
 
                   *   @ r e t u r n 
 
                   *   eW0D0MR0
 
                   * / 
 
                 p u b l i c   s t a t i c   N y A R D o u b l e P o i n t 2 d [ ] [ ]   c r e a t e 2 d A r r a y ( i n t   i _ l e n g t h _ x ,   i n t   i _ l e n g t h _ y ) 
 
                 { 
 
                         N y A R D o u b l e P o i n t 2 d [ ] [ ]   r e t   =   n e w   N y A R D o u b l e P o i n t 2 d [ i _ l e n g t h _ y ] [ ] ; 
 
                         f o r   ( i n t   i   =   0 ;   i   <   i _ l e n g t h _ y ;   i + + ) 
 
                         { 
 
                                 r e t [ i ]   =   n e w   N y A R D o u b l e P o i n t 2 d [ i _ l e n g t h _ x ] ; 
 
                                 f o r   ( i n t   i 2   =   0 ;   i 2   <   i _ l e n g t h _ x ;   i 2 + + ) 
 
                                 { 
 
                                         r e t [ i ] [ i 2 ]   =   n e w   N y A R D o u b l e P o i n t 2 d ( ) ; 
 
                                 } 
 
                         } 
 
                         r e t u r n   r e t ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00pg0[U000v}K000YMz0{W0~0Y00
 
                   *   YMzo00p 1 - > p 2 h00p 2 - > p 3 g0[Y00v}n0YMzg0Y00
 
                   *   @ p a r a m   p 1 
 
                   *   p
 
                   *   @ p a r a m   p 2 
 
                   *   p
 
                   *   @ p a r a m   p 3 
 
                   *   p
 
                   *   @ r e t u r n 
 
                   *   YMzn0$P
 
                   * / 
 
                 p u b l i c   s t a t i c   d o u b l e   c r o s s P r o d u c t 3 P o i n t ( N y A R D o u b l e P o i n t 2 d   p 1 ,   N y A R D o u b l e P o i n t 2 d   p 2 ,   N y A R D o u b l e P o i n t 2 d   p 3 ) 
 
                 { 
 
                         r e t u r n   ( p 2 . x   -   p 1 . x )   *   ( p 3 . y   -   p 2 . y )   -   ( p 2 . y   -   p 1 . y )   *   ( p 3 . x   -   p 2 . x ) ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00pg0[U000v}K000YMz0{W0~0Y00
 
                   *   YMzo00p 1 - > p 2 h00p 2 - > p 3 g0[Y00v}n0YMzg0Y00
 
                   *   @ p a r a m   p 1 
 
                   *   p1 
 
                   *   @ p a r a m   p 2 
 
                   *   p2 
 
                   *   @ p a r a m   p 3 _ x 
 
                   *   p3 n0^j( X ) 
 
                   *   @ p a r a m   p 3 _ y 
 
                   *   p3 n0^j( Y ) 
 
                   *   @ r e t u r n 
 
                   *   YMzn0$P
 
                   * / 
 
                 p u b l i c   s t a t i c   d o u b l e   c r o s s P r o d u c t 3 P o i n t ( N y A R D o u b l e P o i n t 2 d   p 1 ,   N y A R D o u b l e P o i n t 2 d   p 2 ,   d o u b l e   p 3 _ x ,   d o u b l e   p 3 _ y ) 
 
                 { 
 
                         r e t u r n   ( p 2 . x   -   p 1 . x )   *   ( p 3 _ y   -   p 2 . y )   -   ( p 2 . y   -   p 1 . y )   *   ( p 3 _ x   -   p 2 . x ) ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00pƖTK000-N.Y$P( p [ n ] / n ) 0Bl0~0Y00
 
                   *   @ p a r a m   i _ p o i n t s 
 
                   *   pƖT0<h
}W0_0MRg0Y00
 
                   *   @ p a r a m   i _ n u m b e r _ o f _ d a t a 
 
                   *   MR-Nn0	gRj0ppeg0Y00
 
                   *   @ p a r a m   o _ o u t 
 
                   *   -N.Y$P0SQ0S0000000g0Y00
 
                   * / 
 
                 p u b l i c   s t a t i c   v o i d   m a k e C e n t e r ( N y A R D o u b l e P o i n t 2 d [ ]   i _ p o i n t s ,   i n t   i _ n u m b e r _ o f _ d a t a ,   N y A R D o u b l e P o i n t 2 d   o _ o u t ) 
 
                 { 
 
                         d o u b l e   x ,   y ; 
 
                         x   =   y   =   0 ; 
 
                         f o r   ( i n t   i   =   i _ n u m b e r _ o f _ d a t a   -   1 ;   i   > =   0 ;   i - - ) 
 
                         { 
 
                                 x   + =   i _ p o i n t s [ i ] . x ; 
 
                                 y   + =   i _ p o i n t s [ i ] . y ; 
 
                         } 
 
                         o _ o u t . x   =   x   /   i _ n u m b e r _ o f _ d a t a ; 
 
                         o _ o u t . x   =   y   /   i _ n u m b e r _ o f _ d a t a ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00pƖTK000-N.Y$P( p [ n ] / n ) 0Bl0~0Y00
 
                   *   @ p a r a m   i _ p o i n t s 
 
                   *   pƖT0<h
}W0_0MRg0Y00
 
                   *   @ p a r a m   i _ n u m b e r _ o f _ d a t a 
 
                   *   MR-Nn0	gRj0ppeg0Y00
 
                   *   @ p a r a m   o _ o u t 
 
                   *   -N.Y$P0SQ0S0000000g0Y00
 
                   * / 
 
                 p u b l i c   s t a t i c   v o i d   m a k e C e n t e r ( N y A R D o u b l e P o i n t 2 d [ ]   i _ p o i n t s ,   i n t   i _ n u m b e r _ o f _ d a t a ,   N y A R I n t P o i n t 2 d   o _ o u t ) 
 
                 { 
 
                         d o u b l e   l x ,   l y ; 
 
                         l x   =   l y   =   0 ; 
 
                         f o r   ( i n t   i   =   i _ n u m b e r _ o f _ d a t a   -   1 ;   i   > =   0 ;   i - - ) 
 
                         { 
 
                                 l x   + =   i _ p o i n t s [ i ] . x ; 
 
                                 l y   + =   i _ p o i n t s [ i ] . y ; 
 
                         } 
 
                         o _ o u t . x   =   ( i n t ) ( l x   /   i _ n u m b e r _ o f _ d a t a ) ; 
 
                         o _ o u t . y   =   ( i n t ) ( l y   /   i _ n u m b e r _ o f _ d a t a ) ; 
 
                 } 
 
                 / * * 
 
                   *   0000000g0Y00
 
                   *   Rg$P0<h
}W0_00000000ubW0~0Y00
 
                   * / 
 
                 p u b l i c   N y A R D o u b l e P o i n t 2 d ( ) 
 
                 { 
 
                         t h i s . x   =   0 ; 
 
                         t h i s . y   =   0 ; 
 
                         r e t u r n ; 
 
                 } 
 
                 / * * 
 
                   *   0000000g0Y00
 
                   *   Rg$P0c[W0f00000000ubW0~0Y00
 
                   *   @ p a r a m   i _ x 
 
                   *   { @ l i n k   # x } n0Rg$P
 
                   *   @ p a r a m   i _ y 
 
                   *   { @ l i n k   # y } n0Rg$P
 
                   * / 
 
                 p u b l i c   N y A R D o u b l e P o i n t 2 d ( d o u b l e   i _ x ,   d o u b l e   i _ y ) 
 
                 { 
 
                         t h i s . x   =   i _ x ; 
 
                         t h i s . y   =   i _ y ; 
 
                         r e t u r n ; 
 
                 } 
 
                 / * * 
 
                   *   0000000g0Y00
 
                   *   i _ s r c n0$Pg0RgSW0_00000000ubW0~0Y00
 
                   *   @ p a r a m   i _ s r c 
 
                   *   Rg$Ph0Y00000000
 
                   * / 
 
                 p u b l i c   N y A R D o u b l e P o i n t 2 d ( N y A R D o u b l e P o i n t 2 d   i _ s r c ) 
 
                 { 
 
                         t h i s . x   =   i _ s r c . x ; 
 
                         t h i s . y   =   i _ s r c . y ; 
 
                         r e t u r n ; 
 
                 } 
 
                 / * * 
 
                   *   0000000g0Y00
 
                   *   i _ s r c n0$Pg0RgSW0_00000000ubW0~0Y00
 
                   *   @ p a r a m   i _ s r c 
 
                   *   Rg$Ph0Y00000000
 
                   * / 
 
                 p u b l i c   N y A R D o u b l e P o i n t 2 d ( N y A R I n t P o i n t 2 d   i _ s r c ) 
 
                 { 
 
                         t h i s . x   =   ( d o u b l e ) i _ s r c . x ; 
 
                         t h i s . y   =   ( d o u b l e ) i _ s r c . y ; 
 
                         r e t u r n ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00000000n0^jh00c[ph0n0ݍn0WN$P0ԏW0~0Y00
 
                   *   @ p a r a m   i _ p 1 
 
                   *   pn0^j
 
                   *   @ r e t u r n 
 
                   *   i _ p 1 h0n0ݍn0NWN$P
 
                   * / 
 
                 p u b l i c   d o u b l e   s q D i s t ( N y A R D o u b l e P o i n t 2 d   i _ p 1 ) 
 
                 { 
 
                         d o u b l e   x ,   y ; 
 
                         x   =   t h i s . x   -   i _ p 1 . x ; 
 
                         y   =   t h i s . y   -   i _ p 1 . y ; 
 
                         r e t u r n   x   *   x   +   y   *   y ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00000000n0^jh00c[ph0n0ݍn0WN$P0ԏW0~0Y00
 
                   *   @ p a r a m   i _ p 1 
 
                   *   pn0^j
 
                   *   @ r e t u r n 
 
                   *   i _ p 1 h0n0ݍn0NWN$P
 
                   * / 
 
                 p u b l i c   d o u b l e   s q D i s t ( N y A R I n t P o i n t 2 d   i _ p 1 ) 
 
                 { 
 
                         d o u b l e   x ,   y ; 
 
                         x   =   t h i s . x   -   i _ p 1 . x ; 
 
                         y   =   t h i s . y   -   i _ p 1 . y ; 
 
                         r e t u r n   x   *   x   +   y   *   y ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00000000K00000000k0$P0000W0~0Y00
 
                   *   @ p a r a m   i _ s r c 
 
                   *   000CQn00000000
 
                   * / 
 
                 p u b l i c   v o i d   s e t V a l u e ( N y A R D o u b l e P o i n t 2 d   i _ s r c ) 
 
                 { 
 
                         t h i s . x   =   i _ s r c . x ; 
 
                         t h i s . y   =   i _ s r c . y ; 
 
                         r e t u r n ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00000000K00000000k0$P0000W0~0Y00
 
                   *   @ p a r a m   i _ s r c 
 
                   *   000CQn00000000
 
                   * / 
 
                 p u b l i c   v o i d   s e t V a l u e ( N y A R I n t P o i n t 2 d   i _ s r c ) 
 
                 { 
 
                         t h i s . x   =   ( d o u b l e ) i _ s r c . x ; 
 
                         t h i s . y   =   ( d o u b l e ) i _ s r c . y ; 
 
                         r e t u r n ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00000000k0$P0000W0~0Y00
 
                   *   @ p a r a m   i _ x 
 
                   *   { @ l i n k   # x } k0000Y00$P
 
                   *   @ p a r a m   i _ y 
 
                   *   { @ l i n k   # y } k0000Y00$P
 
                   * / 
 
                 p u b l i c   v o i d   s e t V a l u e ( d o u b l e   i _ x ,   d o u b l e   i _ y ) 
 
                 { 
 
                         t h i s . x   =   i _ x ; 
 
                         t h i s . y   =   i _ y ; 
 
                         r e t u r n ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00p0yRW0~0Y00
 
                   *   @ p a r a m   i _ t x 
 
                   *   yRY00ݍx 
 
                   *   @ p a r a m   i _ t y 
 
                   *   yRY00ݍy 
 
                   * / 
 
                 p u b l i c   v o i d   t r a n s l a t e ( d o u b l e   i _ t x ,   d o u b l e   i _ t y ) 
 
                 { 
 
                         t h i s . x   + =   i _ t x ; 
 
                         t h i s . y   + =   i _ t y ; 
 
                 } 
 
 
 
         } 
 
 } 
 
 