Check convexity of polygon

As we demonstrated in our previous post, we can generate polygons by tracing a circle around a given center and placing vertices at randomly spaced angles and radii.

MATLAB irregular polygon

While on visual inspection it should be clear whether some polygons are convex or concave, we want to find a way to check for this property mathematically. We will do so by checking the direction that each internal angle takes around the polygon, as by definition, convex polygons will have all internal angles of less than 180 degrees (additional rules include the fact that all diagonals are contained within the polygon and a line drawn through a convex polygon in any direction will intersect at exactly two points).

Continue reading

Creating 2-D polygons in MATLAB

The basic premise of computational geometry is to calculate distances, areas, intersections and other geometrical calculations on basic objects such as points, lines and polygons. To begin this series on computational geometry in MATLAB, we’ll discuss the creation of random polygons in MATLAB.

Continue reading

Caustic Art in MATLAB. New posts coming soon.

The Matlabgeeks team has been busy working on several interesting projects the last couple of years and have unfortunately been unable to post many updates. Here’s a quick look at one of these projects:

In late 2014, the Matlab Geeks created software that produces caustic art for Harry Sanderson, a fellow at Near Now, which is an art production company specializing in technological art in Nottingham, UK. Caustic art is the design of a surface that projects a desired image onto a screen from a light source. Here is an example of the final image generated using our scripts.

Caustics in MATLAB

Using CGAL, we created an optimal transport map (OTM) to find the most efficient mapping from a source image to a target image. Then, using MATLAB, we interpolated points on a triangular mesh of incident light rays to a target mesh using natural neighbor interpolation with the OTM. Next, we computed surface normal vectors that directed the light rays to the interpolated positions on the screen. Finally, we created a surface with these normal vectors via optimization using the Ceres framework by Google and saved the results as an STL mesh.

We have produced several pieces of caustic art for Harry Sanderson, which are being shown in art shows throughout Europe.

Much of the code was written in MATLAB and as the project used computational geometry, optimization and other interesting techniques extensively, we’ll try and tailor some upcoming posts on these topics.

Check back soon for new updates or feel free to contact us if you have more questions about this project or any projects you would like the Matlab Geeks team to work on.

A Blackjack GUI in Matlab – Part IV of using Guide

With this post we wrap up our introduction to using guide with a look at the usage of a push button and a drop-down menu in our creation of a blackjack strategy guide GUI. As a look back, or to catch up, you can visit our three previous posts: Part I: Creating the layout using guide; Part II: Setting up a table; and Part III: getting user input from radio buttons and text boxes. Finally, we have also attached all of the necessary code to the end of this post to do as you please.

Continue reading

Building GUIs in Matlab – Part III Utilizing User Input

In this post we will combine the ideas presented in part I and part II on building a GUI utilizing guide in Matlab. So far we have generated two graphical windows, one of which includes radio buttons, edittable text boxes, a drop-down menu, and a push button, and the second of which has a modifiable strategy table. The object now is to combine the two windows, and allow for proper user control of all of these components.
Continue reading

Building a GUI in Matlab – Part II Tables

Last week we looked at the usage of guide in building a GUI. We included radio buttons, both editable and static text boxes, a drop-down menu and a push button. This week, we’ll create our second GUI to display a table (uitable). As all the decisions in blackjack hinge on two pieces of information: 1) the face up card of the dealer; and 2) the player cards, a look-up table can provide an optimal method for making a simple informed choice of whether to hit, stand, split or double down.
Continue reading

Building a GUI in Matlab using Guide – Part I

Users crave the ability to use graphical user interfaces (GUIs) to perform tasks. While command line input can be beneficial and easier to implement (see our previous post on user inputs), error handling and decision making can be more intuitive through a GUI. Over the next several weeks, we’ll demonstrate the wonderful capabilities of Matlab in creating such GUIs. Using the Matlab built-in GUI building tool guide, we will build a functional program that takes in user inputs and displays useful information. In order to make this exercise fun, we’ll be creating a GUI that provides the optimum strategy for decision making in the game of blackjack.

Continue reading

Sending messages with sendmail

When running long code streams, waiting in front of the computer watching the program run can be excruciating. Sometimes I find myself doing this if I do not know how long the code will run, or if there will be errors returned. (I also sit in front of the computer because I enjoy watching cat gifs and the old school de-fragmentation screens, so who knows…) But you don’t have to! Go out and accomplish something else while your computer chugs away. With the useful command sendmail, we can send messages to our email or phone with some simple commands. Through this post, I’ll share some sample .m files that we commonly use to notify ourselves of code completion or errors.

Continue reading