Pakistan Flag Dimensions

pakflag3

With 14 August 2016 coming tomorrow I am studying the dimensions of the Pakistan flag as recommended in [3]. The results are shown in above figure. All dimensions are with reference to the height of the flag “H”. Width of the flag is one and half times H, shown as “3H/2” in dimension. The white strip is 1/4th of the total width that translates to 3/8th of height. The outer arc of crescent is a circle with center at center of the green portion with radius thirty percent of flag height. The five pointed star is circumscribed by circle of radius 1/10 H and touches the first circle from inside towards the top right corner. One point of the star is aligned towards top right corner. The inner arc radius is 11/40 times the height with center on off-diagonal line at a distance of 13/20 H from  top right corner. The flag is colored in Pakistan green having standard RGB values (red = 0, green = 102, blue = 0) or with hex triplet #006600 or the HSV value = (h = 120, s = 100, v = 40). The left strip, the star and  the crescent are painted in white. The flag is supported from left white side. The flag is not to be flown vertically. The below figure shows an example with height taken as 20.

pakflag

Programmed tikz to draw the flag in latex.


\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
\definecolor{green}{RGB}{0, 100, 0}
\noindent\begin{tikzpicture}
% Use wikipedia's dimensions

  \fill[green] rectangle (12, 8);%G=8, L=12, L=1.5 G
    \fill[white] (.01,.01) rectangle (2.98, 8);%G=8, L=12, L=1.5 G

   \fill[white] (7.5,4) circle (2);
   \fill[green] (7.9,4.4) circle (1.6);
    \node[star,fill=white, minimum size=1.7cm, rotate=25, star point ratio=2.617,inner sep=0pt] at (8.9,5.5) {};
  \end{tikzpicture}
  \end{document}

pakflag

National Assembly Passed the Design on 11 August 1947

That this assembly resolves that the national flag of the federation of Pakistan be of the following description.

“A dark green rectangular flag in the proportion of length and width 3:2 with a white vertical bar at the mast, the green portion bearing a white crescent in the centre and a five-pointed white heraldic star. The size of the white portion being one-fourth the size of the flag, nearest the mast, the remainder three-fourths being dark green. the dimensions of the crescent and star are obtained as follows:

“Draw the diagonal from the top right hand corner to the bottom left corner of the green portion. On this diagonal establish two points ‘A’ and ‘B’. Point ‘A’ at a distance equidistant from top right and bottom left hand corners of the green portion, i.e. the centre of the green portion. Point ‘B’ at a distance from the top right hand corner equal to 13/20th the width of the flag. With centre point ‘A’ and radius 1.1/4th the width of the flag describe a second arc. The enclosures made by these two arcs form the crescent. The dimensions of the five-pointed white heraldic star are determined by drawing a circle 1/10th the width of the flag. The circle surrounds the five points of the heraldic star. The star lies with one point on the diagonal at a point where the larger arc of the crescent, if completed, cuts the diagonal.”


Flag Construction References:

  1. http://www.pakistani.org/pakistan/flagspec.html
  2. http://www.crwflags.com/fotw/flags/pk’.html
  3. https://web.archive.org/web/20071114124633/http://www.pakistan.gov.pk/divisions/ContentInfo.jsp?DivID=23&cPath=221_227&ContentID=758

 

Browser turned into image-viewer/ebook-reader

In earlier days of the internet, Iqbal Cyber Library was among the first sites that hosted Urdu ebooks. The books, however, were not available in the form of Unicode or searchable text in simple words. The individual book pages were hosted in the form of images, probably created using Inpage Urdu editor. The site allowed downloading of these books with httptrack, a tool to copy complete website on computer hard disk for offline reading. I preferred saving all the ebook pages in one folder with extension pnnnn.gif, nnnn being the 4-digit page number. Then I  programmed little javascript code to view all pages in that folder, navigating with left and right arrow keys.

