9/25/2012

C++/CLI (handmade) template for Windows Form Application

Finally, Microsoft released Visual Studio Express 2012, and it has IntelliSense for C++/CLI! If you have ever used Visual C++ 2010 Express, you might have complained about the absence of IntelliSense in it. So you don't need to use VC++ 2008 anymore.

But, unfortunately, there is no C++/CLI template for Windows Form Application as of Sept. 25th 2012.

So I made a template. I just put a form into an empty project and set it up as a Windows form application. So I might have missed some settings. Maybe you might do a better job.
Anyway, you can download it from this page of my web site.
http://sites.google.com/site/somedayuniverse/contents/c-cli-template-of-windows-form-application-in-visual-studio-express-2012

8/14/2012

Mars Exploration

I am recently excited about Mars exploration, especially Curiosity rover. You might have known that this spacecraft landed by using incredible techniques.

The previous rovers, such as Mars Exploration Rovers, used airbags and bounced on the ground several times to land on Mars. However, Curiosity used different process. After deploying its parachute and slowing down correctly, it separated from the parachute facilities and fell down with the special machine called Sky Crane. The crane hovered and hanged the rover with a cable. When the rover touched down, it flied away with the cable.



This achievement was made also by the spacecrafts orbiting Mars. Mars Odyssey helped the communication between Earth and Curiosity at the entry and descending.
http://mars.jpl.nasa.gov/odyssey/news/whatsnew/index.cfm?FuseAction=ShowNews&NewsID=1265
Mars Reconnaissance Orbiter are gathering data around the rover.
http://marsprogram.jpl.nasa.gov/msl/news/whatsnew/index.cfm?FuseAction=ShowNews&NewsID=1297

I think spacecrafts orbiting an celestial object are important to make the environment for exploration because they can establish the network around the object and Earth.
Even in deep space where a rover has to work by itself without the control room, if there are orbiters, they can seize the information of wide areas of an object.
In the future, it may be a major way to send a rover with many orbiters and machines scattering around an object rather than sending just a single rover or spacecraft.

7/09/2012

Mental Calculation for Temperature Scales

Today, I heard the first cry of cicadas. It's summer! And It is very hot. The maximum temperature is 30 deg. Celsius. But how do you say it in Fahrenheit?
I am sometimes confused with the two scales of temperature: Fahrenheit and Celsius.


You know Fahrenheit is used in a few countries including the U.S. I don't know why Fahrenheit is still commonly used in the U.S. even though many other countries use Celsius. Every time I talk about weather with them, I have to "translate" Celsius to Fahrenheit, and vice versa.

But it is ridiculous to always hold a pen and notes (or a calculator) to use this formula: (F=C*9/5+32). So I have several steps to easily calculate scales in my head.

Celsius to Fahrenheit:
You have a value C in Celsius.

1. Double C
       C * 2
2. Subtract 10% of it
       2C - 0.1 * 2C
3. Add 32
       2C - 0.1 * 2C + 32

Then you get an exact value in Fahrenheit.

It is easier than expected.
For example, let's say the temperature is 30 deg. C.
So you can calculate as the below:
   30*2=60
   60-6=54
   54+32=86 The temperature is exactly 86 deg. F.

In case of 20 deg. C.:
   20*2=40
   40-4=36
   36+32=68 The temperature is 68 deg. F.

The reason can be derived from the formula.
F=C*9/5+32
=C*2/2*9/5+32
=C*2*(9/10)+32
=C*2*0.9+32
=C*2-C*2*0.1+32


Fahrenheit to Celsius:
You have a value F in Fahrenheit.

1. Divide F by 2
      F/2
2. Subtract 16 from it
      F/2 - 16
3. Add 10% of it
      F/2-16 + 0.1 * (F/2-16)

In this case, you get an approximately value in Celsius.

For example, let's say the temperature is 70 deg. F.
So you can calculate as the below:
   70/2=35
   35-16=19
   19+1.9=20.9  The temperature is about 21 deg. C.

The reason can be derived from the formula.
C=(F-32)*5/9
=(F-32)/2*2*5/9
=(F/2-16)*10/9
=(F/2-16)*1.11111...
≒(F/2-16)*1.1


4/26/2012

Private Space Mission to ISS!

At last, the age of private space mission completely has come!
The private space ship, called Dragon, will go to ISS. Although the date to launch was delayed, it is May 7. So it will be soon.
http://www.nasa.gov/exploration/commercial/cargo/spacex_launchpreview.html

