Sending Vector3d

For my extension I am using Vector3d to create points for models.

        VALUE pt1;

	pt1 = rb_ary_new();
	rb_ary_push(pt1, INT2FIX(100));
	rb_ary_push(pt1, INT2FIX(0));
	rb_ary_push(pt1, INT2FIX(0));

	return pt1;

I can send an array no problem from c++ to ruby and create a point. I was wondering what is best way to send data from a Vector3d?

I was trying to it this way:

        Vector3d vector = Vector3d();
    	vector.mx = 100;
    	vector.my = 100;
    	vector.mz = 0;
    	
    	VALUE skp_vector, args[3];
    
    	args[0] = rb_float_new(vector.mx);
    	args[1] = rb_float_new(vector.my);
    	args[2] = rb_float_new(vector.mz);

        return skp_vector

But this did not work. Any thoughts?

Can you expand to what doesn’t work?

Oh! I see now. You are returning an uninitialized VALUE - skp_vector.
And you are defining a C array and assigning float VALUE objects to them.

You need to create the Ruby array in the same way you do in your first code snippet.

Vector3d vector = Vector3d();
vector.mx = 100;
vector.my = 100;
vector.mz = 0;

VALUE skp_vector = rb_ary_new();
rb_ary_push(skp_vector, rb_float_new(vector.mx));
rb_ary_push(skp_vector, rb_float_new(vector.my));
rb_ary_push(skp_vector, rb_float_new(vector.mz));
return skp_vector;