Class: OpenCV::CvPoint2D32f
- Inherits:
-
Object
- Object
- OpenCV::CvPoint2D32f
- Defined in:
- ext/opencv/cvpoint2d32f.cpp,
ext/opencv/cvpoint2d32f.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 CvPoint2D32f {
float x;
float y;
}
Direct Known Subclasses
Class Method Summary collapse
-
.combatible?(obj) ⇒ Boolean
Return compatibility to CvPoint2D32f.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Object
constructor
Create new 2D-coordinate, (x, y).
-
#to_ary ⇒ Array
(also: #to_a)
Return x and y by Array.
-
#to_s ⇒ "<OpenCV::CvSize2D32f:(self.x]
Return x and y by String.
-
#x ⇒ Object
Return parameter on x-axis.
-
#x=(val) ⇒ Object
Set x-axis parameter, return self.
-
#y ⇒ Object
Return parameter on y-axis.
-
#y=(val) ⇒ Object
Set y-axis parameter, return self.
Constructor Details
#new ⇒ Object #new(obj) ⇒ Object #new(x, y) ⇒ Object
Create new 2D-coordinate, (x, y).
new() is same as new(0.0, 0.0)
new(obj) is same as new(obj.x.to_f, obj.y.to_f)
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'ext/opencv/cvpoint2d32f.cpp', line 78
VALUE
rb_initialize(int argc, VALUE *argv, VALUE self)
{
CvPoint2D32f *self_ptr = CVPOINT2D32F(self);
switch (argc) {
case 0:
break;
case 1: {
CvPoint2D32f point = VALUE_TO_CVPOINT2D32F(argv[0]);
self_ptr->x = point.x;
self_ptr->y = point.y;
break;
}
case 2:
self_ptr->x = NUM2DBL(argv[0]);
self_ptr->y = NUM2DBL(argv[1]);
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 CvPoint2D32f. Return true if object have method #x and #y.
For example.
class MyPoint2D32f
def x
95.7
end
def y
70.2
end
end
mp = MyPoint2D32f.new
CvPoint2D32f.compatible?(mp) #=> true
CvPoint2D32f.new(mp) #=> same as CvPoint2D32f(95.7, 70.2)
53 54 55 56 57 |
# File 'ext/opencv/cvpoint2d32f.cpp', line 53
VALUE
rb_compatible_q(VALUE klass, VALUE object)
{
return (rb_respond_to(object, rb_intern("x")) && rb_respond_to(object, rb_intern("y"))) ? Qtrue : Qfalse;
}
|
Instance Method Details
#to_ary ⇒ Array Also known as: to_a
Return x and y by Array.
170 171 172 173 174 |
# File 'ext/opencv/cvpoint2d32f.cpp', line 170
VALUE
rb_to_ary(VALUE self)
{
return rb_ary_new3(2, rb_x(self), rb_y(self));
}
|
#to_s ⇒ "<OpenCV::CvSize2D32f:(self.x]
Return x and y by String.
152 153 154 155 156 157 158 159 160 161 162 |
# File 'ext/opencv/cvpoint2d32f.cpp', line 152
VALUE
rb_to_s(VALUE self)
{
const int i = 4;
VALUE str[i];
str[0] = rb_str_new2("<%s:(%g,%g)>");
str[1] = rb_str_new2(rb_class2name(CLASS_OF(self)));
str[2] = rb_x(self);
str[3] = rb_y(self);
return rb_f_sprintf(i, str);
}
|
#x ⇒ Object
Return parameter on x-axis.
105 106 107 108 109 |
# File 'ext/opencv/cvpoint2d32f.cpp', line 105
VALUE
rb_x(VALUE self)
{
return rb_float_new(CVPOINT2D32F(self)->x);
}
|
#x=(val) ⇒ Object
Set x-axis parameter, return self.
117 118 119 120 121 122 |
# File 'ext/opencv/cvpoint2d32f.cpp', line 117
VALUE
rb_set_x(VALUE self, VALUE x)
{
CVPOINT2D32F(self)->x = NUM2DBL(x);
return self;
}
|
#y ⇒ Object
Return parameter on y-axis.
127 128 129 130 131 |
# File 'ext/opencv/cvpoint2d32f.cpp', line 127
VALUE
rb_y(VALUE self)
{
return rb_float_new(CVPOINT2D32F(self)->y);
}
|
#y=(val) ⇒ Object
Set y-axis parameter, return self.
139 140 141 142 143 144 |
# File 'ext/opencv/cvpoint2d32f.cpp', line 139
VALUE
rb_set_y(VALUE self, VALUE y)
{
CVPOINT2D32F(self)->y = NUM2DBL(y);
return self;
}
|