기본 콘텐츠로 건너뛰기

2월, 2010의 게시물 표시

선분과 한점의 수직 거리 구하기

Minimum Distance between a Point and a Line   Written by Paul Bourke October 1988   This note describes the technique and gives the solution to finding the shortest distance from a point to a line or line segment. The equation of a line defined through two points P1 (x1,y1) and P2 (x2,y2) is P = P1 + u ( P2 - P1 ) The point P3 (x3,y3) is closest to the line at the tangent to the line which passes through P3 , that is, the dot product of the tangent and line is 0, thus ( P3 - P ) dot ( P2 - P1 ) = 0 Substituting the equation of the line gives [ P3 - P1 - u( P2 - P1 )] dot ( P2 - P1 ) = 0 Solving this gives the value of u Substituting this into the equation of the line gives the point of intersection (x,y) of the tangent as x = x1 + u (x2 - x1) y = y1 + u (y2 - y1) The distance therefore between the point P3 and the line is the distance between (x,y) above and P3 . Notes The only special testing for a software implementation

프로그래머에게 유용한 사이트들

OpenGL 오픈지엘 - 오픈지엘 공식 사이트, 생각외로 뉴스가 잘 올라온다. NeHe Tutorial - OpenGL Tutorial. 내용도 좋지만, 각 플랫폼, 언어별로 구현된 소스가 유용. OpenGL man page - OpenGL MAN 페이지. 일종의 매뉴얼. OpenGL Manual - SGI 의 OpenGL 1.2 매뉴얼 GL4Java - 자바를 위한 OpenGL OpenGL Win32 Tutorial - OpenGL Win32 Toturial GLUT3 - glut3 소스 및 다운로드. glut for win32 - Glut for Win32 DLL Download OpenGL Gamedev - OpenGL Gamedev FAQ & Mailing list cannon_smash - OpenGL 로 만든 오픈소스 탁구게임 OpenGL FAQ - OpenGL FAQ OpenGL Reference Manual - 온라인북 OpenGL Programming Guide - 온라인북 OpenGL 수퍼 바이블 - 온라인북 OpenGL 튜토리얼 링크 - OpenGL 튜토리얼 링크 OpenGL 게임개발 FAQ - OpenGL 게임개발 FAQ GLVelocity - OpenGL 관련 소스 및 뉴스, 토론 등등 DelphiGL - Delphi 로 하는 OpenGL Yindo - 차세대 웹 애플리케이션 Dip2K's OpenGL - 여러 GL 관련 예제가 있는 국내 OpenGL 관련 사이트 GLScene - OpenGL Solution for Delphi FLTK - OpenGL 그래픽 유저인터페이스 라이브러리(LGPL) Quesa - Apple Quick Draw 3D Open-source Implementation GLdomain - 파티클, 그라비티 등에 관한 튜토리얼 게임튜토리얼 - 오픈지엘 튜토리얼 및 MP3 라이브러리, 쓰레드 예제 등등이 있다. Delphi3D - 델파이와 OpenGL를 사용한 최신 그래픽 기술에 관한 정보  

OpenCV: fit line (line-fitting )

// fit-line for 2-D data (line-fitting) http://blog.weisu.org/2006/01/opencv-fit-line-line-fitting_14.html #include "stdafx.h" #include "cv.h" #include "highgui.h" #include <stdlib.h> void main ( int argc , char ** argv ) { FILE * fp ; int i ; int count = 48 ; // total number of points int tmp1 , tmp2 ; CvPoint left , right ; float * line ; line = new float [ 4 * count ]; IplImage * img = cvLoadImage ( "b.bmp" , 1 ); // just a black image cvNamedWindow ( "input_image" , CV_WINDOW_AUTOSIZE ); fp = fopen ( "xy.txt" , "r" ); // xy.txt have the (x, y) position CvPoint * points = ( CvPoint *) malloc ( count * sizeof ( points [ 0 ])); for ( i = 0 ; i < count ; i ++) { fscanf ( fp , "%d %d" , & tmp1 , & tmp2 ); points [ i ]. x = tmp1 ;

MFC::Class 접근

CTestApp, CMainFrame, CTestDoc, CTestView ◎ CTestApp에서 CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); CTestDoc* pDoc = (CTestDoc*)((CMainFrame*)AfxGetMainWnd())->GetActiveDocument(); CTestView* pView = (CTestView*)((CMainFrame*)AfxGetMainWnd())->GetActiveView(); ◎ CMainFrame에서 CTestApp* pApp = (CTestApp*)AfxGetApp(); CTestDoc* pDoc = (CTestDoc*)GetActiveDocument(); CTestView* pView = (CTestView*)GetActiveView(); ◎ CTestDoc에서 CTestApp* pApp = (CTestApp*)AfxGetApp(); CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); CTestView* pView = (CTestView*)((CMainFrame*)AfxGetMainWnd())->GetActiveView(); ◎ CTestView에서 CTestApp* pApp = (CTestApp*)AfxGetApp(); CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();             or (CMainFrame*)GetParent(); CTestDoc* pDoc = (CTestDoc*)((CMainFrame*)AfxGetMainWnd())->GetActiveDocument();          or (CTestDoc*)GetDocument();