<html>
<head>
	<title> HTML Ebook </title>
	
	<style type="text/css">
    div{
		transform: rotate(0deg);
		-ms-transform: rotate(0deg); /* IE 9 */
		-webkit-transform: rotate(0deg); /* Safari and Chrome */
	}
	</style>

		
	var imgN=1;
	function padDigits(number, digits) {
		return Array(Math.max(digits - String(number).length + 1, 0)).join(0) + number;
	}

	function nextImg(){
		imgN++; 
		document.getElementById('pageNum').innerHTML='Page: '+ "p"+ padDigits(imgN, 4);
		document.images[0].src= "p"+padDigits(imgN, 4)+".gif";
		//document.images[0].style.msTransform='rotate('+((0=++0%4)*90)+'deg)';
		document.images[0].css("-webkit-transform", "rotate(40deg)");
	}

	function prevImg(){
		imgN--; 
		document.getElementById('pageNum').innerHTML='Page: '+ "p"+ padDigits(imgN, 4);
		document.images[0].src= "p"+padDigits(imgN, 4)+".gif";
		//document.images[0].style.msTransform='rotate('+((0=++0%4)*90)+'deg)';
	}

	document.onkeydown = checkKey;

	function checkKey(e) {
		e = e || window.event;
		if (e.keyCode == '37') {
			// left arrow
			document.body.scrollTop = document.documentElement.scrollTop = 0; //Scroll up page
			nextImg();
		}
		else if (e.keyCode == '39') {
			// right arrow
			document.body.scrollTop = document.documentElement.scrollTop = 0; //Scroll up page
			prevImg();
		}
		//left key code = 37
		//up key code = 38
		//right key code = 39
		//down key code= 40
	}
</head>

<body bgcolor="#FFFFFF" dir=rtl>

	<INPUT TYPE="button" VALUE="< Previous Page" ONCLICK="prevImg()">
	<INPUT TYPE="button" VALUE="Next Page>" ONCLICK="nextImg()">
	<!--<INPUT TYPE="text" VALUE="" ONCLICK="goToImage(text)">-->
 </body>
 </html>

Phase Portraits of Differential Equations

Phase portraits of differential equations help visualize the response of a system to initial conditions and when represented in state-space form, how do the system space vector gets effected for zero input response as function of time.

phasePortrait


% Matlab Code for Phase Portraits
% Author: Abu Bakar Siddique
% Dated: 25-Mar-2016

clear all; close all; clc

[x1,x2] = meshgrid(-4:.5:4,-4:.5:4);

x1 = x1(:)'; x2 = x2(:)';

A1 = [-1 0; 0 -4];
A2 = [-2 -1; -2 -3];
A3 = [-2 0; 0 1];
A4 = [-3 -2; 2 2];
A5 = [-1 1; -1 -3];
A6 = [-2 1; 0 -2];
A7 = [2 -3; 6 -4];
A8 = [-1 2; -5 1];
A9 = [-3 1; 0 -2];
lineWidth = 3;

subplot (241);
xdot = A1*[x1; x2];x1d = xdot(1,:); x2d = xdot(2,:);mag = sqrt(x1d.^2 + x2d.^2);quiver(x1,x2,x1d./mag, x2d./mag,'b');
hold on; quiver([0 0],[0 0],[1 0], [0 1],'r','linewidth',lineWidth); hold off
axis tight equal; title('A_1')

subplot (242)
xdot = A2*[x1; x2];x1d = xdot(1,:); x2d = xdot(2,:);mag = sqrt(x1d.^2 + x2d.^2);quiver(x1,x2,x1d./mag, x2d./mag,'b');
hold on; quiver([0 0],[0 0],[1 1], [-1 2],'r','linewidth',lineWidth); hold off
axis tight equal; title('A_2')

subplot (243)
xdot = A3*[x1; x2];x1d = xdot(1,:); x2d = xdot(2,:);mag = sqrt(x1d.^2 + x2d.^2);quiver(x1,x2,x1d./mag, x2d./mag,'b');
hold on; quiver([0 0],[0 0],[1 0], [0 1],'r','linewidth',lineWidth); hold off
axis tight equal; title('A_3')

subplot (244)
xdot = A4*[x1; x2];x1d = xdot(1,:); x2d = xdot(2,:);mag = sqrt(x1d.^2 + x2d.^2);quiver(x1,x2,x1d./mag, x2d./mag,'b');
hold on; quiver([0 0],[0 0],[-2 1], [1 -2],'r','linewidth',lineWidth); hold off
axis tight equal; title('A_4')

subplot (245)
xdot = A5*[x1; x2];x1d = xdot(1,:); x2d = xdot(2,:);mag = sqrt(x1d.^2 + x2d.^2);quiver(x1,x2,x1d./mag, x2d./mag,'b');
hold on; quiver([0 0],[0 0],[-1 -1], [1 1],'r','linewidth',lineWidth); hold off
axis tight equal; title('A_5')

subplot (246)
xdot = A6*[x1; x2];x1d = xdot(1,:); x2d = xdot(2,:);mag = sqrt(x1d.^2 + x2d.^2);quiver(x1,x2,x1d./mag, x2d./mag,'b');
hold on; quiver([0 0],[0 0],[1 1], [0 0],'r','linewidth',lineWidth); hold off
axis tight equal; title('A_6')

