Class: TG::Geometry::Ring
- Inherits:
-
Object
- Object
- TG::Geometry::Ring
- Defined in:
- lib/tg/geometry.rb,
ext/tg_geometry/tg_geometry_ext.c
Instance Method Summary collapse
- #area ⇒ Object
- #bbox ⇒ Object
- #clockwise? ⇒ Boolean
- #convex? ⇒ Boolean
- #nearest_segment(x_value, y_value) ⇒ Object
- #num_points ⇒ Object
- #num_segments ⇒ Object
- #perimeter ⇒ Object
- #point_at(index_value) ⇒ Object
- #points ⇒ Object
- #segment_at(index_value) ⇒ Object
- #segments ⇒ Object
Instance Method Details
#area ⇒ Object
2607 2608 2609 2610 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 2607 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)); } |
#bbox ⇒ Object
2547 2548 2549 2550 2551 2552 2553 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 2547 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
2617 2618 2619 2620 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 2617 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
2622 2623 2624 2625 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 2622 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; } |
#nearest_segment(x_value, y_value) ⇒ Object
2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 2862 static VALUE rb_tg_geometry_ring_nearest_segment(VALUE self, VALUE x_value, VALUE y_value) { tg_ring_wrapper_t *w = get_ring_wrapper(self); tg_nearest_segment_ctx_t ctx; bool ok; ctx.query.x = NUM2DBL(x_value); ctx.query.y = NUM2DBL(y_value); check_finite_double(ctx.query.x, "x"); check_finite_double(ctx.query.y, "y"); ctx.best_index = -1; ctx.best_distance = INFINITY; ctx.found = false; ok = tg_ring_nearest_segment(w->ring, nearest_rect_distance, nearest_segment_distance, nearest_segment_iter, &ctx); if (!ok) { rb_raise(rb_eNoMemError, "nearest segment search failed"); } if (!ctx.found) { return Qnil; } RB_GC_GUARD(self); return nearest_segment_wrap_value(&ctx); } |
#num_points ⇒ Object
2555 2556 2557 2558 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 2555 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_segments ⇒ Object
2581 2582 2583 2584 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 2581 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)); } |
#perimeter ⇒ Object
2612 2613 2614 2615 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 2612 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
2560 2561 2562 2563 2564 2565 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 2560 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)); } |
#points ⇒ Object
2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 2567 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
2586 2587 2588 2589 2590 2591 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 2586 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)); } |
#segments ⇒ Object
2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 2593 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; } |