Friday, March 10, 2017

Prim's Algorithm Animation

For a given set of randomly distributed points in 2-dimensional space, we utilize the Prim's algorithm to find the minimum total distance from a randomly selected origin point (P_origin). The algorithm is written in C++, visualization is done via Python, video editing by Blender. Also, for those who want to run their algorithm for the same set of points in this video, you can download the input files here. Dropbox path:

 

Final minimum spanning tree snapshots for several random point distributions:



Sunday, February 19, 2017

Bent Waveguide


Here, we demonstrate the propagation through bent waveguides with different bending radii. The thickness of all waveguides are same and let's denote as "d" here. Then we have 3 cases where the radius of bending is d, 2d or 3d. With the smaller radius, the leakage from the bending is stronger compared to the other ones.

Estimating Pi

Here, we look at the Archimedes' method to calculate/estimate the Pi number where simpler polygons are used to find the area of a unit circle. The video is inspired from a talk given by MIT Professor John Guttag within MITx - 6.00.2x.


Wednesday, January 25, 2017

Simple remedy on CLANG error: no member named * in namespace *

Given the following code snippet in C++, when it is compiled with gcc, there is no issue. However, when compiled using the clang, then we see the following error:

Compilation:
clang++ -std=c++14 -pedantic -Wall  main.cpp

Output:
main.cpp:12:18: error: no member named 'runtime_error' in namespace 'std'
      throw std::runtime_error("Cannot find the input file...");
            ~~~~~^
1 error generated.

Code snippet given the above error with Clang.
#include <fstream>
#include <iostream>

using namespace std;

int main() {

   ifstream input;
   input.open("test.txt");

   if (!input.is_open()){
      throw std::runtime_error("Cannot find the input file...");
   }

   input.close();

   return 0;
}

This is because clang cannot find the header file. Either it should be included or simply telling clang which header file to look at solves the problem. In this particular example, including the header file where runtime_error() is defined which is the #include is good enough.