Tuesday, October 9, 2012

Wonderful Islamic Clock build with HTML5


Wonderful Islamic Clock build with HTML5. Click here to download the Islamic Clock.

Moreover, according to time and Know-How constraint, I didn't succeeded in do it in a professionel way. Since, eliminating the real hands of the clock is not a trivial task, and it requires many effort and Know-How.

However, my acting may help other amateur people understand how you can take a picture from an old clock which doesn't work anymore and renew it in another world ;)

Tuesday, October 2, 2012

The Recursive Twin Pair Conjecture [Updated]

Let’s be (p,q)k the k-th pair of twin prime, then for each twin prime p > 11, it exists a i-th, j-th pair of twin primes (p1,q1)i, (p2,q2)j where i < j < k like :
p ≔ p1 + p2 + 1
q ≔ q1 + q2 - 1

Example:
(p1,q1)i≔(5,7)2
(p2,q2)j≔(11,13)3
(p,q)k≔(17,19)4

p≔17≔ 5 + 11 + 1
q≔19≔ 7 + 13 - 1

Another visual example can be found underneath :





See also my previous post about: The New Prime Numbers Conjecture.

New Prime Numbers Conjecture (derivated from Goldbach's conjecture)

The Weak Form of the Prime Numbers Conjecture:
Every prime number p ≥ 5 can be written as the sum of two primes plus 1.
p≔ p+ p+ 1, where k > j ≥ i

The Strong Form of the Prime Numbers Conjecture:
Every prime number p > 7 can be written as the sum of two distinctive primes plus 1.
p≔ p+ p+ 1, where k > j > i and p≠ pj

Proof of the weak form:

According to Goldbach’s Conjecture:
“Every even number greater than 2 can be expressed as the sum of two primes.”

This statement is equivalent to say: “That every odd number greater than 3 can be expressed as the sum of two primes plus 1.” And, because a prime number is an odd number, this implies that every prime number greater or equal 5 can be expressed as the sum of two primes plus 1.
Therefore, in order to proof the weak form of the prime numbers conjecture, we have only to proof the Goldbach’s Conjecture.

Proof of the strong form:
(currently no proof for the strong form is available!)

Example:
3=1+1+1
5=1+2+1
    ***
7=3+3+1
    ***
11=3+7+1
13=5+7+1
17=5+11+1
19=5+13+1
23=5+17+1
29=11+17+1
31=13+17+1
37=5+31+1
41=3+37+1
43=13+29+1
...

Sunday, September 23, 2012

Tunisian Radio Player - Official Version 0.1

Splash screen of the application
>>HIGHLIGHT<<
Hearing all Tunisian Radio Stations in a single friendly and awesome application.

If you would like to hear different Tunisian radio stations, then this application may be adequate for you.

You can hear all Tunisian radio stations in one hand.

Download link for version 0.1.0 can be found here: Tunisian Radio Player - Version 0.1.0 

Download link for version 0.2.0:
Tunisian Radio Player - Version 0.2.0

See on my other post the next TRP version:
http://karakais.blogspot.de/2012/09/tunisian-radio-player-beta-version-011.html

How to install it?
Uncompress the zipped file and click on the setup file to install the application.

Feel free to provide feedback in this occasion.
The application was developed with XAML and Window Presentation Foundation (WPF), and was tested only with the OS Window 7.
Also, in order to install and run it correctly you must have the .Net Framework 4.

Tunisian Radio Player - Version 0.1.0
The supported radio stations are currently 4 stations, this number is susceptible to be extended in a near future:


  1. Mosaique FM
  2. Shems FM
  3. Jawhara FM
  4. Express FM
  5. RTCI *
  6. Zitouna FM *
  7. RTCI-National *
  8. RTCI Jeune *
  9. RTCI Culture **
  10. RTCI-(Kef, Monastir, Sfax, Gafsa, Tatouine) **
Included in the beta version 0.1 and in the future version 0.1.1
** Included in the future version 0.1.1

Features:
- Wheel Mouse to increase the volume
- Rapid play/pause/stop/volume(-/+) buttons are available
in the short view (taskbar) after you reduce the window of the application.

Download previous versions:
Tunisia Radio Player - Beta Version 0.1 (Mai 2012)

Which is the best mobile phone to write in the Arabic language?

Currently, the most powerful Mobil device that support writing in the Arabic language is the iPhone and its adequate iOS. Also, all iOS devices from apple have no problems to write in the Arabic language, other competitor like Samsung have difficulty to support it.

Writing an email (iPhone) in the arabic language
using the iOS from apple
Apple supports native languages. However, no dictionary is always incorporated in the iOS like for the Arabic language. Also, there is no adaptation of the way how the user writes.
For example, when you write always “do” in the English language, the iOS should propose this word when you write “d” since it’s mostly used. Techniques to support this kind of learning can be done using the Hidden-Markovian-Model (HMM) for phrases or words. And, this is actually a minus point to a company that claims elegance.

Also, there is no additional popup screen (or similar to the notification screen but on the sides) where you can have some rapid shortcuts, where you can press to write a significant word or a phrase. Like you always do when you write.

Writing for example “I would like” in the English language is time consuming. However, when you have a popup screen where you can push to write for example “would” instantly, it will boost up the way of writing on such devices. This will even contribute to help writers write more rapidly, and to concentrate more on the content then on the process of writing.

This concept of push-button-to-write-a-word is a little bit highlighted in the Arabic keyboard that I developed myself, and that you can find following this post : Virtual Arabic Keyboard.

That's it for me, thanks for reading ;)

Writing an arabic poem using the iPhone (iOS)


Friday, August 31, 2012

Possible deep see crater not so far away from the Tunisian coast

The following image shows a 70% possible crater located in the deep see water between Sicilia and Tunisia. Denote that at the moment no crater has been discovered so far in Tunisia.

Possible deep see crater near the coast of Tunisia

For more information about the Earth Impact Database (EID) please refer to this link.

Possible deep impact crater in Tunisia


In this post, I will show you a 60% possible deep impact crater located in the governorate of ‘Siliana’ near the city of 'Maktar'. The crater is precisely located in front of the village ‘Sidi Hamid Bu Qassah’ (see Image).
Latitude: 35°45'14.80"N
Longitude: 9° 8'41.81"E

Possible deep impact crater in Tunisia
Currently, in the Worldwide Earth Impact Database (EID) no impact crater has been discovered so far in Tunisia. Therefore, I challenge the specialists in the field of Geology to checkout this possible-deep-impact-site and do some scientific measurements.



Wordwide Map for deep Impact and craters on Earth

Tuesday, July 10, 2012

How many times do a clock's hands overlap in a day ?


كم مرة ينطبق عقربا الساعة على بعضهما في اليوم الواحد ؟
How many times do a clock's hands overlap in a day ?

In order to solve this question, we are going to define the equation of each Needle.


The equations of the 3 Needles are based on their respective rotation, and we get the following 3 equations:

  1. Position of the hour’s Needle is equal to:
  2. 30°.h+v(h)≔30°.h+[30/60°.m+30/3600°.s]≔30°.h+[1/2°.m+1/120°.s]

  3. Position of the Minute’s Needle is equal to:
  4. 6°.m+v(m)≔6°.m+6/60.s≔6°.m+0,1°.s

  5. Position of the Second’s Needle is equal to:
6°.s

Now, we are going to solve the equations pairwise by setting them equal.

Equation (2) and (3) gives us that the position of the Minute’s Needle is equal to the Second’s Needle:

Equation (2) = Equation (3)
6°.m + 0,1°.s = 6°.s
→ m = (5,9°/6°) . s

Equation (1) and (2) gives us that the position of the Hour’s Needle is equal to the Minute’s Needle:

Equation (1) = Equation (2)
30°.h + 0,5°.m + 1/120°.s = 6°.m + 0,1°.s
30°.h = 5,5°.m + 11°/120°.s

We now set the value of ‘m’ found on the first equality:

30°.h = 5,5°.(5,9°/6°).s + (11°/120°).s
30°.h = [(32,45°/6°)+(11°/120°)].s = 660/120.s = 11/2.s = 5,5.s
→ s = (30/5,5) . h

And, we know that :
m = (5,9/6) . s
→ m = (5,9/6) . (30/5,5) . h = (5,9/5,5) . 5 . h = 5,36…36 h

Let’s be the hour 6 o’clock, this means that:
s = (30/5,5) . 6 ≈ 32,7272
m = (5,9/5,5) . 5 . 6 ≈ 32,18

Because ‘m’ must be a natural number, the overlapping is not possible at that time

Now, let’s be the hour 1 o’clock then we have:
s = (30/5,5) . 1 ≈ 5,45
m = (5,9/5,5) . 5 . 1 ≈ 5,36

Because 'm' is a natural number, the overlapping is not possible. Analog, we can disprove the rest of the value except for 11 o’clock.


When the hour is 11 o’clock then we have:
s = (30°/5,5°) . 11 = 60
m = (5,9°/5,5°) . 5 . 11 = 59

That means that the hour is actually 11h 59mn 60s which means 12 o’clock.

Congratulation, we have just found the hour when all needles are overlapping. The complete overlapping is only possible at exactly 12h 0mn 0s!


Here is the results for all hours:




Saturday, June 23, 2012

My Prime Numbers Axiom

My Prime Numbers Interval Axiom

There is maximally 17 prime numbers in each interval of the form:

interv(i) := [100*(i-1)+1, 100*i], i ∈ Ν\{1,2}

for i ∈ {1,2}, we have:
  • interv(1) := 25, and
  • interv(2) := 21.
Thus,
∀i ∈ Ν\{1,2} ⇒ #Primes in interv(i) ≤ 17

I challenge you to prove the contrary!


Here is a start example for you:

30000 investigated intervals sorted here with the frequency of primes
Standard graphic that investigate the number of primes for the first 30000 intervals of the form [100(i-1)+1, 100i]

List of the number of primes for the first 32 intervals

Here is the list of the prime numbers for the first 6 intervals:
Denote here, that I used a special technique to find them. This, will be explained in a future post.

 

* Some mistakes concerning the graphics, prime list and some incorrect statement have been corrected!

Thursday, June 21, 2012

Awesome Clock Animation build with HTML5

Here is an awesome clock animation build with HTML 5 that I found on the internet.

Click here for the link.

Awesome Awesome Awesome

Sunday, May 6, 2012

How to highlight markup and programming languages with the Syntax Highlighter


Syntax Highlighter

This is a short tutorial to explain how to use the Syntax-Highlighter to highlight the most commen markup and programming language such as: html/xml/.., css, javascript, php, sql, python, ruby, perl, visual basic, java, c, c#, c++, etc.
Just put this code in the html-header wherever you are planning to show your highlighted code. In this case, we have omitted to highlight all available languages and choose only to highlight: c#, css, java, javascript, and html/xml.
Also, we have choosen to use the Eclipse-Theme instead of the Default one (other themes are also available and can be customized). Please, refer for more information to the Syntaxhighlighter Project from 'Alex Gorbatchev.










Just put your code that you want to highlight inside a <pre> tag. The current example demonstrate how to highlight html.
The pre-class (brush:html) specify that the content to be highlighted is html.
<pre class="brush:html">
   <h1>Youpi! I'm highlighted!</h1>
</pre>
The result would be:

Youpi! I'm highlighted!

The following example show a java highlighted code (<pre class="brush:java">)
package edu.kara.tutorial.java;

import java.util.*; // not used here

 public class MyClass {

  private String myParameter = "";

  public MyClass(String param) {
   this.myParameter = param;
  }

  public String getValue() {
   return MyParameter;
  }

}

Link:
1. The available brushes are to be found here.

Tuesday, January 31, 2012

Advanced Clock Animation with HTML5


!!! Source Code is Now Available !!!
No copyright authorization:
You are allowed to edit and copy it!


<!DOCTYPE html>

<head>

Temple of water - Version 1.0


</head>

<body onload="init()">


Your browser does not support HTML5

</body>

</html>

Tuesday, January 17, 2012

Tutorial: Simple Clock Animation with HTML5



In this tutorial I will show you how to create a simple clock and animate it.

This tutorial is split in three steps:
  • Step 1: Create the clock's background.
  • Step 2: Initialize the current clock time.
  • Step 3: Animate the clock.
Hint: This tutorial assumes that you have a certain knowledge of HTML5 and JavaScript.

We begin this tutorial by creating the background of this clock.

The following html start code helps you initialize the canvas tag and its context that you require for your animation.


<!DOCTYPE html>

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Simple Clock Animation</title>
<script type="application/javascript">

var canvas; // the clock canvas
var ctx; // canvas’s context

// clock settings
var centerX = 0;
var centerY = 0;
var radius = 150;

function init() {

canvas = document.getElementById("clock");
ctx = canvas.getContext("2d");

centerX = canvas.width / 2;
centerY = canvas.height / 2;

drawClock();

}

</script>
</head>

<body onload="init()">

<canvas id="clock" height="500" width="500">
Your&nbsp;browser&nbsp;does&nbsp;not&nbsp;support&nbsp;HTML5</canvas>

</body>

</html>

Step 1: will consist of drawing the clock. This is given by the function drawClock().

function drawClock() {
                drawClockBackground();
}

The function drawClockBackground() inside the drawClock() function will draw the background of the clock. It will create small lines around the center (centerX, centerY) of the clock which is also the center of the canvas.

We start creating the lines from the right to the left, and using the function drawArcAtPosition() located below. Also, we will highlight the main lines.

At final, a small circle is added at the center of the clock (see function drawLittleCircle()).

Hint: You can also use a predefined image (if you like) instead of drawing the background of the clock yourself.

function drawClockBackground() {

var correction = 1/300;
var shift_unit = 1/170;
var shift_factor = 1/30;
var angle_initial_position = 2;
var angle_current_position_begin = 0;
var angle_current_position_end = 0;
var repeat = 60;
var lineWidth = 10;

for (var i=0; i < repeat; i+=1) {

angle_current_position_begin = angle_initial_position - (i * shift_factor) - correction;
angle_current_position_end = angle_current_position_begin + shift_unit;

if (i % 5 == 0) lineWidth = 20;
else lineWidth = 10;

drawArcAtPosition(centerX, centerY, radius, 
angle_current_position_begin*Math.PI
angle_current_position_end*Math.PI, false, lineWidth);

}

drawLittleCircle(centerX, centerY);

}

function drawArcAtPosition(centerX, centerY, radius, 
start_angle, end_angle, counterclockwise, lineWidth) {
ctx.beginPath();
ctx.arc(centerX, centerY, radius, start_angle, end_angle, counterclockwise);
ctx.lineWidth = lineWidth;
ctx.strokeStyle = "black";
ctx.stroke();
ctx.closePath();
}

function drawLittleCircle(centerX, centerY) {
drawArcAtPosition(centerX, centerY, 4, 0*Math.PI, 2*Math.PI, false, 4);
}

Afterward, we create the Hands for seconds, minutes, and hours. The below figure show the hand for the seconds.

// draw Hand for seconds
function drawSecondsHand() {
endX = centerX + radius*Math.sin(seconds*Math.PI / 30);
endY = centerY - radius*Math.cos(seconds*Math.PI / 30);
drawHand(centerX, centerY, endX, endY);
}

function drawHand(beginX, beginY, endX, endY) {
ctx.beginPath();
ctx.moveTo(beginX, beginY);
ctx.lineTo(endX, endY);
ctx.stroke();
ctx.closePath();
}

The same principle is applied for minutes and hours. The hands will be a little bit smaller than that of the seconds-Hand. The minutes-Hand will move depending on the seconds-Hand, and the hours-Hand will move depending on the minutes-Hand. The moving of the Hands will be constant and smooth.

// draw Hand for minutes
function drawMinutesHand() {

var rotationUnit = minutes + seconds / 60;
var rotationFactor = Math.PI / 30;
var rotation = rotationUnit*rotationFactor;
var handLength = 0.8*radius;

endX = centerX + handLength*Math.sin(rotation);
endY = centerY - handLength*Math.cos(rotation);
drawHand(centerX, centerY, endX, endY);
}

// draw Hand for hours
function drawHoursHand() {

var rotationUnit = 5*hours + minutes / 12;
var rotationFactor = Math.PI / 30;
var rotation = rotationUnit*rotationFactor;
var handLength = 0.4*radius;

endX = centerX + handLength*Math.sin(rotation);
endY = centerY - handLength*Math.cos(rotation);
drawHand(centerX, centerY, endX, endY);
}

The function drawClock() will be adequately updated as follow, where we add the Hands for the clock.

function drawClock() {
                drawClockBackground();
                drawSecondsHand();
                drawMinutesHand();
                drawHoursHand();
}

Step 2: will consists of animating the Hands. However, before we start we have to get the current time of the system. Thus, we create 4 additional system variables as follows:

// time settings
var date;
var hours;
var minutes;
var seconds;

And, we create a function called initTime(), where we initialize the data object and pass to our variables the current time of our system and clock.

// get the system time
function initTime() {
date = new Date();
hours = date.getHours() % 12;
minutes = date.getMinutes();
seconds = date.getSeconds();
}

Now, add the initTime() function before the drawClock() function in the init() function. This is because the Hands will be drawn according to the system current time.

function init() {
initTime();
drawClock();
}

Step 3: will consist now of animating the Hands(seconds, minutes, and hours) of the clock.
We are going now to create an animate clock function called animateClock() as follows:

// animate clock
function animateClock() {

clearCanvas();
refreshTime();
drawClock();

}

Inside this function we have three functions named: clearCanvas(), refreshTime(), and drawClock().
The first function will clear the canvas for the animation. The second function is going to refresh the current elapsed time, and the final function, which we have already seen, is going to redraw the clock with its Hands according to the refreshed time.

// clear canvas
function clearCanvas() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
}

