Colors of Bangladesh – in Joy and with Glory

People of Bangladesh are bit more enthusiast about their national colors and symbols of nationalist glory – partly because they are experiencing new wave of patriotism and partly because Bengali people are always enthusiast about good things; so am I. Yet, it happens to be true that, prescribed use of national color, flag and emblems are always not clear to everyone. Hence, on this post on the eve of Victory Day – a flag day of Bangladesh, I’m going to brief some points about our things.

National Colors

Although not legislatively established, it is generally held that green and red are the colors of Bangladesh because they are on the national flag. According to “People’s Republic of Bangladesh Flag Rules, 1972” (rev 2005):

The ‘National Flag’ will be in bottle green and rectangular in size in the proportion of length to width 10: 6 bearing a red circle on the body of the green.

followed by,

  • 3-I (a): The green base of the flag will be of Procion Brilliant Green H-2RS 50 parts per 1000.
  • 3-I (b): The red circular part will be of Procion Brilliant Orange H-2RS 60 parts per 1000.

As Procion (a brand of reactive colors) can not commonly be attained in digital media, common maps for these colors are:

Color as per Constitution

Color name in rule book

Color described (parts per 1000)

CMYK

Pantone

RGB (web color)

HSB

Green Bottle Green

Procion Brilliant Green H-2RS 50

100-0-70-40

Pantone 342c

#006a4e

165° 100% 45%

Red

Red

Procion Brilliant Orange H-2RS 60

0-100-80-5 No Pantone given #f42a41 351° 89% 88%

National flag has a construct as described:

  • 3-IV (a): When the length of the ‘Flag’ is 10′ its width will be 6′.
  • 3-IV (b): The radius of the red circle in the ‘Flag’ will be 2′.
  • 3-IV (c): Draw a perpendicular on 4½’ from the left hand of the length of the ‘Flag’ and a horizontal line from the middle of its width.
  • 3-IV (d): The Centre of the red circle will be at the point of intersection of these two lines.

800px-Bangladesh_National_Flag_construct.svg

Info: In the constitution, the flag is described as,

1-4 (2) The national flag of the Republic shall consist of a circle, coloured red throughout its area, resting on a green background.

With joy and love. “Victory of Bangladesh be fruitful with many more joy”.

Advertisements

Fix Delicious bookmark add-on problem with Firefox 4

Warning info_blue Major text on this post is copy pasted from someone else’s original post

Delicious bookmark add-on has long been my well-utilized tool in Firefox; but problem arose as I shifted from Fx3 to Fx4. This plug-in did not work and Firefox add-on manager displayed an warning saying, “Delicious Bookmarks add-on 2.2.106 is incompatible with Firefox 4.0”. I noticed the problem with earlier beta releases of Fx4 and hoped that this issue would be resolved before the release of the stable version, but it did not.

So, I googled and found some help text as quoted below:

  • From the menu of Firefox select Help > Troubleshooting information
  • On this new tab, near the top, you’ll see a field called Profile Directory. Click the button in the field to launch Finder (File Explorer for Windows)
  • In the window which has popped up navigate to the extensions folder.
  • Inside that should be another folder named “{2fa4ed95-0317-4c6a-a74c-5f3e3912c1f9}”.
  • Inside this is a file called install.rdf Open install.rdf in any plain text editor.
  • Around line 8 you should see some XML which looks like this:
    em:maxVersion=”4.0b3pre” />
  • Update this to:
    em:maxVersion=”5.0″ />

    (See we removed the changed the version?)
  • Save the file and restart Firefox.

The original post mentioned to change the version to 4.0 only by removing b3pre part. But, for updates of Firefox 4 it did not work properly. So, I changed it to 5.0 and started to use Delicious once again Smile

References:

Firefox address-bar search: restoring Google

Firefox is a nice browser, everyone agrees, and many of its default features are really cool. One of the cool features of it is the address bar. In default setting, when you do not put a valid address it uses the Google I’m feeling lucky search and it often redirects you to the web-page you really want to go.

Many Firefox plug-in tend to change this and set it to Yahoo! search or some other engine; in such case you might want to restore the original behavior. I suffered this problem, and the remedy is pretty simple.

Restore Google I’m feeling lucky in Firefox address-bar

resetFirefoxGoogle
  1. Open Firefox browser
  2. Type about:config in address bar and press enter
  3. Search for configuration key keyword.URL
  4. Right click on the configuration key keyword.URL and choose Reset from the shortcut menu.
  5. That’s all. From now onwards Firefox uses Google’s I’m Feeling Lucky when you type keywords in URL bar.

 

