Class: TG::Geometry::Ring

Inherits:
Object
  • Object
show all
Defined in:
ext/tg_geometry/tg_geometry_ext.c

Instance Method Summary collapse

Instance Method Details

#areaObject



1861
1862
1863
1864
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1861

static VALUE rb_tg_geometry_ring_area(VALUE self) {
    tg_ring_wrapper_t *w = get_ring_wrapper(self);
    return rb_float_new(tg_ring_area(w->ring));
}

#bboxObject



1801
1802
1803
1804
1805
1806
1807
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1801

static VALUE rb_tg_geometry_ring_bbox(VALUE self) {
    tg_ring_wrapper_t *w = get_ring_wrapper(self);
    VALUE rect = rect_from_tg_rect(tg_ring_rect(w->ring));

    RB_GC_GUARD(self);
    return rect;
}

#clockwise?Boolean

Returns:

  • (Boolean)


1871
1872
1873
1874
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1871

static VALUE rb_tg_geometry_ring_clockwise_p(VALUE self) {
    tg_ring_wrapper_t *w = get_ring_wrapper(self);
    return tg_ring_clockwise(w->ring) ? Qtrue : Qfalse;
}

#convex?Boolean

Returns:

  • (Boolean)


1876
1877
1878
1879
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1876

static VALUE rb_tg_geometry_ring_convex_p(VALUE self) {
    tg_ring_wrapper_t *w = get_ring_wrapper(self);
    return tg_ring_convex(w->ring) ? Qtrue : Qfalse;
}

#num_pointsObject



1809
1810
1811
1812
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1809

static VALUE rb_tg_geometry_ring_num_points(VALUE self) {
    tg_ring_wrapper_t *w = get_ring_wrapper(self);
    return INT2NUM(tg_ring_num_points(w->ring));
}

#num_segmentsObject



1835
1836
1837
1838
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1835

static VALUE rb_tg_geometry_ring_num_segments(VALUE self) {
    tg_ring_wrapper_t *w = get_ring_wrapper(self);
    return INT2NUM(tg_ring_num_segments(w->ring));
}

#perimeterObject



1866
1867
1868
1869
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1866

static VALUE rb_tg_geometry_ring_perimeter(VALUE self) {
    tg_ring_wrapper_t *w = get_ring_wrapper(self);
    return rb_float_new(tg_ring_perimeter(w->ring));
}

#point_at(index_value) ⇒ Object



1814
1815
1816
1817
1818
1819
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1814

static VALUE rb_tg_geometry_ring_point_at(VALUE self, VALUE index_value) {
    tg_ring_wrapper_t *w = get_ring_wrapper(self);
    int index = checked_child_index(index_value, tg_ring_num_points(w->ring), "ring point");

    return point_array_from_tg_point(tg_ring_point_at(w->ring, index));
}

#pointsObject



1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1821

static VALUE rb_tg_geometry_ring_points(VALUE self) {
    tg_ring_wrapper_t *w = get_ring_wrapper(self);
    int count = tg_ring_num_points(w->ring);
    VALUE points = rb_ary_new_capa(count);

    for (int i = 0; i < count; i++) {
        rb_ary_push(points, point_array_from_tg_point(tg_ring_point_at(w->ring, i)));
    }

    RB_GC_GUARD(self);
    RB_GC_GUARD(points);
    return points;
}

#segment_at(index_value) ⇒ Object



1840
1841
1842
1843
1844
1845
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1840

static VALUE rb_tg_geometry_ring_segment_at(VALUE self, VALUE index_value) {
    tg_ring_wrapper_t *w = get_ring_wrapper(self);
    int index = checked_child_index(index_value, tg_ring_num_segments(w->ring), "ring segment");

    return segment_wrap_value(tg_ring_segment_at(w->ring, index));
}

#segmentsObject



1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1847

static VALUE rb_tg_geometry_ring_segments(VALUE self) {
    tg_ring_wrapper_t *w = get_ring_wrapper(self);
    int count = tg_ring_num_segments(w->ring);
    VALUE segments = rb_ary_new_capa(count);

    for (int i = 0; i < count; i++) {
        rb_ary_push(segments, segment_wrap_value(tg_ring_segment_at(w->ring, i)));
    }

    RB_GC_GUARD(self);
    RB_GC_GUARD(segments);
    return segments;
}