/ *   
 
   *   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   C #   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 ; 
 
 u s i n g   S y s t e m . D i a g n o s t i c s ; 
 
 u s i n g   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 ; 
 
 
 
 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 . r p f 
 
 { 
 
         p u b l i c   c l a s s   V e c L i n e a r C o o r d i n a t e s O p e r a t o r 
 
         { 
 
 	         / * * 
 
 	           *   m a r g e R e s e m b l e C o o r d s g0OF0ݍweE\$Pn0$Pg0Y00
 
 	           *   1[Y00( ( ݍ^ 2 ) * 2 ) 0c[W0~0Y00
 
 	           * / 
 
 	         p r i v a t e   c o n s t   i n t   _ S Q _ D I F F _ D O T _ T H = ( ( 1 0 * 1 0 )   *   2 ) ; 
 
 	         / * * 
 
 	           *   m a r g e R e s e m b l e C o o r d s g0OF0҉^weE\$Pn0$Pg0Y00
 
 	           *   C o s ( n ) n0$Pg0Y00
 
 	           * / 
 
 	         p r i v a t e   c o n s t   d o u b l e   _ S Q _ A N G _ T H = N y A R M a t h . C O S _ D E G _ 1 0 ; 
 
 
 
 	         / / 000
 
 	         p r i v a t e   N y A R L i n e a r   _ l 1   =   n e w   N y A R L i n e a r ( ) ; 
 
 	         p r i v a t e   N y A R L i n e a r   _ l 2   =   n e w   N y A R L i n e a r ( ) ; 
 
 	         p r i v a t e   N y A R D o u b l e P o i n t 2 d   _ p   =   n e w   N y A R D o u b l e P o i n t 2 d ( ) ; 
 
         	 
 
 	         / * * 
 
 	           *   MRn0MRek00<O_000000Ɩ0~0Y00<O_00000n0$R[Wno002 }n0[pk0J0Q00v}n0l}
Ng0n0ݍn0NWNTg0Y00
 
 	           *   0000n0q}Th0MOn`1Xn0{k0o00R͑s^GW0(uD0~0Y00
 
 	           *   @ p a r a m   i _ v e c t o r 
 
 	           *   }ƖY000000000c[W0~0Y00
 
 	           * / 
 
 	         p u b l i c   v o i d   m a r g e R e s e m b l e C o o r d s ( V e c L i n e a r C o o r d i n a t e s   i _ v e c t o r ) 
 
 	         { 
 
 	 	         V e c L i n e a r C o o r d i n a t e s . V e c L i n e a r C o o r d i n a t e P o i n t [ ]   i t e m s = i _ v e c t o r . i t e m s ; 
 
 	 	         N y A R L i n e a r   l 1   =   t h i s . _ l 1 ; 
 
 	 	         N y A R L i n e a r   l 2   =   t h i s . _ l 2 ; 
 
 	 	         N y A R D o u b l e P o i n t 2 d   p   =   t h i s . _ p ; 
 
 
 
 
 
 	 	         f o r   ( i n t   i   =   i _ v e c t o r . l e n g t h   -   1 ;   i   > =   0 ;   i - - )   { 
 
 	 	 	         V e c L i n e a r C o o r d i n a t e s . V e c L i n e a r C o o r d i n a t e P o i n t   t a r g e t 1   =   i t e m s [ i ] ; 
 
 	 	 	         i f ( t a r g e t 1 . s c a l a r = = 0 ) { 
 
 	 	 	 	         c o n t i n u e ; 
 
 	 	 	         } 
 
 	 	 	         d o u b l e   r d x = t a r g e t 1 . d x ; 
 
 	 	 	         d o u b l e   r d y = t a r g e t 1 . d y ; 
 
 	 	 	         d o u b l e   r x = t a r g e t 1 . x ; 
 
 	 	 	         d o u b l e   r y = t a r g e t 1 . y ; 
 
 	 	 	         l 1 . s e t V e c t o r ( t a r g e t 1 ) ; 
 
 	 	 	         d o u b l e   s _ t m p = t a r g e t 1 . s c a l a r ; 
 
 	 	 	         t a r g e t 1 . d x * = s _ t m p ; 
 
 	 	 	         t a r g e t 1 . d y * = s _ t m p ; 
 
 	 	 	         t a r g e t 1 . x * = s _ t m p ; 
 
 	 	 	         t a r g e t 1 . y * = s _ t m p ; 
 
 	 	 	         f o r   ( i n t   i 2   =   i   -   1 ;   i 2   > =   0 ;   i 2 - - )   { 
 
 	 	 	 	         V e c L i n e a r C o o r d i n a t e s . V e c L i n e a r C o o r d i n a t e P o i n t   t a r g e t 2   =   i t e m s [ i 2 ] ; 
 
 	 	 	 	         i f ( t a r g e t 2 . s c a l a r = = 0 ) { 
 
 	 	 	 	 	         c o n t i n u e ; 
 
 	 	 	 	         } 
 
 	 	 	 	         i f   ( t a r g e t 2 . g e t V e c C o s ( r d x , r d y )   > = _ S Q _ A N G _ T H )   { 
 
 	 	 	 	 	         / /   ]00^00n0NhpK00l}0_D0f00vKbn0v}h0n0Np0{Y000
 
 	 	 	 	 	         l 2 . s e t V e c t o r ( t a r g e t 2 ) ; 
 
 	 	 	 	 	         l 1 . n o r m a l L i n e C r o s s P o s ( r x ,   r y , l 2 ,   p ) ; 
 
 	 	 	 	 	         d o u b l e   w x ,   w y ; 
 
 	 	 	 	 	         d o u b l e   l   =   0 ; 
 
 	 	 	 	 	         / /   Npn0ݍn0T0{0l k02 * d i s t ^ 2 0_00
 
 	 	 	 	 	         w x   =   ( p . x   -   r x ) ; 
 
 	 	 	 	 	         w y   =   ( p . y   -   r y ) ; 
 
 	 	 	 	 	         l   + =   w x   *   w x   +   w y   *   w y ; 
 
 	 	 	 	 	         l 2 . n o r m a l L i n e C r o s s P o s ( t a r g e t 2 . x ,   t a r g e t 2 . y , l 2 ,   p ) ; 
 
 	 	 	 	 	         w x   =   ( p . x   -   t a r g e t 2 . x ) ; 
 
 	 	 	 	 	         w y   =   ( p . y   -   t a r g e t 2 . y ) ; 
 
 	 	 	 	 	         l   + =   w x   *   w x   +   w y   *   w y ; 
 
 	 	 	 	 	         / /   ݍL0 N[$PNNj000000
 
 	 	 	 	 	         i f   ( l   >   _ S Q _ D I F F _ D O T _ T H )   { 
 
 	 	 	 	 	 	         c o n t i n u e ; 
 
 	 	 	 	 	         } 
 
 	 	 	 	 	         / /   <O_00F0j00000zvW0_000_en00000k0$P0q}T0
 
 	 	 	 	 	         s _ t m p =   t a r g e t 2 . s c a l a r ; 
 
 	 	 	 	 	         t a r g e t 1 . x + =   t a r g e t 2 . x * s _ t m p ; 
 
 	 	 	 	 	         t a r g e t 1 . y + =   t a r g e t 2 . y * s _ t m p ; 
 
 	 	 	 	 	         t a r g e t 1 . d x   + =   t a r g e t 2 . d x * s _ t m p ; 
 
 	 	 	 	 	         t a r g e t 1 . d y   + =   t a r g e t 2 . d y * s _ t m p ; 
 
 	 	 	 	 	         t a r g e t 1 . s c a l a r   + =   s _ t m p ; 
 
 	 	 	 	 	         / / 0j0D0P[0!qRSW0f0J0O00
 
 	 	 	 	 	         t a r g e t 2 . s c a l a r = 0 ; 
 
 	 	 	 	         } 
 
 	 	 	         } 
 
 	 	         } 
 
 	 	         / / MRep0
 
 	 	         i _ v e c t o r . r e m o v e Z e r o D i s t I t e m ( ) ; 
 
 	 	         / / R͑s^GWdj0F0( x , y MOnn00) 
 
 	 	         f o r ( i n t   i = 0 ; i < i _ v e c t o r . l e n g t h ; i + + ) 
 
 	 	         { 
 
 	 	 	         V e c L i n e a r C o o r d i n a t e s . V e c L i n e a r C o o r d i n a t e P o i n t   p t r = i t e m s [ i ] ; 
 
 	 	 	         d o u b l e   d = 1 / p t r . s c a l a r ; 
 
 	 	 	         p t r . x * = d ; 
 
 	 	 	         p t r . y * = d ; 
 
 	 	 	         p t r . d x * = d ; 
 
 	 	 	         p t r . d y * = d ; 
 
 	 	         } 
 
 	         } 
 
         } 
 
 } 