Other Search Engine Keys for Firefox

If you don’t  want to go back to Google and use some other engine instead you may find this list useful:

glut in MS Visual Studio 2010 (MSVS10)


One of my earlier blogs, OpenGL and glut in C++ with MS Visual Studio 2008 (MSVS9) described how to set up your Visual Studio and Computer to work with glut, as well as OpenGL. Now with the new edition, Microsoft Visual Studio 2010, as the version shifted from v6.0A to v7.0A, we need to change some path.So, here goes, what we need to do for using glut in MSVS10:

  • Download the original GLUT library from Nate Robins’ site
  • Unzip the download and copy files as instructed below,
    • glut.h to the folder C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include\gl\
    • glut32.lib to the folder C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib\
    • glut32.dll to the folder C:\Windows\System32\
  • You are now ready to use GLUT!

All other things remain same as described on http://wp.me/puVgg-j

happy gluting, nJoy!

OpenGL, Tree as a fractal, trigonometric Approach

Our goal is to,

  • Draw a tree using fractals with recursion
  • Take user input for:
    • Depth of tree/sub-trees
    • Angle between leftmost and rightmost branch in same depth

Fractals are useful way of approaching to infinity and for drawing some real life like objects where same pattern recurs. To do so, we are drawing single line and then recurring sub trees.

Recursive definition of such trees might be,

A tree is a line from root point to tree top point followed by two sub-trees, each having the root at the top of parent tree and own top at new calculated point.

The idea of Fractal tree is to build it from two initial points,

  • Root of tree p1(x1,y1)
  • Tree top p2(x2,y2)

1

Fig 1: Draw the basis of tree

We draw this part by,

glBegin(GL_LINE_STRIP);
glVertex2f(x1,y1);// root of tree glVertex2f(x2,y2);//tree top glEnd();

 

Now, we should find the two points for each of the sub-trees. To do so, let us first find a point p3 on the line p1p2. This will be done by changing the co-ordinate by placing new origin at p1 and multiplying x2 and y2 by the same multiplication factor. Hence, if the distance between p1 and p2 be l12 and if the multiplication factor is m then we need to get p3 at l23 distant from p1 such that

It is depicted below in figure 2

2 copy

Fig 2: Find point 3

This is done by the code segment shown below,

x3=(x2-x1)*treeRatio+x1, y3=(y2-y1)*treeRatio+y1;

 

After that, we can find the tree top points of the sub-trees, p’3right and p’3left by rotating p3 in y-axis with respect to p2 by θ angle (right sub-tree) and – θ angle (left sub-tree) as done by figure 3 and the pseudo code below,

3 copy Fig 3: Find the recurring points

x3=x3-x2; y3-=y2;
X’3right =  x3 * cos(angle) + y3 * sin(angle) + x2;
Y’3right = -x3 * sin(angle) + y3 * cos(angle) + y2;
X’3left =  x3 * cos(-angle) + y3 * sin(-angle) + x2;
Y’3left = -x3 * sin(-angle) + y3 * cos(-angle) + y2;

 

Now, we can recursively call the function for drawing sub-trees, by decreasing depth by one.

Figure 4 below depicts a right sub-tree being called4 copy

Fig 4: Recursive call to draw right sub-tree

The code segment below, includes the definition of this recursive function in action,

Listing A

 

void tree(GLfloat x1, GLfloat y1,        //root of tree GLfloat x2, GLfloat y2,    //tree top GLfloat angle,//angle/2 between outermost branches of same level GLint n                //depth of subtree )
{

    glBegin(GL_LINE_STRIP);
    glVertex2f(x1,y1);// root of tree glVertex2f(x2,y2);//tree top glEnd();
    if(n<1)return ;        //stop criteria of recursion int nn = n-1;        //decrement GLfloat        //find P3 by x3=(x2-x1)*treeRatio+x1-x2, //translating co-ordinate system to p1 y3=(y2-y1)*treeRatio+y1-y2; //then multiplying p2 by the factor //and position it back to real co-ord //right subtree tree(x2,        y2,
         x3 * cos(angle) + y3 * sin(angle) + x2,// P'3 -x3 * sin(angle) + y3 * cos(angle) + y2,// angle,nn,branchCount);
    //left subtree tree(x2,        y2,
         x3 * cos(-angle) + y3 * sin(-angle) + x2,// P'3 -x3 * sin(-angle) + y3 * cos(-angle) + y2,
        angle,nn,branchCount);
}

 