// refresh time after 1 seconde
function refreshTime() {
seconds += 1;
if (Math.floor((seconds / 60)) != 0) { minutes += 1; seconds %= 60; }
if (Math.floor((minutes / 60)) != 0) { hours += 1; minutes %= 60; }
}

// draw or redraw Clock after time refresh
function drawClock() {
                drawClockBackground();
                drawSecondsHand();
                drawMinutesHand();
                drawHoursHand();
}

In order to animate the clock we are going now to add the setInterval(..) function inside the init() function which will animate the clock every second. Of course, the function that will be called every second is the animateClock() function.

function init() {

canvas = document.getElementById("clock");
ctx = canvas.getContext("2d");

centerX = canvas.width / 2;
centerY = canvas.height / 2;

initTime();
drawClock();

setInterval("animateClock()", 1000);

}

The full clock's code can be viewed below:

<!DOCTYPE html>

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Simple Clock Animation</title>
<script type="application/javascript">

var canvas; // the clock canvas
var ctx; // canvas's context

// clock settings
var centerX = 0;
var centerY = 0;
var radius = 150;

// time settings
var date;
var hours;
var minutes;
var seconds;

function init() {

canvas = document.getElementById("clock");
ctx = canvas.getContext("2d");

centerX = canvas.width / 2;
centerY = canvas.height / 2;

initTime();
drawClock();

setInterval("animateClock()", 1000);

}

