First Coding Period Summary

Hi all,
I would like to share my experience through the first weeks of GSoC 2016 with GNU Octave.
My project is mainly concerned with computational geometry as it aims at creating 2D polygon functions as a part of the geometry package.
The main function is polybool which permits performing boolean operations on polygons.
The project’s bitbucket repository can be found here:
https://bitbucket.org/amr_keleg/octave-geometry


  • We started working on the project earlier than the program official start and were able to finish the first required functions for changing the representation of the polygons between cell arrays format and NaN-delimited vectors format.
    These two functions polyjoin/polysplit are implemented as .m files and are used to manipulate the polygons’s representation.
  • Then , we started implementing the ispolycw function that checks the orientation of multiple polygons at the same time using the Boost::Geometry library.
    For self-intersecting polygons, The orientation of the polygon is defined as the orientation of the leftmost point and its two neighbouring points.
  • A Makefile was written to compile and link the written cc files.
    The Makefile was inspired from the sockets package for Octave.
  • Currently, We are focusing on implementing the polybool and we managed to create an initial working version of the function.
    Here are some snapshots for the output of the polybool function:poly

    theta = linspace(0, 2 * pi, 1000);
    x1 = cos(theta) – 0.5;
    y1 = – sin(theta);
    x2 = x1 + 1;
    y2 = y1 + 1;

    figure(1)
    plot(x2, y2)
    [xa, ya] = polybool(‘union’, x1, y1, x2, y2);
    [xb, yb] = polybool(‘intersection’, x2, y2, x1, y1);
    [xc, yc] = polybool(‘xor’, x1, y1, x2, y2);
    [xd, yd] = polybool(‘subtraction’, x1, y1, x2, y2);
    subplot(2, 3, 1)
    axis equal
    patch(xa{1}, ya{1}, ‘FaceColor’, ‘r’)
    axis ([- 2 2 – 2 2])
    title(‘Union’)

    subplot(2, 3, 2)
    axis equal
    for k = 1:numel(xb), patch(xb{k}, yb{k}, ‘FaceColor’, ‘r’) end
    axis ([- 2 2 – 2 2])
    title(‘Intersection’)

    subplot(2, 3, 3)
    axis equal
    [x1 y1] = polysplit(x1, y1);
    for k = 1:numel(x1), patch(x1{k}, y1{k}, ‘FaceColor’, ‘b’), end
    axis ([- 2 2 – 2 2])
    title(‘Polygon 1’)

    subplot(2, 3, 4)
    axis equal
    for k = 1:numel(xc), patch(xc{k}, yc{k}, ‘FaceColor’, ‘r’) end
    axis ([- 2 2 – 2 2])
    title(‘Xor’)

    subplot(2, 3, 5)
    axis equal
    for k = 1:numel(xd), patch(xd{k}, yd{k}, ‘FaceColor’, ‘b’), end
    axis ([- 2 2 – 2 2])
    title(‘Difference’)

    subplot(2, 3, 6)
    axis equal
    [x2 y2] = polysplit(x2, y2);
    for k = 1:numel(x2), patch(x2{k}, y2{k}, ‘FaceColor’, ‘b’), end
    axis ([- 2 2 – 2 2])
    title(‘Polygon 2’)


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s