<s> import math <EOL> class Vector2 : <EOL> def __init__ ( self , x = <NUM_LIT:0> , y = <NUM_LIT:0> ) : <EOL> self . x = x <EOL> self . y = y <EOL> if hasattr ( x , "<STR_LIT>" ) : <EOL> x , y = x <EOL> self . _v = [ float ( x ) , float ( y ) ] <EOL> else : <EOL> self . _v = [ float ( x ) , float ( y ) ] <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( self . x , self . y ) <EOL> def from_points ( P1 , P2 ) : <EOL> return Vector2 ( P2 [ <NUM_LIT:0> ] - P1 [ <NUM_LIT:0> ] , P2 [ <NUM_LIT:1> ] - P1 [ <NUM_LIT:1> ] ) <EOL> def get_magnitude ( self ) : <EOL> return math . sqrt ( self . x ** <NUM_LIT:2> + self . y ** <NUM_LIT:2> ) <EOL> def normalize ( self ) : <EOL> magnitude = self . get_magnitude ( ) <EOL> self . x /= magnitude <EOL> self . y /= magnitude <EOL> def __add__ ( self , rhs ) : <EOL> return Vector2 ( self . x + rhs . x , self . y + rhs . y ) <EOL> def __sub__ ( self , rhs ) : <EOL> return Vector2 ( self . x - rhs . x , self . y - rhs . y ) <EOL> def __neg__ ( self ) : <EOL> return Vector2 ( - self . x , - self . y ) <EOL> def __mul__ ( self , scalar ) : <EOL> return Vector2 ( self . x * scalar , self . y * scalar ) <EOL> def __truediv__ ( self , scalar ) : <EOL> return Vector2 ( self . x / scalar , self . y / scalar ) <EOL> def __getitem__ ( self , index ) : <EOL> return self . _v [ index ] <EOL> def __setitem__ ( self , index , value ) : <EOL> self . _v [ index ] = <NUM_LIT:1.0> * value <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> A = ( <NUM_LIT> , <NUM_LIT> ) <EOL> B = ( <NUM_LIT> , <NUM_LIT> ) <EOL> AB = Vector2 . from_points ( A , B ) <EOL> step = AB * <NUM_LIT> <EOL> position = Vector2 ( * A ) <EOL> for n in range ( <NUM_LIT:10> ) : <EOL> position += step <EOL> print ( position ) </s>