// get the system time
function initTime() {

date = new Date();
hours = date.getHours() % 12;
minutes = date.getMinutes();
seconds = date.getSeconds();

}

// animate clock
function animateClock() {

clearCanvas();
refreshTime();
drawClock();

}

// clear canvas
function clearCanvas() {
ctx.clearRect(00, canvas.width, canvas.height);
}

// refresh time after 1 seconde
function refreshTime() {
seconds += 1;
if (Math.floor((seconds / 60)) != 0) { minutes += 1; seconds %= 60; }
if (Math.floor((minutes / 60)) != 0) { hours += 1; minutes %= 60; }
}

// draw or redraw Clock after time refresh
function drawClock() {
                drawClockBackground();
                drawSecondsHand();
                drawMinutesHand();
                drawHoursHand();
}

function drawHand(beginX, beginY, endX, endY) {
ctx.beginPath();
ctx.moveTo(beginX, beginY);
ctx.lineTo(endX, endY);
ctx.stroke();
ctx.closePath();
}

// draw Hand for seconds
function drawSecondsHand() {
endX = centerX + radius*Math.sin(seconds*Math.PI / 30);
endY = centerY - radius*Math.cos(seconds*Math.PI / 30);
drawHand(centerX, centerY, endX, endY);
}


// draw Hand for minutes
function drawMinutesHand() {
var rotationUnit = minutes + seconds / 60;
var rotationFactor = Math.PI / 30;
var rotation = rotationUnit*rotationFactor;
var handLength = 0.8*radius;

endX = centerX + handLength*Math.sin(rotation);
endY = centerY - handLength*Math.cos(rotation);
drawHand(centerX, centerY, endX, endY);
}

