TKYM's profile※ 画面は開発中のものですPhotosBlogListsMore Tools Help

※ 画面は開発中のものです

いろいろと作ってます。 プログラミング( VC++, C#, Javascript, PHP ) 時々ノイズ(鉄道 庭のビワ 他)

作ったもの

Loading...Loading...

TKYM

Occupation
Location
Interests
(特に最近は結構)プログラミングしてます。
C++(SDK, MFC), C#
HSP
Javascript, PHP など

ソフ開の勉強をします。
簿記2級もまだ目指してます。

鉄道が好きです。
時刻表をよく見ます。
模型は金銭的、撮影は時間的な問題から実践できていません。

2007年、庭にビワの種をまきました。
ProgrammingCity
http://prog-city.no-ip.info/
自宅サーバー。プログラミングの記事・ソフトの配布など


Vector でも公開しています。
(反映が遅いため最新版ではない可能性があります) vector
このページのURL
http://prog-city.spaces.live.com/

記事一覧

Loading...Loading...
June 23

if(0<i<100) という書き方 (C#)

もちろん、 if(0<i<100) なんていう書き方は不可能である。
しかし、何とかしようと思えばできなくもなさそうである。

   1: struct keisan
   2: {
   3:     public int i;
   4:  
   5:     List<range> condition;
   6:  
   7:     //tostring
   8:     public override string ToString()
   9:     {
  10:         return "" + i;
  11:     }
  12:  
  13:     //コンストラクタ
  14:     public keisan(int i) {
  15:         this.i = i;
  16:         condition = new List<range>();
  17:     }
  18:  
  19:     //新しく追加するとき
  20:     public keisan(keisan ks) {
  21:         this.i = ks.i;
  22:         condition = new List<range>();
  23:  
  24:         foreach(range r in ks.condition){
  25:             condition.Add(r);
  26:         }
  27:     }
  28:  
  29:     //bool へのキャスト
  30:     public static implicit operator bool(keisan ks){
  31:         foreach(range r in ks.condition){
  32:             if(r.min > ks.i || r.max < ks.i){
  33:                 return false;
  34:             }
  35:         }
  36:         return true;
  37:     }
  38:  
  39:     //int へのキャスト
  40:     public static implicit operator int(keisan ks) {
  41:         return ks.i;
  42:     }
  43:  
  44:     //int からのキャスト
  45:     public static implicit operator keisan(int i)
  46:     {
  47:         return new keisan(i);
  48:     }
  49:  
  50:     //オペレーター
  51:  
  52:  
  53:     //<
  54:     public static keisan low(int i, keisan ks) {
  55:         keisan result = new keisan(ks);
  56:         result.condition.Add(new range(i, int.MaxValue));
  57:  
  58:         return result;
  59:     }
  60:     public static keisan high(int i, keisan ks)
  61:     {
  62:         keisan result = new keisan(ks);
  63:         result.condition.Add(new range(int.MinValue, i));
  64:  
  65:         return result;
  66:     }
  67:  
  68:     public static keisan operator <(keisan ks, int i) {
  69:         return high(i, ks);
  70:     }
  71:     public static keisan operator <(int i, keisan ks){
  72:         return low(i, ks);
  73:     }
  74:  
  75:     //>
  76:     public static keisan operator >(int i, keisan ks){
  77:         return high(i, ks);
  78:     }
  79:     public static keisan operator >(keisan ks, int i){
  80:         return low(i, ks);
  81:     }
  82:  
  83:     //<=
  84:     //>=
  85: }
  86:  
  87: struct range{
  88:     public range(int min, int max) {
  89:         this.min = min;
  90:         this.max = max;
  91:     }
  92:  
  93:     public int min;
  94:     public int max;
  95: }

int 型の値と、条件を保持する構造体を作ってみて、

  • 比較演算子をオーバーロードする。
  • int , bool へのキャストを書く
  • int からのキャストを書く(代入用)
  • ToString を書く

 

細かいことは考えていないが、

   1: keisan k = 100;
   2:  
   3: if (200 > k > 0) {
   4:     MessageBox.Show(""+k);
   5: }

 

と、書くことができた。


February 17

Destroy で 完全消去

Destroy というソフトがある。
安全にディスク消去できるソフトらしい。


このソフトを使ってディスクを消去したいのだが、
USB まで認識させるためには、ドライバを組み込まねばならない。
そして、 FDD がないので余計ややこしい。

自分の通った道をメモしておく。
もっと簡単な方法はきっとある。
  1. 用意するもの
    1. Destroy の ファイル一式
    2. 仮想FDDソフト Virtual Floppy Drive
    3. USBASPI.SYS と DI1000DD.SYS
  2. Power2Go でブータブルディスクを作成する
    (Destroy 付属のISO を焼けばいいと思う。)
  3. VFD ドライブを作る。
    マイコンピュータにドライブが表示されるように努力する
  4. VFD でドライブを開く
    ドライブ0 を選択し、 開く/新規 をクリックし、ブータブルディスクの bootimg.img をイメージとして選択する。
  5. 開いたドライブにファイルを足す/追記する
    • USBASPI.SYS と DI1000DD.SYS
    • config.sys に 以下を追加する(説明書通り)
      device=usbaspi.sys
      device=di1000dd.sys
  6. VFD の画面から保存を選択する。適当に保存する
  7. Power2Go で、イメージとして6で保存したものを選択して、ブータブルCDを作成する。
    (deepBurner でも、ブートイメージを選んでブータブルCDを焼くメニューがあったような)
試しにUSB メモリを消去してみたらうまくいった。
あまりこういう面倒なことはしたくない。


January 17

数式をWebに貼る方法

これまでOpenOffice の数式エディタで数式を作りコピペしていた。
それが面倒になってきたので、GETパラメータに式を入れて表示できるもの
がないか調べたところ、以下を見つけた。

[mimeTeX]
バイナリのcgi を実行する。
ギザギザが気になる。


[imgTeX]
FastCGI
キレイに表示できる
TeX を使ってそれを PNG にしているとのこと。







January 02

曲線同士の交点を求めた

ベジエ曲線同士の交点を、(自分的にはついに)求められた。
誤差が大きいのであまり信頼は出来ないが、
見た目上はちゃんと交点を指している。

大まかにはこの記事の流れで出来た。
http://prog-city.spaces.live.com/Blog/cns!E5379F11D9E8BB3F!1072.entry

image

December 07

ベジエ曲線の分割

曲線を t : 1-t に分割したければ、 制御点 1-2,  2-3,  3-4 を  t : 1-t に分割し、
それを結んで出来た2本の直線を、再び t : 1-t に分割し、
残りの1本を t : 1-t に分割する。

分割した点は、新たな曲線の制御点になっている。


image

        static public PointF[,] BezierCut(PointF[] points, float t){
            PointF[,] result = new PointF[2, points.Length];
            
            //stでくぎられる点を見つける
            //分割前の P0, Pn が分割後の L0, Rn になる
            result[0,0] = points[0];
            result[1,points.Length-1] = points[points.Length - 1];

            PointF[] prev = points;
            for (int i = 1; i < points.Length; i++)
            {
                PointF[] tmp = new PointF[points.Length - i];
                for (int j = 0; j < points.Length - i; j++)
                {
                    //tmp[j] - tmp[j+1] の間を st で区切る
                    tmp[j].X = prev[j].X + (prev[j + 1].X - prev[j].X) * t;
                    tmp[j].Y = prev[j].Y + (prev[j + 1].Y - prev[j].Y) * t;
                }
                result[0,i].X = tmp[0].X;
                result[0,i].Y = tmp[0].Y;
                result[1,points.Length - i - 1].X = tmp[tmp.Length - 1].X;
                result[1,points.Length - i - 1].Y = tmp[tmp.Length - 1].Y;

                prev = tmp; //算出したものを保持
            }

            return result;
        }

image

このシリーズの他記事 http://prog-city.spaces.live.com/lists/cns!E5379F11D9E8BB3F!1047/

 

 

ダイヤ乱れ

Loading...Loading...

その他

ブログ村
ブログランキング・にほんブログ村へ

にほんブログ村 IT技術ブログへ
にほんブログ村 その他日記ブログへ
テクノラティ

 
HSP
足跡。
Please wait...
Sorry, the comment you entered is too long. Please shorten it.
You didn't enter anything. Please try again.
Sorry, we can't add your comment right now. Please try again later.
To add a comment, you need permission from your parent. Ask for permission
Your parent has turned off comments.
Sorry, we can't delete your comment right now. Please try again later.
You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
Complete the security check below to finish leaving your comment.
The characters you type in the security check must match the characters in the picture or audio.
鉄道  
Photo 1 of 10