Class: OpenCV::CvPoint3D32f

Inherits:
CvPoint2D32f show all
Defined in:
ext/opencv/cvpoint3d32f.cpp,
ext/opencv/cvpoint3d32f.cpp

Overview

This class means one point on X axis Y axis. X and Y takes the value of the Float. see also CvPoint

C structure is here, very simple.

typdef struct CvPoint3D32f {
  float x;
  float y;
  float z;
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#newObject #new(obj) ⇒ Object #new(x, y, z) ⇒ Object

Create new 3D-coordinate, (x, y, z).

new() is same as new(0.0, 0.0, 0.0)

new(obj) is same as new(obj.x.to_f, obj.y.to_f, obj.z.to_f)



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'ext/opencv/cvpoint3d32f.cpp', line 84

VALUE
rb_initialize(int argc, VALUE *argv, VALUE self)
{
  CvPoint3D32f *self_ptr = CVPOINT3D32F(self);
  switch (argc) {
  case 0:
    break;
  case 1: {
    CvPoint3D32f point = VALUE_TO_CVPOINT3D32F(argv[0]);
    self_ptr->x = point.x;
    self_ptr->y = point.y;
    self_ptr->z = point.z;
    break;
  }
  case 3:
    self_ptr->x = NUM2DBL(argv[0]);
    self_ptr->y = NUM2DBL(argv[1]);
    self_ptr->z = NUM2DBL(argv[2]);
    break;
  default:
    rb_raise(rb_eArgError, "wrong number of arguments (%d for 0..2)", argc);
    break;
  }
  return self;
}

Class Method Details

.combatible?(obj) ⇒ Boolean

Return compatibility to CvPoint3D32f. Return true if object have method #x and #y and #z.

For example.

class MyPoint3D32f
  def x
    95.7
  end
  def y
    70.2
  end
  def z
    10.0
  end
end
mp = MyPoint3D32f.new
CvPoint3D32f.compatible?(mp)  #=> true
CvPoint3D32f.new(mp)          #=> same as CvPoint3D32f(95.7, 70.2)

Returns:

  • (Boolean)


57
58
59
60
61
62
63
# File 'ext/opencv/cvpoint3d32f.cpp', line 57

VALUE
rb_compatible_q(VALUE klass, VALUE object)
{
  return (rb_respond_to(object, rb_intern("x")) &&
	  rb_respond_to(object, rb_intern("y")) &&
	  rb_respond_to(object, rb_intern("z"))) ? Qtrue : Qfalse;
}

Instance Method Details

#to_aryArray Also known as: to_a

Return x and y by Array.

Returns:

  • (Array)


201
202
203
204
205
# File 'ext/opencv/cvpoint3d32f.cpp', line 201

VALUE
rb_to_ary(VALUE self)
{
  return rb_ary_new3(3, rb_x(self), rb_y(self), rb_z(self));
}

#to_s"<OpenCV::CvSize3D32f:(self.x]

Return x and y by String.

Returns “<OpenCV::CvSize3D32f:(self.x].

Returns:

  • ("<OpenCV::CvSize3D32f:(self.x])

    “<OpenCV::CvSize3D32f:(self.x]



182
183
184
185
186
187
188
189
190
191
192
193
# File 'ext/opencv/cvpoint3d32f.cpp', line 182

VALUE
rb_to_s(VALUE self)
{
  const int i = 5;
  VALUE str[i];
  str[0] = rb_str_new2("<%s:(%g,%g,%g)>");
  str[1] = rb_str_new2(rb_class2name(CLASS_OF(self)));
  str[2] = rb_x(self);
  str[3] = rb_y(self);
  str[4] = rb_z(self);
  return rb_f_sprintf(i, str);
}

#xObject

Return parameter on x-axis.



113
114
115
116
117
# File 'ext/opencv/cvpoint3d32f.cpp', line 113

VALUE
rb_x(VALUE self)
{
  return rb_float_new(CVPOINT2D32F(self)->x);
}

#x=(val) ⇒ Object

Set x-axis parameter, return self.



125
126
127
128
129
130
# File 'ext/opencv/cvpoint3d32f.cpp', line 125

VALUE
rb_set_x(VALUE self, VALUE x)
{
  CVPOINT2D32F(self)->x = NUM2DBL(x);
  return self;
}

#yObject

Return parameter on y-axis.



135
136
137
138
139
# File 'ext/opencv/cvpoint3d32f.cpp', line 135

VALUE
rb_y(VALUE self)
{
  return rb_float_new(CVPOINT2D32F(self)->y);
}

#y=(val) ⇒ Object

Set y-axis parameter, return self.



147
148
149
150
151
152
# File 'ext/opencv/cvpoint3d32f.cpp', line 147

VALUE
rb_set_y(VALUE self, VALUE y)
{
  CVPOINT2D32F(self)->y = NUM2DBL(y);
  return self;
}

#zObject

Return parameter on z-axis.



157
158
159
160
161
# File 'ext/opencv/cvpoint3d32f.cpp', line 157

VALUE
rb_z(VALUE self)
{
  return rb_float_new(CVPOINT3D32F(self)->z);
}

#z=(val) ⇒ Object

Set z-axis parameter, return self.



169
170
171
172
173
174
# File 'ext/opencv/cvpoint3d32f.cpp', line 169

VALUE
rb_set_z(VALUE self, VALUE z)
{
  CVPOINT3D32F(self)->z = NUM2DBL(z);
  return self;
}