Enhanced Branches

If we want to use more than two sub-trees, we can do it by enhancing the function from listing A, as depicted in listing B. (Changes are highlighted)

Listing B
void tree(GLfloat x1, GLfloat y1,        //root of tree GLfloat x2, GLfloat y2,    //tree top GLfloat angle,//angle/2 between outermost branches of same level GLint n,        //depth of subtree GLint branchCount)        //number of sub-trees per level {

    glBegin(GL_LINE_STRIP);
    glVertex2f(x1,y1);// root of tree glVertex2f(x2,y2);//tree top glEnd();
    if(n<1)return ;        //stop criteria of recursion int nn = n-1;        //decrement GLfloat            //find P3 by x3=(x2-x1)*treeRatio+x1-x2, //translating co-ordinate system to p1 y3=(y2-y1)*treeRatio+y1-y2; //and then multiplying p2 by the factor //and position it back to real co-ord if(branchCount==2){
        //right subtree tree(x2,        y2,
             x3 * cos(angle) + y3 * sin(angle) + x2,// P'3 -x3 * sin(angle) + y3 * cos(angle) + y2,// angle,nn,branchCount);
        //left subtree tree(x2,        y2,
             x3 * cos(-angle) + y3 * sin(-angle) + x2,// P'3 -x3 * sin(-angle) + y3 * cos(-angle) + y2,
            angle,nn,branchCount);
    }
 else { GLfloat nowAngle = -angle; GLfloat angleTone = angle/(branchCount-1)*2; for(int i=0;i<branchCount;i++,nowAngle+=angleTone){ tree(x2, y2, x3 * cos(nowAngle) + y3 * sin(nowAngle) + x2, -x3 * sin(nowAngle) + y3 * cos(nowAngle) + y2, angle,nn,branchCount); } }
}

Many objects have self-similarity. A fractal is a rough or fragmented geometric shape that can be subdivided in parts, each of which is (at least approximately) a smaller copy of the whole. These fractals can be utilized to model such self-similar objects in computer graphics. Recursive functions can be nicely used to design fractals with its self-similar parts. Design of such objects depends on devising a recursion and thus care should be taken to limit the bound and base criteria should be evaluated nicely.

Thanks for your time with me 🙂

Randomizing the C++ Random function

In programming, we often need to use the random number generator. C++ also provide us with one function for the purpose, the rand(). Alright, it functions properly, I have nothing to blame it about, but one thing you might have noticed, it always generates the same sequence of random numbers, i.e. these are not really random numbers! This is because, any random function generates the random number using a function and based upon a seed, this seed for C++ is fixed. (Oh NO!, you are doomed, how could you get real random numbers!?)

Don’t get frustrated, you can seed the seed using srand(). Now, all you need to do is, just seed it right, (definitely, you shall chose the seed randomly).

I guess, the only thing surely be randomly chosen every time you execute the program is current time. So I prefer to use the time here.

Now, having the theory posed, let me post a code demonstrating the use of real random function generator…

#include <iostream>
#include <ctime>
using namespace std;

int random(int a_seed = 0){
  //type to hold calender time 
  time_t sysTime;
  //Structure to hold time 
  struct tm *timeBox;
  //Read System 
  time sysTime= time(NULL);
  //Convert calender time to tm structure 
  timeBox = gmtime(&sysTime);
  //Generate the seed 
  unsigned seed = timeBox->tm_sec 
                  + timeBox->tm_min
                  + timeBox->tm_hour;
  //feed the seed 
  srand(seed+a_seed);
  return rand();
}

int main(){
  //use the randomized random cout<<random(11);
  //use either random() or rand() after random() is once called 
  cout<<rand();
  cout<<random();
  return 0;
}

I wrote this code when I was a 2nd year student at university and thought that it might be of help to some guy out there in some end of the earth, staring at his/her pretty monitor for some while. Meanwhile, let me get busy with another movie before I go for sleep, tomorrow I shall have to go to job again. So, good luck reader 🙂

Join split files in Windows

We often encounter situation when we need to join multiple split parts of a file into a whole file. Say, we have 3 split parts of a file myfile.ext and the splits are myfile.ext.001, myfile.ext.002 & myfile.ext.003.
Following command in the cmd will join all of them into one:

copy /b myfile.ext.001+myfile.ext.002+myfile.ext.003 myfile.ext

Hope it was kind of helpful, if so keep coming & if not then at least don’t forget to put a comment 😀