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.
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).
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.
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.
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.
This is the final post in our series on random numbers in Matlab. In the first post, we discussed basic random number functions, and in the second post, we discussed the control of random number generation in Matlab and alternatives for applications with stronger requirements. In this post, we will demonstrate how to create probability distributions with the basic rand and randn functions of Matlab. This is useful in many engineering applications, including reliability analysis and communications.
This is our second post in our series on random numbers in Matlab. The first post can be found here. In this post, I will explain how to control the random number generation functions in Matlab and discuss alternatives for projects with stronger requirements for randomness, such as cryptography.