연산자 오버로딩

카테고리 없음 2009. 11. 20. 12:08 Posted by 보노보노보노

/* 09-11-20 FRI Obj_*/
#include<iostream>
using namespace std;

class Complex
{
 private :
   double real;
   double image;
 public:
   Complex(double r=0,double i=0);
   void ShowComplex();
   void ShowComplex(char);
   void SetReal(double r);
   void SetImage(double i);
   double GetReal();
   double GetImage();
   void ReFresh(double r, double i);
   Complex operator+(Complex B);
   Complex operator-(Complex B);
   Complex operator*(Complex B);
   Complex operator/(Complex B);
   void OPer(char op, Complex a, Complex b);
};

Complex::Complex(double r, double i){
 real = r;  image = i;  }


void Complex::OPer(char op, Complex a, Complex b){
 if(op=='+'){
  real = a.GetReal() +  b.GetReal();
  image = a.GetImage() + b.GetImage();
 }else if(op=='-'){
  real = a.GetReal() - b.GetReal();
  image = a.GetImage() - b.GetImage();
 }
}


void Complex::ReFresh(double r, double i){
 real = r; image = i; }

void Complex::SetReal(double r)  { real = r;   }
void Complex::SetImage(double i) { image = i;  }

 

double Complex::GetReal() {  return real;  }
double Complex::GetImage() {  return image; }

void Complex::ShowComplex(){
 cout<<"("<< real <<" + "<< image <<" i )"<<endl;  }

void Complex::ShowComplex(char ch){
 cout<<"("<< real <<" "<<ch<<" "<< image <<" i )"<<endl;  }

Complex  Complex::operator+(Complex B)
{
 Complex Temp;
 Temp.SetReal(B.GetReal() +  this->GetReal());
 Temp.SetImage(B.GetImage() + this->GetImage());

 return Temp;
}
Complex  Complex::operator-(Complex B)
{
 Complex Temp;
 Temp.SetReal( this->GetReal() - B.GetReal() );
 Temp.SetImage(this->GetImage() - B.GetImage());

 return Temp;
}
Complex  Complex::operator*(Complex B)
{
 Complex Temp;
 Temp.SetReal((B.GetReal() *  this->GetReal()) - (B.GetImage()*this->GetImage() ) );
 Temp.SetImage((B.GetReal() * this->GetImage()) + (this->GetReal() * B.GetImage()) );

 return Temp;
}
Complex  Complex::operator/(Complex B)
{
 double a,b,c,d;
 Complex Temp;
 
 a=this->GetReal();
 b=this->GetImage();
 c=B.GetReal();
 d=B.GetImage();
 
 
 Temp.SetReal( ((a*c)-(b*d))/((c*c)+(d*d)) );
 Temp.SetImage( (a*d-c*b) / ( c*c+d+d) );
 return Temp;
}


void main()
{
 Complex x(10,20);
 Complex y(20,5);
 Complex z;

 cout<<"x = ";  x.ShowComplex();
 cout<<"y = ";  y.ShowComplex();
 cout<<"z = ";  z.ShowComplex();
 cout<<endl;
 /*z.ReFresh( x.GetReal() + y.GetReal(),
    x.GetImage() + y.GetImage()
    );
 */
 cout<<"OPER : *"<<endl;
 z=x*y;
 x.ShowComplex();
 y.ShowComplex();
 z.ShowComplex(); 
 cout<<endl;
 
 cout<<"OPER : /"<<endl;
 z=x/y;
 x.ShowComplex();
 y.ShowComplex();

}



 

객체지향 - Class

카테고리 없음 2009. 11. 6. 12:22 Posted by 보노보노보노

/* 09-11-06 FRI Obj_*/
#include<iostream>
using namespace std;

class Complex
{
 private :
   int real;
   int image;
 public:
   Complex(int r=0,int i=0);
   void ShowComplex();
   void SetReal(int r);
   void SetImage(int i);
   int  GetReal();
   int  GetImage();
   void ReFresh(int r, int i);

