Toolbox .net Code Converter

Convert C# to VB.NET

Support .NET 3.5 syntax, http://www.developerfusion.com/tools/convert/csharp-to-vb/

Advertisements

Using NURBS library in Matlab

  1. Get the NURBS library from here
  2. Extract the files to your hardisk, for example, C:\Matlab
  3. So, your NURBS lib folder will be on C:\Matlab\nurbs-1.3.1 folder,
  4. Create new m-file, TestNURBSlib.m, the control points data are taken from An Introduction to NURBS: With Historical Perspective book, pp. 215
    Continue reading

Installing GLUI using CodeBlocks on windows

Here is another way to installing GLUI on windows. Before going to install the glui, please ensure that the glut is installed properly.

  1. Download glui library from http://glui.sourceforge.net/ in the files section u will find the latest release version of glui.
  2. Extract the zip file somewhere in ur disk, Open Code::Blocks, Click File -> Import Projects -> MS Visual Studio Solution ..

    Importing the VS GLUI Project

    Importing the VS GLUI Project

  3. Then open the glui-2.36 directory (i use glui-2.36 version) under src directory u will find msvc directory, then open glui.sln file. Next, Click yes to convert the VS solution into Code::Block projects (All)

    Confirmation box

    Confirmation box

  4. Continue reading

Chart Pattern Fills on Excel 2003, 2007, 2010

Select on the Y-axis using ur mouse and press Ctrl + F11 followed by Ctrl + G to move the window focus to Immediate window and type the following code :

selection.fill.patterned (4);

sorry no screenshot for this post :D

almost forgot, there is another way to fill the chart automatically, by installing pattern fills addins. You can find it here

References :
http://blogs.msdn.com/b/excel/archive/2007/11/16/chart-pattern-fills.aspx
http://www.andypope.info/charts/patternfills.htm

Preventing matlab to display distorted graphics/Displaying real objects

Usually matlab will displaying our graph in different aspect ratio

to manage put the following code after your draw your object

set(gca,'DataAspectRatio',[1 1 1]);

Here one example of distorted 3D plot

A distorted 3D plot

A distorted 3D plot

and here the 3D plot example of the object

Surface Result

Surface Result

Easy right!!??? :D :D

Actually, it took me 4 months for searching this code :), and finally i found it :D

Reference : http://www.mathworks.com/access/helpdesk/help/techdoc/visualize/f4-48363.html

Posting a source code on wordpress with syntax highlighter

Having a source code in your post?, try this new tag instead of <code> tag. Here i show you the difference between <code> and [sourcecode] tags

Example :
<code>
 void normalize()
 {
  double sq = x*x + y*y + z*z;
  if (sq > 0.0)
  {
   double div_a = 1.0/sqrt(sq);
   x *= div_a;
   y *= div_a;
   z *= div_a;
   w = 1.0;
  }
 }
</code>

will be rendered as below :

void normalize()
{
double sq = x*x + y*y + z*z;
if (sq > 0.0)
{
double div_a = 1.0/sqrt(sq);
x *= div_a;
y *= div_a;
z *= div_a;
w = 1.0;
}
}

whereas
[sourcecode language=”cpp”]
 void normalize()
 {
  double sq = x*x + y*y + z*z;
  if (sq > 0.0)
  {
   double div_a = 1.0/sqrt(sq);
   x *= div_a;
   y *= div_a;
   z *= div_a;
   w = 1.0;
  }
 }
[/sourcecode]

The result is,

	void normalize()
	{
		double sq = x*x + y*y + z*z;
		if (sq > 0.0)
		{
			double div_a = 1.0/sqrt(sq);
			x *= div_a;
			y *= div_a;
			z *= div_a;
			w = 1.0;
		}
	}

References:
http://alexgorbatchev.com/SyntaxHighlighter/
http://en.support.wordpress.com/code/posting-source-code/

My NURBS Surface Viewer using GLUT and GLUI

Ohhh no!!! its 2 pm already… and i still stuck with this genetic algorithm stuff. However, here my NURBS viewer. Since the gluNurbsSurface has failed when dealing with large number of knots/control points (its took a long time to render), so i decided to build my own Nurbs Surface viewer.

NURBS surface

NURBS surface

A ship hull

A ship hull

And here partial of the configuration file:

! Conventional Skinning Surface
! Num of Points on v direction
17
! Num of Points on u direction
38
! Num of Knots on v direction
21
! Num of Knots on u direction
42
! Num of ?? on v direction
4
! Num of ?? on u direction
40
! Order on v direction
4
! Order on u direction
4
! Knot on V direction
0 0 0 0 0.125 0.1875 0.25 0.3125 0.375 0.4375 0.5 0.5625 0.625 0.6875 0.75 0.8125 0.875 1 1 1 1

! Knot on U direction
0 0 0 0 0.3204168 0.3330365 0.3386205 0.3615613 0.3640918 0.3996359 0.4230176 0.4400723 0.4703173 0.4771228 0.4806252 0.4995547 0.5038797 0.5067325 0.5071404 0.5266452 0.5291815 0.533802 0.5355079 0.5368688 0.5375204 0.54007 0.5779993 0.5956679 0.6181809 0.6400152 0.6523381 0.6688393 0.6768478 0.6881943 0.6948065 0.6951187 0.6983484 0.6992325 1 1 1 1

! Cross Section Control Points (U) : 0
0.0000000 0.0000000 0.0000000 1.0
0.6666667 0.0000000 0.0000000 1.0
1.6666667 0.0000000 0.0000000 1.0
3.0000000 0.0000000 0.0000000 1.0
4.0000000 0.0000000 0.0000000 1.0
5.0000000 0.0000000 0.0000000 1.0
6.0000000 0.0000000 0.0000000 1.0
7.0000000 0.0000000 0.0000000 1.0
8.0000000 0.0000000 0.0000000 1.0
9.0000000 0.0000000 0.0000000 1.0
10.0000000 0.0000000 0.0000000 1.0
11.0000000 0.0000000 0.0000000 1.0
12.0000000 0.0000000 0.0000000 1.0
13.0000000 0.0000000 0.0000000 1.0
14.3333333 0.0000000 0.0000000 1.0
15.3333333 0.0000000 0.0000000 1.0
16.0000000 0.0000000 0.0000000 1.0

! Cross Section Control Points (U) : 1
0.0000000 0.0000000 0.1183558 1.0
0.6669870 0.0204567 0.1144623 1.0
1.6668257 0.0823568 0.1066065 1.0
3.0001828 0.1567253 0.0830420 1.0
4.0009233 0.2080720 0.0705577 1.0
4.9990463 0.3250287 0.0400466 1.0
5.9999298 0.3737906 0.0322105 1.0
6.9998674 0.4348038 0.0182866 1.0
7.9994083 0.5059588 0.0020279 1.0
8.9999562 0.5055757 0.0006495 1.0
10.0002874 0.5222002 -0.0016813 1.0
11.0009609 0.4849985 0.0049546 1.0
12.0012907 0.4111537 0.0210627 1.0
12.9993008 0.2804071 0.0513682 1.0
14.3343042 0.1803885 0.0684193 1.0
15.3320223 0.0418953 0.1172258 1.0
16.0000000 0.0000000 0.1137902 1.0

...