// draw Hand for hours
function drawHoursHand() {
var rotationUnit = 5 * hours + minutes / 12;
var rotationFactor = Math.PI / 30;
var rotation = rotationUnit*rotationFactor;
var handLength = 0.4*radius;

endX = centerX + handLength*Math.sin(rotation);
endY = centerY - handLength*Math.cos(rotation);
drawHand(centerX, centerY, endX, endY);
}

function drawClockBackground() {

var correction = 1/300;
var shift_unit = 1/170;
var shift_factor = 1/30;
var angle_initial_position = 2;
var angle_current_position_begin = 0;
var angle_current_position_end = 0;
var repeat = 60;
var lineWidth = 10;

for (var i=0; i < repeat; i+=1) {

angle_current_position_begin = angle_initial_position - (i * shift_factor) - correction;
angle_current_position_end = angle_current_position_begin + shift_unit;

if (i % 5 == 0) lineWidth = 20;
else lineWidth = 10;

drawArcAtPosition(centerX, centerY, radius, 
angle_current_position_begin*Math.PI
angle_current_position_end*Math.PI, false, lineWidth);

}

drawLittleCircle(centerX, centerY);

}

function drawArcAtPosition(centerX, centerY, radius, start_angle, 
end_angle, counterclockwise, lineWidth) {
ctx.beginPath();
ctx.arc(centerX, centerY, radius, start_angle, end_angle, counterclockwise);
ctx.lineWidth = lineWidth;
ctx.strokeStyle = "black";
ctx.stroke();
ctx.closePath();
}

function drawLittleCircle(centerX, centerY) {
drawArcAtPosition(centerX, centerY, 4, 0*Math.PI, 2*Math.PI, false, 4);
}

</script>
</head>

<body onload="init()">

<canvas id="clock" height="500" width="500">
Your&nbsp;browser&nbsp;does&nbsp;not&nbsp;support&nbsp;HTML5</canvas>

</body>

</html>