   void OPer(char op, Complex a, Complex b);
};

Complex::Complex(int r, int i){
 real = r;  image = i;  }


void Complex::OPer(char op, Complex a, Complex b){
 if(op=='+'){
  real = a.GetReal() +  b.GetReal();
  image = a.GetImage() + b.GetImage();
 }else if(op=='-'){
  real = a.GetReal() - b.GetReal();
  image = a.GetImage() - b.GetImage();
 }
}

void Complex::ReFresh(int r, int i){
 real = r; image = i; }

void Complex::SetReal(int r)  { real = r;   }
void Complex::SetImage(int i) { image = i;  }

int Complex::GetReal() {  return real;  }
int Complex::GetImage() {  return image; }

void Complex::ShowComplex(){
 cout<<"("<< real <<" + "<< image <<" i )"<<endl;  }


void main()
{
 Complex x(10,20);
 Complex y(20,5);
 Complex z;

 cout<<"x = ";  x.ShowComplex();
 cout<<"y = ";  y.ShowComplex();
 cout<<"z = ";  z.ShowComplex();
 cout<<endl;
 /*z.ReFresh( x.GetReal() + y.GetReal(),
    x.GetImage() + y.GetImage()
    );
 */

 z.OPer('+',x,y);
 cout<<"x + y = ";  z.ShowComplex();

 z.OPer('-',x,y);
 cout<<"x - y = ";  z.ShowComplex();

}



 

글리치(glich)

학습 2009. 5. 3. 20:31 Posted by 보노보노보노

글리치(Glitch)

 불필요한 부분에 발생하는 노이즈 펄스로 인해 일어나는 컴퓨터의 일시적인 오동작. 잘못된 출력이나 시스템 충돌을 일으키는 원인이 된다. 글리치가 하드웨어적인 문제인 데 비해, 소프트웨어적인 문제로 오동작이 일어나는 것을 버그라고 한다.



얼굴인식을 통한 UI구현

UI & GUI 2009. 4. 5. 03:40 Posted by 보노보노보노
faceAPI : 웹캠으로 얼굴인식을 하여, 얼굴이 화면에 가까이 오면, 3차원 오브젝트와 가까워지고, 얼굴과 멀어지면, 오브젝트도 멀어진다. 또한, 얼굴을 좌우로 이동하면, 오브젝트도 따라서 움직인다.












 닌텐도 wii모콘 끝에 달려있는 적외선 카메라를 모니터에 달고, 기존 TV위에 설치하던 LED 센서를 모자에 달아, 얼굴을 쉽게 추적하게 한 프로토타입... 위의 데모와 거의 유사한 형태이다. 제작은 카네기 멜른의 Johnny Chung Lee... 참고로 위모트는 1024x768 해상도의 적외선 카메라가 달려있고, 100Hz로 4점 트래킹이 가능하며, 100Hz로 동작하는 +/-3g 8비트 3축 가속센서(accelerometer)가 포함되어 있다.




휴대폰이나 PC에는 이미 나를 찍는 카메라가 달려있기 때문에, 향후, 휴대폰이나 PC등에서 위의 3차원 기술등이 적용된 어플리케이션, 게임들을 쉽게 볼 수 있을 것이다.

출처 : 몬스터 디자인그룹
http://monsterdesign.tistory.com/850


FT232 가지고 놀기 Part.2

프로젝트/FTDI 2009. 2. 26. 19:18 Posted by 보노보노보노

이것은 USB로 PC와 시리얼 로 접속한뒤 블루투스나 Rs-232로 데이터를 전송하는 모듈이다.

모듈은 내부 핀설정을 통해 블루투스에서 받은 데이터를 RS-232C로 전송하거나

RS-232로 받은 데이터를 블루투스로 보내는 어답터 역활을 수행하기도 한다.
흰색부분이 3pin RS-232신호핀이다.

위의 점퍼로 설정이 가능 한데, 저 점퍼를 세로로 하면 BT-RE232C 통신이 가능하다.