Wednesday, September 21, 2011

Point inside convex hull test

Assume we want to check if a given point is inside a convex hull or not, we will do the following:
v  Divide the convex hull to triangles where all of these triangles have a common vertex which is arbitrarily chosen
v  Check if the point is inside one of the triangles. If the point is inside one of the triangles then it is inside the convex hull. Else if the point is not inside any triangle then it is out the convex hull.

The method used to detect if a point is inside a triangle looks like the following:
v  The prescribed triangle has three edges. For each edge create a triangle composed of the test point and an edge
v  Compute the area of the main triangle and the other three triangles. If the sum of areas of the constructed three triangles equals that area of the main triangle then the point is inside.

Note: I don’t know if this method is previously used or not, but what I know is that my mind gifted me this method.

Friday, August 12, 2011

World map with circles art work

I got the following image using "image processing and design toolbox" in Scilab environment to get the color of each pixel in the original image and drawing circles with random diameters. The color of each circle is the color of the pixel coincident with its center. Finally, I exported those circles to scalable vector graphics format which is easy to scale keeping the quality unchanged.


The code is time-consuming, so if I improved the code, I'll post it later. 

Tuesday, August 9, 2011

VAWT mounting layouts

Here you are two layouts for VAWT mounting and the required dimensions to be calculated for each layout. The rotor is drawn as a rectangle just for this schematic and the original rotor shape does not matter.



Monday, July 4, 2011

Spirograph

Spirograph is a geometric drawing toy that produces mathematical curves of the variety technically known as hypotrochoids and epitrochoids. The term has also been used to describe a variety of software applications that display similar curves, and applied to the class of curves that can be produced with the drawing equipment (so in this sense it may be regarded as a synonym of hypotrochoid). The name is a registered trademark of Hasbro, Inc.

The following figure shows the concept and geometric paraeters



The following are some curves drawn by the spirograph code I wrote in Scilab



Friday, July 1, 2011

Force meter with mechanical amplification




The amplification depends on the ratio between areas of pistons. Small force can produce large pointer displacement.

This force meter can work with both compression and tension forces. Also it can work as comparator

The spring here (in this design) will be compressed, but we can modify the design to make it elongating.

Low friction sealing is required for this device

Saturday, April 30, 2011

Controlling dc motor speed using pc

Steps:




[]  Generate a sound wave of certain duration (in my case 10 seconds) with high frequency (say 20000 Hz) using my Scilab toolbox for tone generation.

[] Cut a wire from an old pc headphone including the TRS connector

[]  Connect one end of the dc motor with a diode and the other end of the diode with any wire out from the sound card.

[]  Connect the second wire with the motor

[]  Run the sound file with any media player and control the speed via volume control slider






Note: wave rectification is done by hardware (diode) and is not going to work when done by software
Note: when motor is connected without diode it is not going to rotate and it will behave as a speaker (you can hear songs from the motor!)

Friday, April 29, 2011

Graphical presentation of RGB 3d matrix

When I was using Image Processing and Design toolbox IDP 8.0 in Scilab environment I came over what's called "3d matrix". This 3d matrix is called RGB matrix also. Each pixel in any image requires to be defined 3 information: pixel row, pixel column, and the RGB values of this pixel. So, this matrix defines pixel location and color components. The size of this RGB matrix is M x N x 3 where M is image height in pixels, and N is image width in pixels.




Friday, January 14, 2011

Simulating heat conduction using Scilab

Heat conduction is one of the simplest physical phenomena to simulate as it simply depends on the diffusion equation. I wrote a simple Scilab code that simulates the heat conduction process from a square block using the finite difference method for the spatial discretization and forward Euler (explicit) method for time integration. The code is going to show you how Scilab can be used for simulation and visualization.



  And here you are the code (tested and worked)


//Scilab code for simulating heat conduction to a square block
//Time step
dt=0.05;

//Ambient temperature
T_amb=100;     //degrees in Celcius

//Creat an empty matrix of the temperature
T=[];

//Lower boundary
for i=1:20,
T(i,1)=T_amb;
end

//Upper boundary
for i=1:20,
T(i,20)=T_amb;
end

//left boundary
for j=1:20,
T(1,j)=T_amb;
end

//right boundary
for j=1:20,
T(20,j)=T_amb;
end

for i=2:19,
for j=2:19,
T(i,j)=20;     //Initial condition
end
end

x=1:20;
y=1:20;

show_window(); clf()
f=gcf();
f.color_map=jetcolormap(256);
f.pixmap='on';

colorbar(0,100);
T_new=T;  //use this line to copy boundaries
for counter=1:60,
T=T_new;
for i=2:19,
for j=2:19,
T_new(i,j)=dt*(T(i-1,j)+T(i+1,j)+T(i,j-1)+T(i,j+1)-4*T(i,j))+T(i,j);
end
end
z=T_new;
Sgrayplot(x,y,z, strf="042",rect=[-5 2 25 40], zminmax=[0,100])
show_pixmap();
end

