/* call-seq: * Vector2.new() -> vector * Vector2.new([x,y]) -> vector * Vector2.new(vector) -> vector * Vector2.new(x,y) -> vector * * Create a new vector instance. */ static VALUE Vector2_Initialize( VALUE self, VALUE someArgs ) { long arrayLength = RARRAY_LEN( someArgs ); rb_iv_set( self, "@x", INT2NUM( 0 ) ); rb_iv_set( self, "@y", INT2NUM( 0 ) ); if( arrayLength == 0 ) { // Nothing needs to be done } else if( arrayLength == 1 ) { Vector2_internal_CopyFrom( self, rb_ary_entry( someArgs, 0 ) ); } else if( arrayLength == 2 ) { VALUE arg1 = rb_ary_entry( someArgs, 0 ); VALUE arg2 = rb_ary_entry( someArgs, 1 ); Vector2_internal_ValidateTypes( arg1, arg2 ); rb_iv_set( self, "@x", arg1 ); rb_iv_set( self, "@y", arg2 ); } rb_iv_set( self, "@dataType", CLASS_OF( rb_iv_get( self, "@x" ) ) ); return self; }