/ *   
 
   *   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   N y A R R e c t T a r g e t S t a t u s   :   N y A R T a r g e t S t a t u s 
 
         { 
 
 	         p r i v a t e   N y A R R e c t T a r g e t S t a t u s P o o l   _ r e f _ m y _ p o o l ; 
 
         	 
 
         	 
 
 	         / * * 
 
 	           *   s(Wn0wb_`1X
 
 	           * / 
 
 	         p u b l i c   N y A R D o u b l e P o i n t 2 d [ ]   v e r t e x = 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 ( 4 ) ; 
 
 
 
 	         / * * 
 
 	           *   N`W0_0p^n0NWN$Pn0T
 
 	           * / 
 
 	         p u b l i c   i n t   e s t i m a t e _ s u m _ s q _ v e r t e x _ v e l o c i t y _ a v e ; 
 
 
 
 	         / * * 
 
 	           *   N`p{V
 
 	           * / 
 
 	         p u b l i c   N y A R I n t R e c t   e s t i m a t e _ r e c t = n e w   N y A R I n t R e c t ( ) ; 
 
 	         / * * 
 
 	           *   N`pMOn
 
 	           * / 
 
 	         p u b l i c   N y A R D o u b l e P o i n t 2 d [ ]   e s t i m a t e _ v e r t e x = 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 ( 4 ) ; 
 
 
 
 	         / * * 
 
 	           *    g_k0O00_0iQ000n0$Pg0Y00D T _ x x x n0$P0h00~0Y00
 
 	           * / 
 
 	         p u b l i c   i n t   d e t e c t _ t y p e ; 
 
 	         / * * 
 
 	           *   Rgwb_iQg0iQ0[LW0_00
 
 	           * / 
 
 	         p u b l i c   c o n s t   i n t   D T _ S Q I N I T = 0 ; 
 
 	         / * * 
 
 	           *   [8^wb_iQg0iQ0[LW0_00
 
 	           * / 
 
 	         p u b l i c   c o n s t   i n t   D T _ S Q D A I L Y = 1 ; 
 
 	         / * * 
 
 	           *   [8^v}iQg0iQ0[LW0_00
 
 	           * / 
 
 	         p u b l i c   c o n s t   i n t   D T _ L I D A I L Y = 2 ; 
 
 	         / * * 
 
 	           *   0d0K00j0K0c0_000
 
 	           * / 
 
 	         p u b l i c   c o n s t   i n t   D T _ F A I L E D = - 1 ; 
 
         	 
 
 	         / / 
 
 	         / / 6R_
 
         	 
 
 	         / * * 
 
 	           *   @ O v e r r i d e 
 
 	           * / 
 
                 p u b l i c   N y A R R e c t T a r g e t S t a t u s ( N y A R R e c t T a r g e t S t a t u s P o o l   i _ p o o l ) 
 
                         :   b a s e ( i _ p o o l . _ o p _ i n t e r f a c e ) 
 
 	         { 
 
 	 	         t h i s . _ r e f _ m y _ p o o l = i _ p o o l ; 
 
 	 	         t h i s . d e t e c t _ t y p e = D T _ S Q I N I T ; 
 
 	         } 
 
 
 
 	         / * * 
 
 	           *   MRVn000000h0N`000000{W0f0000W0~0Y00
 
 	           *   @ p a r a m   i _ p r e v _ p a r a m 
 
 	           * / 
 
 	         p r i v a t e   v o i d   s e t E s t i m a t e P a r a m ( N y A R R e c t T a r g e t S t a t u s   i _ p r e v _ p a r a m ) 
 
 	         { 
 
 	 	         N y A R D o u b l e P o i n t 2 d [ ]   v c _ p t r = t h i s . v e r t e x ; 
 
 	 	         N y A R D o u b l e P o i n t 2 d [ ]   v e _ p t r = t h i s . e s t i m a t e _ v e r t e x ; 
 
 	 	         i n t   s u m _ o f _ v e r t e x _ s q _ d i s t = 0 ; 
 
 	 	         i f ( i _ p r e v _ p a r a m ! = n u l l ) { 
 
 	 	 	         / / ]R000000000
 
 	 	 	         N y A R D o u b l e P o i n t 2 d [ ]   v p = i _ p r e v _ p a r a m . v e r t e x ; 
 
 	 	 	         / / p^n0,n
 
 	 	 	         f o r ( i n t   i = 3 ; i > = 0 ; i - - ) { 
 
 	 	 	 	         i n t   x = ( i n t ) ( ( v c _ p t r [ i ] . x - v p [ i ] . x ) ) ; 
 
 	 	 	 	         i n t   y = ( i n t ) ( ( v c _ p t r [ i ] . y - v p [ i ] . y ) ) ; 
 
 	 	 	 	         / / N`MOn
 
 	 	 	 	         v e _ p t r [ i ] . x = ( i n t ) v c _ p t r [ i ] . x + x ; 
 
 	 	 	 	         v e _ p t r [ i ] . y = ( i n t ) v c _ p t r [ i ] . y + y ; 
 
 	 	 	 	         s u m _ o f _ v e r t e x _ s q _ d i s t + = x * x + y * y ; 
 
 	 	 	         } 
 
 	 	         } e l s e { 
 
 	 	 	         / / p^n00000
 
 	 	 	         f o r ( i n t   i = 3 ; i > = 0 ; i - - ) { 
 
 	 	 	 	         v e _ p t r [ i ] . x = ( i n t ) v c _ p t r [ i ] . x ; 
 
 	 	 	 	         v e _ p t r [ i ] . y = ( i n t ) v c _ p t r [ i ] . y ; 
 
 	 	 	         } 
 
 	 	         } 
 
 	 	         / / pN,nh0{VN,n
 
 	 	         t h i s . e s t i m a t e _ s u m _ s q _ v e r t e x _ v e l o c i t y _ a v e = s u m _ o f _ v e r t e x _ s q _ d i s t / 4 ; 
 
 	 	         t h i s . e s t i m a t e _ r e c t . s e t A r e a R e c t ( v e _ p t r , 4 ) ; 
 
         / / 	 	 t h i s . e s t i m a t e _ r e c t . c l i p ( i _ l e f t ,   i _ t o p ,   i _ r i g h t ,   i _ b o t t o m ) ; 
 
 	 	         r e t u r n ; 
 
 	         } 
 
         	 
 
 	         / * * 
 
 	           *   *`1X0CQk0wb_000000c[W00$P0000W0~0Y00
 
 	           *   S0n0peo00Qtn0bR1YWek000Z00Q[	Yf0LD0~0Y00
 
 	           *   @ p a r a m   i _ c o n t o u r _ s t a t u s 
 
 	           *   pe0[LY00h00S0n0000000n0Q[o04xXU00~0Y00
 
 	           *   @ r e t u r n 
 
 	           *   @ t h r o w s   N y A R E x c e p t i o n 
 
 	           * / 
 
                 p u b l i c   b o o l   s e t V a l u e W i t h I n i t i a l C h e c k ( N y A R C o n t o u r T a r g e t S t a t u s   i _ c o n t o u r _ s t a t u s ,   N y A R I n t R e c t   i _ s a m p l e _ a r e a ) 
 
 	         { 
 
 	 	         / / 0000n0000( 000Y00h0M0k003 , 4 aPeTn00000o01 , 2 aPn00000k0	YcY000) 
 
 	 	         i _ c o n t o u r _ s t a t u s . v e c p o s . l i m i t Q u a d r a n t T o 1 2 ( ) ; 
 
 	 	         t h i s . _ r e f _ m y _ p o o l . _ v e c p o s _ o p . m a r g e R e s e m b l e C o o r d s ( i _ c o n t o u r _ s t a t u s . v e c p o s ) ; 
 
 	 	         i f ( i _ c o n t o u r _ s t a t u s . v e c p o s . l e n g t h < 4 ) { 
 
 	 	 	         r e t u r n   f a l s e ; 
 
 	 	         } 
 
         	 	 
 
 	 	         / / 0000000S_
 
 	 	         i _ c o n t o u r _ s t a t u s . v e c p o s . g e t K e y C o o r d ( t h i s . _ r e f _ m y _ p o o l . _ i n d e x b u f ) ; 
 
 	 	         / / pk0	Yc
 
 	 	         N y A R D o u b l e P o i n t 2 d [ ]   t h i s _ v x = t h i s . v e r t e x ; 
 
 	 	         i f ( ! t h i s . _ r e f _ m y _ p o o l . _ l i n e _ d e t e c t . l i n e 2 S q u a r e V e r t e x ( t h i s . _ r e f _ m y _ p o o l . _ i n d e x b u f , t h i s _ v x ) ) { 
 
 	 	 	         r e t u r n   f a l s e ; 
 
 	 	         } 
 
         	 	 
 
         / / 	 	 / / pK00v}0Q{
 
         / / 	 	 f o r ( i n t   i = 3 ; i > = 0 ; i - - ) { 
 
         / / 	 	 	 t h i s _ s q . l i n e [ i ] . m a k e L i n e a r W i t h N o r m a l i z e ( t h i s _ s q . s q v e r t e x [ i ] , t h i s _ s q . s q v e r t e x [ ( i + 1 ) % 4 ] ) ; 
 
         / / 	 	 } 
 
 	 	         t h i s . s e t E s t i m a t e P a r a m ( n u l l ) ; 
 
 	 	         i f ( ! c h e c k I n i t i a l R e c t C o n d i t i o n ( i _ s a m p l e _ a r e a ) ) 
 
 	 	         { 
 
 	 	 	         r e t u r n   f a l s e ; 
 
 	 	         } 
 
 	 	         t h i s . d e t e c t _ t y p e = D T _ S Q I N I T ; 
 
 	 	         r e t u r n   t r u e ; 
 
 	         } 
 
 	         / * * 
 
 	           *   $P0000W0~0Y00S0n0peo00Qtn0bR1YWek000Z00Q[	Yf0LD0~0Y00
 
 	           *   @ p a r a m   i _ s a m p l e r _ i n 
 
 	           *   @ p a r a m   i _ s o u r c e 
 
 	           *   @ p a r a m   i _ p r e v _ s t a t u s 
 
 	           *   @ r e t u r n 
 
 	           *   @ t h r o w s   N y A R E x c e p t i o n 
 
 	           * / 
 
                 p u b l i c   b o o l   s e t V a l u e W i t h D e i l y C h e c k ( I N y A R V e c t o r R e a d e r   i _ v e c _ r e a d e r ,   L o w R e s o l u t i o n L a b e l i n g S a m p l e r O u t . I t e m   i _ s o u r c e ,   N y A R R e c t T a r g e t S t a t u s   i _ p r e v _ s t a t u s ) 
 
 	         { 
 
 	 	         V e c L i n e a r C o o r d i n a t e s   v e c p o s = t h i s . _ r e f _ m y _ p o o l . _ v e c p o s ; 
 
 	 	         / / *}0S0
 
 	 	         i f ( ! i _ v e c _ r e a d e r . t r a c e C o n t u r e ( i _ s o u r c e . l e b e l i n g _ t h , i _ s o u r c e . e n t r y _ p o s , v e c p o s ) ) { 
 
 	 	 	         r e t u r n   f a l s e ; 
 
 	 	         } 
 
 	 	         / / 3 , 4 aPeTn00000o01 , 2 aPn00000k0	YcY000
 
 	 	         v e c p o s . l i m i t Q u a d r a n t T o 1 2 ( ) ; 
 
 	 	         / / 0000n0000
 
 	 	         t h i s . _ r e f _ m y _ p o o l . _ v e c p o s _ o p . m a r g e R e s e m b l e C o o r d s ( v e c p o s ) ; 
 
 	 	         i f ( v e c p o s . l e n g t h < 4 ) { 
 
 	 	 	         r e t u r n   f a l s e ; 
 
 	 	         } 
 
 	 	         / / 0000000S_
 
 	 	         v e c p o s . g e t K e y C o o r d ( t h i s . _ r e f _ m y _ p o o l . _ i n d e x b u f ) ; 
 
 	 	         / / pk0	Yc
 
 	 	         N y A R D o u b l e P o i n t 2 d [ ]   t h i s _ v x = t h i s . v e r t e x ; 
 
 	 	         i f ( ! t h i s . _ r e f _ m y _ p o o l . _ l i n e _ d e t e c t . l i n e 2 S q u a r e V e r t e x ( t h i s . _ r e f _ m y _ p o o l . _ i n d e x b u f , t h i s _ v x ) ) { 
 
 	 	 	         r e t u r n   f a l s e ; 
 
 	 	         } 
 
 	 	         / / p&Ns0n0te
 
 	 	         r o t a t e V e r t e x L ( t h i s . v e r t e x , c h e c k V e r t e x S h i f t V a l u e ( i _ p r e v _ s t a t u s . v e r t e x , t h i s . v e r t e x ) ) ; 	 
 
 
 
 	 	         / / 00000000
 
 	 	         i f ( ! c h e c k D e i l y R e c t C o n d i t i o n ( i _ p r e v _ s t a t u s ) ) { 
 
 	 	 	         r e t u r n   f a l s e ; 
 
 	 	         } 
 
 	 	         / / !kVn0N,n
 
 	 	         s e t E s t i m a t e P a r a m ( i _ p r e v _ s t a t u s ) ; 
 
 	 	         r e t u r n   t r u e ; 
 
 	         } 
 
 	         / * * 
 
 	           *   *K00n0XSriQ
 
 	           *   @ p a r a m   i _ r a s t e r 
 
 	           *   @ p a r a m   i _ p r e v _ s t a t u s 
 
 	           *   @ r e t u r n 
 
 	           *   @ t h r o w s   N y A R E x c e p t i o n 
 
 	           * / 
 
                 p u b l i c   b o o l   s e t V a l u e B y L i n e L o g ( I N y A R V e c t o r R e a d e r   i _ v e c _ r e a d e r ,   N y A R R e c t T a r g e t S t a t u s   i _ p r e v _ s t a t u s ) 
 
 	         { 
 
 	 	         / / iQ{VK000000000n02 WN$P0{0iQWn0NWNݍn01 / ( 4 0 * 4 0 )   ( CQݍn01 / 4 0 ) 
 
 	 	         i n t   d = ( ( i n t ) i _ p r e v _ s t a t u s . e s t i m a t e _ r e c t . g e t D i a g o n a l S q D i s t ( ) / ( N y A R M a t h . S Q _ 4 0 ) ) ; 
 
 	 	         / / NWNyR^K0000000000{0
 
 	 	         i n t   v _ a v e _ l i m i t = i _ p r e v _ s t a t u s . e s t i m a t e _ s u m _ s q _ v e r t e x _ v e l o c i t y _ a v e ; 
 
 	 	         / / 
 
 	 	         i f ( v _ a v e _ l i m i t > d ) { 
 
 	 	 	         / / yR0000000000iQ{V0000n0{0F0L0'YM0K0c0_00000( RM0Y0N0) 
 
 	 	 	         r e t u r n   f a l s e ; 
 
 	 	         } 
 
 	 	         d = ( i n t ) M a t h . S q r t ( d ) ; 
 
 	 	         / /  gNOg002 `00m00
 
 	 	         i f ( d < 2 ) { 
 
 	 	 	         d = 2 ; 
 
 	 	         } 
 
 	 	         / /  g'Y0000000( 5 ) 0H004XTo05 k0Y000
 
 	 	         i f ( d > 5 ) { 
 
 	 	 	         d = 5 ; 
 
 	 	         } 
 
         	 	 
 
 	 	         / / 0000000n0fL
 
 
 
 	 	         N y A R L i n e a r [ ]   s h _ l = t h i s . _ r e f _ m y _ p o o l . _ l i n e ; 
 
 	 	         i f ( ! t r a c e S q u a r e L i n e ( i _ v e c _ r e a d e r , d , i _ p r e v _ s t a t u s , s h _ l ) ) { 
 
 	 	 	         r e t u r n   f a l s e ; 
 
 	 	         } e l s e { 
 
 	 	         } 
 
 	 	         / / 4 pbQ
 
 	 	         f o r ( i n t   i = 3 ; i > = 0 ; i - - ) { 
 
 	 	 	         i f ( ! s h _ l [ i ] . c r o s s P o s ( s h _ l [ ( i   +   3 )   %   4 ] , t h i s . v e r t e x [ i ] ) ) { 
 
 	 	 	 	         / / V҉L0\O0j0D00
 
 	 	 	 	         r e t u r n   f a l s e ; 
 
 	 	 	         } 
 
 	 	         } 	 	 
 
 
 
 	 	         / / p&Ns0n0te
 
 	 	         r o t a t e V e r t e x L ( t h i s . v e r t e x , c h e c k V e r t e x S h i f t V a l u e ( i _ p r e v _ s t a t u s . v e r t e x , t h i s . v e r t e x ) ) ; 	 
 
 	 	         / / ]R00000n0000
 
 	 	         s e t E s t i m a t e P a r a m ( i _ p r e v _ s t a t u s ) ; 
 
 	 	         r e t u r n   t r u e ; 
 
 	         } 
 
 	         / * * 
 
 	           *   rlk0_X0f0wb_xbKbl0R0fH0~0Y00
 
 	           *   @ p a r a m   i _ v e c _ r e a d e r 
 
 	           *   000000000n0W,g;uPk0000W0_0V e c t o r R e a d e r 
 
 	           *   @ p a r a m   i _ s o u r c e 
 
 	           *   000000000
 
 	           *   @ p a r a m   i _ p r e v _ s t a t u s 
 
 	           *   MRVn0rKa0<h
}W0_0000000
 
 	           *   @ r e t u r n 
 
 	           *   @ t h r o w s   N y A R E x c e p t i o n 
 
 	           * / 
 
                 p u b l i c   b o o l   s e t V a l u e B y A u t o S e l e c t ( I N y A R V e c t o r R e a d e r   i _ v e c _ r e a d e r ,   L o w R e s o l u t i o n L a b e l i n g S a m p l e r O u t . I t e m   i _ s o u r c e ,   N y A R R e c t T a r g e t S t a t u s   i _ p r e v _ s t a t u s ) 
 
 	         { 
 
 	 	         i n t   c u r r e n t _ d e t e c t _ t y p e = D T _ S Q D A I L Y ; 
 
 	 	         / / yR^k000Kbkn0R0fH0
 
 	 	         i n t   s q _ v _ a v e _ l i m i t = i _ p r e v _ s t a t u s . e s t i m a t e _ s u m _ s q _ v e r t e x _ v e l o c i t y _ a v e / 4 ; 
 
 	 	         / / ^L0\U0D0BfK00MRVL i n e L o g L0bRW0_0h0M0o0D T _ L I D A I L Y 
 
 	 	         i f ( ( ( s q _ v _ a v e _ l i m i t < 1 0 )   & &   ( i _ p r e v _ s t a t u s . d e t e c t _ t y p e = = D T _ S Q D A I L Y ) )   | |   ( i _ p r e v _ s t a t u s . d e t e c t _ t y p e = = D T _ L I D A I L Y ) ) { 
 
 	 	 	         c u r r e n t _ d e t e c t _ t y p e = D T _ L I D A I L Y ; 
 
 	 	         } 
 
         	 	 
 
 	 	         / / MRVn0R\O00k000Kbkn0R0fH0
 
 	 	         s w i t c h ( c u r r e n t _ d e t e c t _ t y p e ) 
 
 	 	         { 
 
 	 	         c a s e   D T _ L I D A I L Y : 
 
 	 	 	         / / L i n e L o g - > 
 
 	 	 	         i f ( s e t V a l u e B y L i n e L o g ( i _ v e c _ r e a d e r , i _ p r e v _ s t a t u s ) ) 
 
 	 	 	         { 
 
 	 	 	 	         / / F0~0O0D0c0_00
 
 	 	 	 	         t h i s . d e t e c t _ t y p e = D T _ L I D A I L Y ; 
 
 	 	 	 	         r e t u r n   t r u e ; 
 
 	 	 	         } 
 
 	 	 	         i f ( i _ s o u r c e ! = n u l l ) { 
 
 	 	 	 	         i f ( s e t V a l u e W i t h D e i l y C h e c k ( i _ v e c _ r e a d e r , i _ s o u r c e , i _ p r e v _ s t a t u s ) ) 
 
 	 	 	 	         { 
 
 	 	 	 	 	         / / F0~0O0D0c0_0
 
 	 	 	 	 	         t h i s . d e t e c t _ t y p e = D T _ S Q D A I L Y ; 
 
 	 	 	 	 	         r e t u r n   t r u e ; 
 
 	 	 	 	         } 
 
 	 	 	         } 
 
 	 	 	         b r e a k ; 
 
 	 	         c a s e   D T _ S Q D A I L Y : 
 
 	 	 	         i f ( i _ s o u r c e ! = n u l l ) { 
 
 	 	 	 	         i f ( s e t V a l u e W i t h D e i l y C h e c k ( i _ v e c _ r e a d e r , i _ s o u r c e , i _ p r e v _ s t a t u s ) ) 
 
 	 	 	 	         { 
 
 	 	 	 	 	         t h i s . d e t e c t _ t y p e = D T _ S Q D A I L Y ; 
 
 	 	 	 	 	         r e t u r n   t r u e ; 
 
 	 	 	 	         } 
 
 	 	 	         } 
 
 	 	 	         b r e a k ; 
 
 	 	         d e f a u l t : 
 
 	 	 	         b r e a k ; 
 
 	 	         } 
 
 	 	         / / MRVn0R\O000fM0cH0
 
 	 	         i _ p r e v _ s t a t u s . d e t e c t _ t y p e = D T _ F A I L E D ; 
 
 	 	         r e t u r n   f a l s e ; 
 
 	         } 
 
         	 
 
 
 
 	         / * * 
 
 	           *   S0n0000L0Rg0000( C o o r d K00R e c t x0n0wy) 000Y00K00000W0~0Y00
 
 	           *   agNo00
 
 	           *     1 . iQV҉b_n0[҉po0CQn0iQwb_QK0
 
 	           *     2 .  NjuwD0h0wD0n0ko000 . 1 ~ 1 0 n0{VK0
 
 	           *     3 . MOn
PwD00wD0L0wY0N0j0D0K0
 
 	           *   @ p a r a m   i _ s a m p l e _ a r e a 
 
 	           *   S0n0wb_0iQY00_00k0Oc0_0CQ000n0{V( 00000iQ{V) 
 
 	           * / 
 
                 p r i v a t e   b o o l   c h e c k I n i t i a l R e c t C o n d i t i o n ( N y A R I n t R e c t   i _ s a m p l e _ a r e a ) 
 
 	         { 
 
 	 	         N y A R D o u b l e P o i n t 2 d [ ]   t h i s _ v x = t h i s . v e r t e x ; 
 
 
 
 	 	         / / iQW0_0V҉b_n0[҉pL0iQ000QK0
 
 	 	         i n t   c x = ( i n t ) ( t h i s _ v x [ 0 ] . x + t h i s _ v x [ 1 ] . x + t h i s _ v x [ 2 ] . x + t h i s _ v x [ 3 ] . x ) / 4 ; 
 
 	 	         i n t   c y = ( i n t ) ( t h i s _ v x [ 0 ] . y + t h i s _ v x [ 1 ] . y + t h i s _ v x [ 2 ] . y + t h i s _ v x [ 3 ] . y ) / 4 ; 
 
 	 	         i f ( ! i _ s a m p l e _ a r e a . i s I n n e r P o i n t ( c x , c y ) ) { 
 
 	 	 	         r e t u r n   f a l s e ; 
 
 	 	         } 
 
 
 
         	 	 
 
 	 	         / /  NjuwD0h0wD0n0k0x( 1 0 
Pn0kL0B0c0_00j00K0	Y) 
 
 	 	         i n t   m a x   =   i n t . M i n V a l u e ; 
 
                         i n t   m i n   =   i n t . M a x V a l u e ; 
 
 	 	         f o r ( i n t   i = 0 ; i < 4 ; i + + ) { 
 
 	 	 	         i n t   t = ( i n t ) t h i s _ v x [ i ] . s q D i s t ( t h i s _ v x [ ( i + 1 ) % 4 ] ) ; 
 
 	 	 	         i f ( t > m a x ) { m a x = t ; } 
 
 	 	 	         i f ( t < m i n ) { m i n = t ; } 
 
 	 	         } 
 
 	 	         / / ksOpen0x
 
 	 	         i f ( m a x < ( 5 * 5 )   | | m i n < ( 5 * 5 ) ) { 
 
 	 	 	         r e t u r n   f a l s e ; 
 
 	 	         } 
 
 	 	         / / 1 0 
P0000n02 WN
 
 	 	         i f ( ( 1 0 * 1 0 ) * m i n / m a x < ( 3 * 3 ) ) { 
 
 	 	 	         r e t u r n   f a l s e ; 
 
 	 	         } 
 
 	 	         r e t u r n   t r u e ; 
 
 	         } 
 
 	         / * * 
 
 	           *   2 VvNMn0e\tk0Oc0_000000000
 
 	           *   agNo00
 
 	           *     1 .  NjuwD0h0wD0n0ko000 . 1 ~ 1 0 n0{VK0
 
 	           *     2 . MOn
PwD00wD0L0wY0N0j0D0K0
 
 	           *     3 . yRݍL0uizk0'YM0j00n0o0!qD0K0( Nn0irn03 
PRD0f0_00J0K0W0D0) 
 
 
 
 	           *   @ p a r a m   i _ s a m p l e _ a r e a 
 
 	           * / 
 
                 p r i v a t e   b o o l   c h e c k D e i l y R e c t C o n d i t i o n ( N y A R R e c t T a r g e t S t a t u s   i _ p r e v _ s t ) 
 
 	         { 
 
 	 	         N y A R D o u b l e P o i n t 2 d [ ]   t h i s _ v x = t h i s . v e r t e x ; 
 
 
 
 	 	         / /  NjuwD0h0wD0n0k0x( 1 0 
Pn0kL0B0c0_00j00K0	Y) 
 
 	 	         i n t   m a x = i n t . M i n V a l u e ; 
 
                         i n t   m i n   =   i n t . M a x V a l u e ; 
 
 	 	         f o r ( i n t   i = 0 ; i < 4 ; i + + ) { 
 
 	 	 	         i n t   t = ( i n t ) t h i s _ v x [ i ] . s q D i s t ( t h i s _ v x [ ( i + 1 ) % 4 ] ) ; 
 
 	 	 	         i f ( t > m a x ) { m a x = t ; } 
 
 	 	 	         i f ( t < m i n ) { m i n = t ; } 
 
 	 	         } 
 
 	 	         / / ksOpen0x
 
 	 	         i f ( m a x < ( 5 * 5 )   | | m i n < ( 5 * 5 ) ) { 
 
 	 	 	         r e t u r n   f a l s e ; 
 
 	 	         } 
 
 	 	         / / 1 0 
P0000n02 WN
 
 	 	         i f ( ( 1 0 * 1 0 ) * m i n / m a x < ( 3 * 3 ) ) { 
 
 	 	 	         r e t u r n   f a l s e ; 
 
 	 	         } 
 
 	 	         / / yRݍs^GW00'YM0O0eRW0_0pL0!qD0K0x
 
 	 	         r e t u r n   t h i s . _ r e f _ m y _ p o o l . c h e c k L a r g e D i f f ( t h i s _ v x , i _ p r e v _ s t . v e r t e x ) ; 
 
 	         } 
 
 
 
 	         / * * 
 
 	           *   N`MOn0Wnk0V҉b_00000W0f00 N[n0Wn0000Y00K00UOW0~0Y00
 
 	           *   @ p a r a m   i _ r e a d e r 
 
 	           *   @ p a r a m   i _ e d g e _ s i z e 
 
 	           *   @ p a r a m   i _ p r e v s q 
 
 	           *   @ r e t u r n 
 
 	           *   @ t h r o w s   N y A R E x c e p t i o n 
 
 	           * / 
 
                 p r i v a t e   b o o l   t r a c e S q u a r e L i n e ( I N y A R V e c t o r R e a d e r   i _ r e a d e r ,   i n t   i _ e d g e _ s i z e ,   N y A R R e c t T a r g e t S t a t u s   i _ p r e v s q ,   N y A R L i n e a r [ ]   o _ l i n e ) 
 
 	         { 
 
 	 	         N y A R D o u b l e P o i n t 2 d   p 1 , p 2 ; 
 
 	 	         V e c L i n e a r C o o r d i n a t e s   v e c p o s = t h i s . _ r e f _ m y _ p o o l . _ v e c p o s ; 
 
 	 	         / / N y A R I n t R e c t   i _ r e c t 
 
 	 	         p 1 = i _ p r e v s q . e s t i m a t e _ v e r t e x [ 0 ] ; 
 
 	 	         i n t   d i s t _ l i m i t = i _ e d g e _ s i z e * i _ e d g e _ s i z e ; 
 
 	 	         / / 7_^weE\$P( 00000- 1 ) 
 
         / / 	 	 i n t   m i n _ t h = i _ e d g e _ s i z e * 2 + 1 ; 
 
         / / 	 	 m i n _ t h = ( m i n _ t h * m i n _ t h ) ; 
 
 	 	         f o r ( i n t   i = 0 ; i < 4 ; i + + ) 
 
 	 	         { 
 
 	 	 	         p 2 = i _ p r e v s q . e s t i m a t e _ v e r t e x [ ( i + 1 ) % 4 ] ; 
 
         	 	 	 
 
 	 	 	         / / 0000NM0g0N`MOnhTn0v}n00000
 
 	 	 	         i _ r e a d e r . t r a c e L i n e W i t h C l i p ( p 1 , p 2 , i _ e d g e _ s i z e , v e c p o s ) ; 
 
 
 
 	 	 	         / / 0000000W0f00PM0n0яD000000cY00( PLuo01 0 ^) 
 
 	 	 	         t h i s . _ r e f _ m y _ p o o l . _ v e c p o s _ o p . m a r g e R e s e m b l e C o o r d s ( v e c p o s ) ; 
 
 	 	 	         / / W,gvk0o01 jug0K0D00000`00m00`0c0f00v}rk0S00`00n00
 
 
 
 	 	 	         i n t   v i d = v e c p o s . g e t M a x C o o r d I n d e x ( ) ; 
 
 	 	 	         / / 000Tꌏ6R( 7_^L0Y\7_O0j0D0h00) 
 
         / / 	 	 	 i f ( v e c p o s . i t e m s [ v i d ] . s q _ d i s t < ( m i n _ t h ) ) { 
 
         / / 	 	 	 	 r e t u r n   f a l s e ; 
 
         / / 	 	 	 } 
 
         / / @ t o d o : 0000te
 
 	 	 	         / / ҉^6R( CQn0}Rh0n0҉^0x) 
 
 	 	 	         i f ( v e c p o s . i t e m s [ v i d ] . g e t A b s V e c C o s ( i _ p r e v s q . v e r t e x [ i ] , i _ p r e v s q . v e r t e x [ ( i + 1 ) % 4 ] ) < N y A R M a t h . C O S _ D E G _ 5 ) { 
 
 	 	 	 	         / / S y s t e m . o u t . p r i n t l n ( " C O D E 1 " ) ; 
 
 	 	 	 	         r e t u r n   f a l s e ; 
 
 	 	 	         } 
 
         / / @ t o d o : 0000te
 
 	 	 	         / / N`pK00U0{0i0Y0f0D0j0D0pg0B00K00( iQpn0yRݍ▒0{Y000) 
 
 	 	 	         d o u b l e   d i s t ; 
 
 	 	 	         d i s t = v e c p o s . i t e m s [ v i d ] . s q D i s t B y S e g m e n t L i n e E d g e ( i _ p r e v s q . v e r t e x [ i ] , i _ p r e v s q . v e r t e x [ i ] ) ; 
 
 	 	 	         i f ( d i s t < d i s t _ l i m i t ) { 
 
 	 	 	 	         o _ l i n e [ i ] . s e t V e c t o r W i t h N o r m a l i z e ( v e c p o s . i t e m s [ v i d ] ) ; 
 
 	 	 	         } e l s e { 
 
 	 	 	 	         / / S y s t e m . o u t . p r i n t l n ( " C O D E 2 : " + d i s t + " , " + d i s t _ l i m i t ) ; 
 
 	 	 	 	         r e t u r n   f a l s e ; 
 
 	 	 	         } 
 
 	 	 	         / / p0000n0yR
 
 	 	 	         p 1 = p 2 ; 
 
 	 	         } 
 
 	 	         r e t u r n   t r u e ; 
 
 	         } 
 
                 / * * 
 
                   *   pTXn0ݍK000pn0000ϑ0ԏW0~0Y00S0n0peo000O0<O_0d0n0wb_n0pTXn0[_0S0_00k0O(uW0~0Y00
 
                   *   @ p a r a m   i _ s q u a r e 
 
                   *   k[an0wb_
 
                   *   @ r e t u r n 
 
                   *   000ϑ0pe$Pg0ԏW0~0Y00
 
                   *   000ϑo0t h i s - i _ s q u a r e g0Y001 n04XT0t h i s . s q v e r t e x [ 0 ] h0i _ s q u a r e . s q v e r t e x [ 1 ] L0[_pk0j00( s h i f t ϑ1 ) g0B00S0h00:yW0~0Y00
 
                   * / 
 
                 p r i v a t e   s t a t i c   i n t   c h e c k V e r t e x S h i f t V a l u e ( N y A R D o u b l e P o i n t 2 d [ ]   i _ v e r t e x 1 , N y A R D o u b l e P o i n t 2 d [ ]   i _ v e r t e x 2 ) 
 
                 { 
 
         	         D e b u g . A s s e r t ( i _ v e r t e x 1 . L e n g t h = = 4   & &   i _ v e r t e x 2 . L e n g t h = = 4 ) ; 
 
         	         / / 3 - 0 juv
 
         	         i n t   m i n _ d i s t = i n t . M a x V a l u e ; 
 
         	         i n t   m i n _ i n d e x = 0 ; 
 
         	         i n t   x d , y d ; 
 
         	         f o r ( i n t   i = 3 ; i > = 0 ; i - - ) { 
 
         	 	         i n t   d = 0 ; 
 
         	 	         f o r ( i n t   i 2 = 3 ; i 2 > = 0 ; i 2 - - ) { 
 
         	 	 	         x d =   ( i n t ) ( i _ v e r t e x 1 [ i 2 ] . x - i _ v e r t e x 2 [ ( i 2 + i ) % 4 ] . x ) ; 
 
         	 	 	         y d =   ( i n t ) ( i _ v e r t e x 1 [ i 2 ] . y - i _ v e r t e x 2 [ ( i 2 + i ) % 4 ] . y ) ; 
 
         	 	 	         d + = x d * x d + y d * y d ; 
 
         	 	         } 
 
         	 	         i f ( m i n _ d i s t > d ) { 
 
         	 	 	         m i n _ d i s t = d ; 
 
         	 	 	         m i n _ i n d e x = i ; 
 
         	 	         } 
 
         	         } 
 
         	         r e t u r n   m i n _ i n d e x ; 
 
                 } 
 
                 / * * 
 
                   *   4 h0n n0 g'YlQ}pe0000
 
                   * / 
 
                 p r i v a t e   s t a t i c   i n t [ ]   _ g c d _ t a b l e 4 = { - 1 , 1 , 2 , 1 } ; 
 
                 / * * 
 
                   *   p0]VW0f00wb_0VU0[0~0Y00
 
                   *   @ p a r a m   i _ s h i f t 
 
                   * / 
 
                 p r i v a t e   s t a t i c   v o i d   r o t a t e V e r t e x L ( N y A R D o u b l e P o i n t 2 d [ ]   i _ v e r t e x , i n t   i _ s h i f t ) 
 
                 { 
 
         	         D e b u g . A s s e r t ( i _ s h i f t < 4 ) ; 
 
         	         N y A R D o u b l e P o i n t 2 d   v e r t e x t ; 
 
         	         i f ( i _ s h i f t = = 0 ) { 
 
         	 	         r e t u r n ; 
 
         	         } 
 
         	         i n t   t 1 , t 2 ; 
 
         	         i n t   d ,   i ,   j ,   m k ; 
 
 	                 i n t   l l = 4 - i _ s h i f t ; 
 
 	                 d   =   _ g c d _ t a b l e 4 [ l l ] ; / / N y M a t h . g c n ( 4 , l l ) ; 
 
 	                 m k   =   ( 4 - l l )   %   4 ; 
 
 	                 f o r   ( i   =   0 ;   i   <   d ;   i + + )   { 
 
 	         	         v e r t e x t = i _ v e r t e x [ i ] ; 
 
 	                         f o r   ( j   =   1 ;   j   <   4 / d ;   j + + )   { 
 
 	                                 t 1 = ( i   +   ( j - 1 ) * m k )   %   4 ; 
 
 	                                 t 2 = ( i   +   j * m k )   %   4 ; 
 
 	                                 i _ v e r t e x [ t 1 ] = i _ v e r t e x [ t 2 ] ; 
 
 	                         } 
 
 	                         t 1 = ( i   +   l l )   %   4 ; 
 
 	                         i _ v e r t e x [ t 1 ] = v e r t e x t ; 
 
 	                 } 
 
                 } 
 
                 / * * 
 
                   *   A R T o o l K i t n0d i r e c t i o n 000k0_c0f00p0000W0~0Y00
 
                   *   @ p a r a m   i _ d i r 
 
                   * / 
 
                 p u b l i c   v o i d   s h i f t B y A r t k D i r e c t i o n ( i n t   i _ d i r ) 
 
                 { 
 
         	         r o t a t e V e r t e x L ( t h i s . e s t i m a t e _ v e r t e x , i _ d i r ) ; 
 
         	         r o t a t e V e r t e x L ( t h i s . v e r t e x , i _ d i r ) ; 
 
                 } 
 
         } 
 
 } 