New Curie effect heat engine

I searched a lot for a Curie effect heat engine and found simple layouts that actually can not be called heat engines but toys. I thought about a Curie effect rotational heat engine (not oscillating) and got this result (see figure below). One of the most important features of this engine that it can be driven using concentrated solar energy and so the rotation of the rotor is not going to affect the heat source (like that in the case of using candles).



One important note is when using candles or flames for driving the Curie effect heat engine the magnet itself is going to be affected. Also, the ferromagnetic material used in the engine should have low specific heat and low Curie temperature. I tried to make this engine using a bottle cap and some twist ties and the engine revolved but due to some inaccuracies it did not work later. Also, I faced a problem that we did not have here in Egypt Neodymium magnets. I hope that anyone will use this method will refer to me first (contact me via email).

A method for reversing rotational direction using belts

The following method can be used for reversing rotational direction without using simple gear train (in fact I hate gears as they are costly and require lubrication). I don't think that this method has (or will have) an application, but I expect it may be used in robotic applications where small torques are exist. This method is not going to use the conventional belts but it uses a belt which I call "double-V" belt. The following figures show how to do so.



And the belt is going to be like the following

Sunday, January 9, 2011

Magnetic levitation

Magnetic levitation is an alternative for thrust bearing. That means it counters the axial loads. Very accurate and well-adjusted magnets should be used.
Magnets are mounted on the shaft which is highly polished [fine turning] with a sliding fit with very small clearance. One of the magnets should be fixed in the housing.
Usually magnetic levitation uses [depends on] the repulsion forces between magnets because magnets will not come in contact unless the load is too much.
Magnetic levitation also can use attraction forces between magnets but it has several problems:
v  At low loads, the magnets can come in contact to each other if the load is not quite enough to separate them
v  At high loads, the magnets will be far away from each other which means no magnetic interaction between them
v  It requires both magnets to be fixed, one fixed on the shaft and the other to be fixed in the housing



Generating sine wave tone using Scilab

Scilab is a powerful numerical software. It has different sound handling functions. The following code (as a demonstration) can generate a sine wave tone with different parameters that can be controlled (frequency, tone length, and amplitude). The code also enables you to save the sound file as a wave file.
As a concept, you can also use Scilab to generate noise waves like saw tooth, step, impulse, etc. and then you can say bye bye to all tone generator software.

Here you are the code

//Generating sine wave tone toolbox

txt=['Length in seconds';'Frequency';'Amplitude'];
parameters=x_mdialog('Enter wave properties',txt,['10';'10000';'1']);
frequency=evstr(parameters(2));     //tone frequency
size_x=frequency*evstr(parameters(1));     //number of bits
A=evstr(parameters(3));     //Wave amplitude
x=1:size_x;
y=A*[sin(x);sin(x)];     //sine wave for both left and right channels
file_save=uiputfile("*.wav");     //Saving the wave file
wavwrite(y,frequency, 8,file_save+'.wav')     //Writing the wave file
disp('done')

And this is apture for the toolbox


Friday, January 7, 2011

Unfolding of the helical Savonius blade

Manufacturing of the blade of helical Savonius is not easy or not economic. In our mini-project in the faculty we faced this problem "How to make the blade". We (the team work) thought a lot, and most of the techniques were depending on discretization criteria. Our instructor told us "try to unfold the blade and you may get the help from any mathimatician". I searched over the internet and found a patent named "Helical wind rotor and a method for manufacturing the same". The patent number is US 6,428,275 B1 (you can find it in http://www.freepatentsonline.com/ .

The main problem in this patent that it requires converting the blade profile (section) to parametric equations and  solving simultaneous non-linear partial differential equations.

After a lot of work, I were able to unfold the blade using simple method (some Scilab codes) and the results were convincing and looks like that obtained in the patent.


The previous figure shows the unfolding of the a helical blade of 80 cm height, 30 cm bucket diameter, and 5 cm primary gap.

Tuesday, January 4, 2011

How to mesh your name

To make some thing special with meshing software, here you are the recipe:

1. Open MS Paint and write your name using any font you want
2. Copy the image and paste it in Vector Magic software and convert your name to vector graphics.
3. There is an option in Vector Magic to save your file as DXF file. Save the file as DXF
4. Open the DXF file using Autodesk Inventor and save it as DWG file
5. Open the DWG file and save it as AutoCad DWG file
6. Create a new .ipm file in Autodesk Inventor and import AutoCad DWG
7. Export the file to any cad format supported by the meshing software you use
8. Mesh your name

and this is what I got