subplot (247)
xdot = A7*[x1; x2];x1d = xdot(1,:); x2d = xdot(2,:);mag = sqrt(x1d.^2 + x2d.^2);quiver(x1,x2,x1d./mag, x2d./mag,'b');
% hold on; quiver([0 0],[0 0],[1 1], [-1 1],'r'); hold off
axis tight equal; title('A_7')

subplot (248)
xdot = A8*[x1; x2];x1d = xdot(1,:); x2d = xdot(2,:);mag = sqrt(x1d.^2 + x2d.^2);quiver(x1,x2,x1d./mag, x2d./mag,'b');
% hold on; quiver([0 0],[0 0],[1 1], [-1 1],'r'); hold off
axis tight equal; title('A_8')

ha = axes('Position',[0 0 1 1],'Xlim',[0 1],'Ylim',[0
1],'Box','off','Visible','off','Units','normalized', 'clipping' , 'off');

text(0.5, 1,'\bf Phase Portrait Plots submitted by Abu Bakar Siddique: 2013-Phd-Elect-008)','HorizontalAlignment' ,'center','VerticalAlignment', 'top')

quiver(X,Y,U,V) plots velocity vectors as arrows with components (u,v)
at the points (x,y). The matrices X,Y,U,V must all be the same size
and contain corresponding position and velocity components (X and Y
can also be vectors to specify a uniform grid). quiver automatically
scales the arrows to fit within the grid.

LED and Push Button code for STM32F4 on Keil uVision5

STM32F4-Discovery
/*----------------------------------------------------------------------------
 * Name:     Toggle.c
 * Purpose:  Blinks LED PD13. Toggles LED PD14 by PA0 Button
 * Author:   Abu Bakar Siddique
 * Software: Keil uVision V5.17.0.0
 * Platform: STM32F401C, STM32F4 Discovery Board
 * Dated:    April 2016
 *----------------------------------------------------------------------------
 * This software is supplied "AS IS" without warranties of any kind.
 *
 * Copyright (c) 2004-2015 Abu Bakar Siddique. All rights reserved.
 *----------------------------------------------------------------------------*/

#include "stm32f4xx_hal.h"              // Keil::Device:STM32Cube HAL:Common

void delay(int time){
	int i, j;
	for (i = time; i > 0; i--){
		for(j = 100; j > 0; j--);
	}
}

int main (void) {
  GPIO_InitTypeDef GPIO_InitStruct;
  HAL_Init();                               /* Initialize the HAL Library     */
  __GPIOA_CLK_ENABLE();
	__GPIOD_CLK_ENABLE();

  GPIO_InitStruct.Pin   = GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15 | GPIO_PIN_4 | GPIO_PIN_3;
  GPIO_InitStruct.Mode  = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull  = GPIO_PULLDOWN;
  GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
  HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);

  /* Configure GPIO pin: PA0 (USER) */
  GPIO_InitStruct.Pin = GPIO_PIN_0;
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

	HAL_GPIO_WritePin(GPIOD, GPIO_PIN_4, GPIO_PIN_RESET);
	HAL_GPIO_WritePin(GPIOD, GPIO_PIN_15, GPIO_PIN_SET);
	HAL_GPIO_WritePin(GPIOD, GPIO_PIN_3, GPIO_PIN_SET);	

  while (1) {

    int flag = 0;
		if (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0) == GPIO_PIN_SET && flag == 0) {
			HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_14);
			flag = 1;
		}

		HAL_GPIO_WritePin(GPIOD, GPIO_PIN_4, GPIO_PIN_RESET);
		HAL_GPIO_WritePin(GPIOD, GPIO_PIN_3, GPIO_PIN_RESET);
		HAL_GPIO_WritePin(GPIOD, GPIO_PIN_13, GPIO_PIN_RESET);
		delay(10000);
		flag = 0;

		HAL_GPIO_WritePin(GPIOD, GPIO_PIN_4, GPIO_PIN_SET);
		HAL_GPIO_WritePin(GPIOD, GPIO_PIN_3, GPIO_PIN_RESET);
		delay(10000);

		HAL_GPIO_WritePin(GPIOD, GPIO_PIN_4, GPIO_PIN_RESET);
		HAL_GPIO_WritePin(GPIOD, GPIO_PIN_3, GPIO_PIN_RESET);
		HAL_GPIO_WritePin(GPIOD, GPIO_PIN_13, GPIO_PIN_SET);
		delay(10000);

		HAL_GPIO_WritePin(GPIOD, GPIO_PIN_4, GPIO_PIN_RESET);
		HAL_GPIO_WritePin(GPIOD, GPIO_PIN_3, GPIO_PIN_SET);
		delay(10000);

	}
}