Docking to another spacecraft needs very complicated and difficult techniques. That's the reason why old spacecrafts were mainly controlled by dexterous military pilots. This means the private mission has been developed as well as those administered by governments. In addition, it will show the potentiality of private companies to send spacecrafts to more distant places.

4/07/2012

Projected Glaxy

I found this beautiful picture. It is the panorama of the Milky Way.

Credit: ESO/S. Brunier

Yes, it is very beautiful. In addition, I found its projection is equirectangular or plate carree. So I can change this image into equidistant projection using my application!


I felt as if I were in space!

Demo of Azimuthal Projection using Javascript

I said I made the program of azimuthal projection working on the computer several months.
I also made javascript version. Actually, this kind of programming language was new to me. Although I have been using C/C++ which needs compiling, I have never touched any script language.

There were some points I was surprised at. I thought javascript was written in Java, but it is like C language. It also looks like VB because it supports variant type. However, these were not significant for me. The biggest problem was Same Origin Policy or SOP. This policy is for a browser to restrict the work of javascript. If a script is stored at the specific domain, it cannot load any image or files stored at the different domain. Your browser would provide error code like 'Security error" code: "1000'. Finally, I directly wrote the image data in the script. The web service to change image into script was very useful.

Now, here is the script I wrote.
Here is the demo.
http://sites.google.com/site/somedayuniverse/contents/azimap_js

There might be a problem for IE because it does not support canvas. If you get the trouble, you can try a program running on your PC.
http://sites.google.com/site/somedayuniverse/contents/azimuthal-projection

3/10/2012

Azimuthal Equidistant Projection and Program

I finally finished writing. I updated the page related to azimuthal equidistant projection and uploaded the program I made.


Here is the page on my website.
http://sites.google.com/site/somedayuniverse/contents/azimuthal-projection

3/01/2012

Network Programming with .Net

I tried to write a code working in the network. Windows API is necessary to build a system related to the network. But I did not want to use APIs. There was no practical reason. I just wanted not to be confused with them, and wanted to use mainly C++/CLI, which I was familiar with.

I found an interesting page related to this problem. (although it is mentioning C#.)

So what I had to do was to write my own code in C++/CLI. It was just to put proper notations. But I found this page was a kind of old documents because some functions were obsolete.

At last, I wrote a new C++/CLI version after reading the page.

===============================================
#include "stdafx.h"

using namespace System;
using namespace System::Net;

int main(array ^args)
{
String^ name = (args->Length < 1) ? Dns::GetHostName() : args[0];
try{
array^ addrs = Dns::GetHostEntry(name)->AddressList;
int i = 0;
while(i < addrs->Length){
Console::WriteLine("{0}/{1}",name,addrs[i]);
i++;
}
}catch(Exception^ e){
Console::WriteLine(e->Message);
}

Console::ReadLine(); //waiting for pushing Enter
return 0;
}
===============================================

It is just the beginning. I will start for higher levels.

2/23/2012

OpenCV...

When I was an undergraduate student, I tried to use OpenCV for some purposes. But I gave up because it required a high level of programming skills in order to understand how the library works. Especially Visual C++ needs specific settings, such as /clr:pure to /clr in the option of common language runtime. OpenCV is written in C++. On the other hand, the default settings of Visual C++ accepts only C++/CLI, which is a kind of managed language looking like C++.

In addition to my poor skills, some functions has been apparently replaced with new ones when its version was changed to 2.x. For example, "imread" is used to load an image file while "cvLoadImage" has been used previously. I am afraid that it may be easy for other people to understand and use it, but I was actually confused.

However, I recently started to read the tutorial for ver 2.3. I feel that I will be finally able to understand its structure.
http://opencv.itseez.com/

One of the points I was surprised is that "IplImage" structure is no longer needed in the new version because "Mat" structure treats both images and matrices. I think Mat makes it easy to treat images. Actually, I can use openCV on Visual C++ now although I had many troubles with the old structures before using the new features.

2/07/2012

New program making azimuthal maps

I have been in work for applications to graduate schools. So I am considerably nervous!
While I was busy, I was also making a program projecting azimuthal maps.
I made a previous version a few years ago, but it was not good because it took SEVERAL MINUTES to project a map.

In the last month, I hit upon a good idea to make it fast and gathered related necessary techniques.
The new program takes only 100 milliseconds! (but I think that this implementation actually owes to Marshal class of .Net rather than my idea...)
I will upload my program and explain the calculation in my web site.


The world (azimuthal equidistant projection)

Around Japan (azimuthal equidistant projection)

The pacific ocean (azimuthal equidistant projection)

The world (azimuthal equal-area projection)