검색결과 리스트
Skills에 해당되는 글 22건
- 2015.08.10 MS Word에서 두 문서 비교하기 (버전 비교)
- 2015.06.22 [OpenGL] 3D coordinates from 2D mouse click ( Convert Screen Coordinate to World Coordinate )
- 2015.06.08 KB954430 자꾸만 다시 설치하라고 할 때..
- 2015.05.21 MATLAB에서 Figure docking (default) 1
- 2015.05.19 컴퓨터의 주요 부품에 관하여..
- 2015.01.15 [Assertion failed] wincore.cpp error line 952
- 2014.12.16 C++ 반전 연산자~와 논리 연산자 !의 차이
- 2014.12.15 공유 메모리를 이용한 IPC
- 2014.12.15 MFC dialog에서 콘솔(console)로 디버깅하기
- 2014.12.09 [C/C++] double 형 데이터에 분수 넣기
글
MS Word에서 두 문서 비교하기 (버전 비교)
가끔 문서 작업을 하다보면, 자주 수정하게 되어 버전 관리를 한다거나 혹은 여러 명이 수정을 거치게 되는 경우가 있다.
그 때 유용한 기능이 있음.
MS Word의 리본메뉴 중 검토 메뉴의 하위 메뉴 중에서 아래 붉게 네모친 곳을 보면 "비교" 라는 것을 볼 수 있다.
이것을 눌러보면 아래 그림처럼 두 문서의 변경 내역을 한 눈에 검토할 수 있다. (엄청나게 편리하다!!)
사용 방법은 "비교" 버튼을 눌러보면 너무나 쉽게 알 수 있기 때문에 생략하기로 한다.
글
[OpenGL] 3D coordinates from 2D mouse click ( Convert Screen Coordinate to World Coordinate )
[1]
GLpoint GetOGLMousePos(GLint x, GLint y) { GLfloat winX = 0.0, winY = 0.0, winZ = 0.0; // never ever make a mistake between float and double. I wasted my 4 days to solve this and the problem was, I was using GLdouble here instead of GLfloat. Try GLdouble here you will see a hell difference in output values. GLdouble posX = 0.0, posY = 0.0, posZ = 0.0; winX = (float)x; winY = (float)OGLMviewport[3] - (float)y; // invert winY so that down lowers value glReadPixels( x, int(winY), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ ); gluUnProject( winX, winY, winZ, OGLMmodelview, OGLMprojection, OGLMviewport, &posX, &posY, &posZ); return GLpoint(posX, posY, -posZ); // invert z value }
[2]
private void glControl1_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e) { if (!loadedTK) return; // Play nice int[] viewport = new int[4]; double[] modelViewMatrix = new double[16]; double[] projectionMatrix = new double[16]; if (checkBoxSelectPoints.Checked == true) { int mouseX = e.X; int mouseY = e.Y; //Get Matrix OpenTK.Graphics.OpenGL.GL.GetInteger(OpenTK.Graphics.OpenGL.GetPName.Viewport, viewport); OpenTK.Graphics.OpenGL.GL.GetDouble(OpenTK.Graphics.OpenGL.GetPName.ModelviewMatrix, modelViewMatrix); OpenTK.Graphics.OpenGL.GL.GetDouble(OpenTK.Graphics.OpenGL.GetPName.ProjectionMatrix, projectionMatrix); //Calculate NearPlane point and FarPlane point. One will get the two end points of a straight line //that "almost" intersects the plotted point you "clicked". Vector3 win = new Vector3(mouseX, viewport[3] - mouseY, 0); Vector3 worldPositionNear; Glu.UnProject(win, modelViewMatrix, projectionMatrix, viewport, out worldPositionNear); win.Z = 1.0f; Vector3 worldPositionFar; Glu.UnProject(win, modelViewMatrix, projectionMatrix, viewport, out worldPositionFar); //Calculate the lenght of the straigh line (the distance between both points). double distanceNF = Math.Sqrt(Math.Pow(worldPositionNear.X - worldPositionFar.X, 2) + Math.Pow(worldPositionNear.Y - worldPositionFar.Y, 2)+ Math.Pow(worldPositionNear.Z - worldPositionFar.Z, 2)); double minDist = distanceNF; //Calculate which of the plotted points is closest to the line. In other words, // look for the point you tried to select. Calculate the distance between the 2 endpoints that passes through // each plotted point. The one that is most similar with the straight line will be the selected point. int selectedPoint = 0; for (int i = 0; i < PointsInfo.Count; i++) { double d1 = Math.Sqrt(Math.Pow(worldPositionNear.X - PointsInfo[i].Position.X, 2) + Math.Pow(worldPositionNear.Y - PointsInfo[i].Position.Y, 2) + Math.Pow(worldPositionNear.Z - PointsInfo[i].Position.Z, 2)); double d2 = Math.Sqrt(Math.Pow(PointsInfo[i].Position.X - worldPositionFar.X, 2) + Math.Pow(PointsInfo[i].Position.Y - worldPositionFar.Y, 2) + Math.Pow(PointsInfo[i].Position.Z - worldPositionFar.Z, 2)); if (((d1 + d2) - distanceNF) <= minDist) { minDist = (d1 + d2) - distanceNF; selectedPoint = i; } } //Just select/unselect points if the "click" was really close to a point. Not just by clicking anywhere in the screen if (minDist < 0.000065) { if (selectedPoints.Contains(selectedPoint)) selectedPoints.Remove(selectedPoint); else selectedPoints.Add(selectedPoint); glControl1.Invalidate(); //paint again } }
[3]
private Vector3d GetOGLPos(int x, int y)
{
int[] viewport = new int[4];
double[] matrixprojection = new double[16];
double[] matrixmodeview = new double[16];
double WinX, WinY;
float[] WinZ = new float[1];
double PosX, PosY, PosZ;
IntPtr PixelPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(sizeof(float));
GL.glGetDoublev(GL.GL_PROJECTION_MATRIX, matrixprojection);
GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, matrixmodeview);
GL.glGetIntegerv(GL.GL_VIEWPORT, viewport);
GL.glEnable(GL.GL_DEPTH_TEST);
GL.glDepthMask(1);
GL.glDepthRange(0, 1);
System.Runtime.InteropServices.Marshal.Copy(WinZ, 0, PixelPtr, 1);
WinX = (double)x;
WinY = (double)viewport[3] - (double)y;
GL.glReadPixels(x, (int)WinY, 1, 1, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, PixelPtr);
System.Runtime.InteropServices.Marshal.Copy(PixelPtr, WinZ, 0, 1);
System.Runtime.InteropServices.Marshal.FreeHGlobal(PixelPtr);
GL.gluUnProject(WinX, WinY,(double)WinZ[0], matrixmodeview, matrixprojection, viewport,out PosX,out PosY,out PosZ);
//PosZ = (double)WinZ[0];
Vector3d result = new Vector3d(PosX, PosY, PosZ);
return result;
}
* Ref
[1] http://www.gamedev.net/topic/632454-incorrect-3d-coordinates-from-2d-mouse-click/
[2] http://www.opentk.com/node/1892
[3] http://www.opentk.com/node/480
'Skills > Programming' 카테고리의 다른 글
[안드로이드] 디바이스를 못찾을 때.. (0) | 2016.02.06 |
---|---|
MFC에서 소켓통신이 잘 안될 때.. [유니코드 멀티바이트] (0) | 2016.01.14 |
KB954430 자꾸만 다시 설치하라고 할 때.. (0) | 2015.06.08 |
MATLAB에서 Figure docking (default) (1) | 2015.05.21 |
[Assertion failed] wincore.cpp error line 952 (0) | 2015.01.15 |
글
KB954430 자꾸만 다시 설치하라고 할 때..
아래 사이트를 참조하자.
https://social.technet.microsoft.com/Forums/windows/ko-KR/646651ca-1a32-46d3-bc5e-8d8a77eff9a7/update-kb954430?forum=w7itprogeneral
'Skills > Programming' 카테고리의 다른 글
MFC에서 소켓통신이 잘 안될 때.. [유니코드 멀티바이트] (0) | 2016.01.14 |
---|---|
[OpenGL] 3D coordinates from 2D mouse click ( Convert Screen Coordinate to World Coordinate ) (0) | 2015.06.22 |
MATLAB에서 Figure docking (default) (1) | 2015.05.21 |
[Assertion failed] wincore.cpp error line 952 (0) | 2015.01.15 |
C++ 반전 연산자~와 논리 연산자 !의 차이 (0) | 2014.12.16 |
글
MATLAB에서 Figure docking (default)
MATLAB을 사용하다보면 figure를 main GUI에 docking하고 싶을 때가 있다. (default로..)
아래를 참조하면 된다!!
I just wanted to pass along a small tip that you might find useful. If you’ve become as big of a fan of docked figures as I have, you might be looking for a way to have figures docked by default when they are created. This is easy to do (but not obvious) by modifying default figure properties. The following command will cause all subsequent new figures in the current MATLAB session to open docked:
Put this command in your startup.m file for this to be the default behavior for every MATLAB session.
Don’t like it?
This will set things back to normal.
Want to understand how this command works?
This is the standard graphics set command. The first argument is the handle to the root graphics object, i.e. the screen. This applies to all subequently generated graphics objects. When a figure is docked, it’s WindowStyle property is set to ‘docked’. Since this is a Figure property, I can modify it’s default behavior by appending DefaultFigure to WindowStyle. Hence,
* Ref.
[1] http://blogs.mathworks.com/pick/2005/11/15/default-docked-figures/
'Skills > Programming' 카테고리의 다른 글
[OpenGL] 3D coordinates from 2D mouse click ( Convert Screen Coordinate to World Coordinate ) (0) | 2015.06.22 |
---|---|
KB954430 자꾸만 다시 설치하라고 할 때.. (0) | 2015.06.08 |
[Assertion failed] wincore.cpp error line 952 (0) | 2015.01.15 |
C++ 반전 연산자~와 논리 연산자 !의 차이 (0) | 2014.12.16 |
공유 메모리를 이용한 IPC (0) | 2014.12.15 |
글
컴퓨터의 주요 부품에 관하여..
컴퓨터의 주요 부품에는 CPU, 램, HDD 가 있습니다.
CPU는 연산장치, 램은 주기억장치, HDD는 보조기억장치 라고 생각하면 됩니다.
아주 좋은 예를 보게 되었습니다.
cpu는 사람의 두뇌, 캐쉬메모리는 기억력, HDD는 메모장!!
어떤 문제를 풀 때, 기억해서 바로 계산할 수 있으면 캐쉬메모리의 데이터를 쓰는 것이고
기억이 안나서 메모장을 뒤져야 한다면 HDD를 뒤지는 것이다!
HDD는용량은 크지만 속도가 매우 느립니다.
캐쉬메모리에는 L1 ~ L3 까지 있습니다.
L1이 가장 가깝고 CPU에 내장되어 있어 빠름.
L2는 CPU와 함께 칩으로 따로 존재 하고 있으며 그 다음으로 빠름.
L3는 가장 멀리 있으며 메인보드에 존재하고 있음.
(요새 나오는 CPU는 L3를 지원합니다)
어쨌거나 캐쉬메모리는 용량이 작습니다. 속도는 빠르지만 단일기억이라고 생각하면 되겠습니다.
캐쉬 메모리와 HDD 사이의 중간 다리 역할을 하는 것이 RAM이라고 생각하시면 되겠습니다.
하지만 RAM은 컴퓨터가 꺼지면 저장하고 있던 데이터를 모두 잃어버립니다.
램은 HDD로부터 필요한 데이터를 받아서 CPU로 전달을 해 줍니다.
(예를 들어 게임을 로딩하는 것 역시 HDD로부터 램으로 데이터를 전달하는 것이라고 하네요!!)
'Skills > Computer' 카테고리의 다른 글
JPEG 이미지 축소 (용량 축소 / 사이즈 축소) (0) | 2016.07.13 |
---|---|
아웃룩(outlook) 익스체인지(exchange) 데이터 파일 (.pst) 변경 (0) | 2016.03.08 |
드롭박스(dropbox) 가입과 동시에 용량 늘리기 (1) | 2016.01.20 |
Aten cs1782 kvm switch 사용기 (0) | 2015.08.31 |
글
[Assertion failed] wincore.cpp error line 952
MFC does not support calling a window from a thread that did not create the window. Your call to OnIdle violates that restriction.
Each thread uses a separate message queue, so it is also a bad idea to attempt to use the main message queue from your thread.
Why are you creating windows in your thread? It is best to create all windows in the main thread, and use secondary threads for non-GUI processing.
When you create a thread in an MFC program you are supposed to use AfxBeginThread, not the CreateThread API. AfxBeginThread will call CreateThread for you, after doing whatever MFC needs in order to work properly.
* Ref
https://social.msdn.microsoft.com/Forums/vstudio/en-US/38f58a71-2d5f-44fd-b3a1-37bafa6e54bd/assert-in-multithread-program-with-function-onidle0?forum=vcgeneral
'Skills > Programming' 카테고리의 다른 글
KB954430 자꾸만 다시 설치하라고 할 때.. (0) | 2015.06.08 |
---|---|
MATLAB에서 Figure docking (default) (1) | 2015.05.21 |
C++ 반전 연산자~와 논리 연산자 !의 차이 (0) | 2014.12.16 |
공유 메모리를 이용한 IPC (0) | 2014.12.15 |
MFC dialog에서 콘솔(console)로 디버깅하기 (0) | 2014.12.15 |
글
C++ 반전 연산자~와 논리 연산자 !의 차이
case CMD_TELEOPERATION:
{
bETRI_Tele = !bETRI_Tele;
cout<<"bETRI_Tele : "<<bETRI_Tele<<endl;
}
MFC 다이얼로그를 통해 버튼을 누르면 위의 코드에 들어가게 해 두었다.
그런데 이상한 점 발견!
bETRI_Tele = ~bETRI_Tele; 로 할 때에는 cout이 계속 1의 값을 반환한다는 것이다!
그러나 bETRI_Tele = !bETRI_Tele; 로 할 때에는 버튼을 누를 때마다 0과 1의 값이 반복되면서 제대로 잘 나온다.
일단, 그 원인은 ~가 bit 연산자라는 것에 있을 것으로 판단되고 boolean이 bit로 보았을 때에는 단순한 1과 0 이 아닐 것이라는 추측이 된다.
'Skills > Programming' 카테고리의 다른 글
MATLAB에서 Figure docking (default) (1) | 2015.05.21 |
---|---|
[Assertion failed] wincore.cpp error line 952 (0) | 2015.01.15 |
공유 메모리를 이용한 IPC (0) | 2014.12.15 |
MFC dialog에서 콘솔(console)로 디버깅하기 (0) | 2014.12.15 |
[C/C++] double 형 데이터에 분수 넣기 (0) | 2014.12.09 |
글
공유 메모리를 이용한 IPC
IPC (Inter Process Communication)란, 프로세스 간에 정보를 주고받을 수 있도록 하는 통신 기법
32bit 시스템에서는 각 프로세스에 제공되는 연속적인 4GB의 가상 메모리를 사용하는데, 가상 메모리 중 절반은 사용자 모드(스택, 힙)에 사용하고 나머지 절반은 커널 모드(운영체제가 관리)에 사용한다.
공유 메모리를 이용한 IPC는 커널 모드의 메모리 영역을 활용하여 프로세스 간에 서로 통신하는 기법임.
* Ref (or copied from)
[1] 열혈강의 VISUAL C++ 2008 MFC 윈도우 프로그래밍, 최호성, 2009.
'Skills > Programming' 카테고리의 다른 글
[Assertion failed] wincore.cpp error line 952 (0) | 2015.01.15 |
---|---|
C++ 반전 연산자~와 논리 연산자 !의 차이 (0) | 2014.12.16 |
MFC dialog에서 콘솔(console)로 디버깅하기 (0) | 2014.12.15 |
[C/C++] double 형 데이터에 분수 넣기 (0) | 2014.12.09 |
첫째 예외가 있습니다. 0xC0000005: 0x00000018 위치를 읽는 동안 액세스 위반이 발생했습니다. (0) | 2014.11.12 |
글
MFC dialog에서 콘솔(console)로 디버깅하기
MFC 다이얼로그를 이용하다 보면, 콘솔 응용프로그램을 코딩할 때처럼 printf 나 cout 같은 것으로 디버깅하고 싶을 때가 있다.. 그럴 떄 아래와 같은 방법으로 해결할 수 있다.
방법 1
App의 InitInstance에서 AllocConsole()을 호출한다.
디버그 모드에서만 동작할 것이므로 간단히 다음과 같이 할 수 있겠다.
#ifdef _DEBUG
if( !AllocConsole() )
{
AfxMessage(_T("Failed to create the console!"), MB_ICONEXCLAMATION);
}
#endif
해제하기 위해서는 ExitInstance에서 FreeColsole()을 호출한다.
이전과 마찬가지로 다음과 같이 쓰면 된다.
#ifdef _DEBUG
if( !FreeConsole() )
{
AfxMessage(_T("Failed to free the console!"), MB_ICONEXCLAMATION);
}
#endif
방법 2
stdafx.h에서 다음과 같이 입력한다.
#ifdef _DEBUG
#pragma comment(linker, "/entry:WinMainCRTStartup /subsystem:console")
#endif
출력은 일반적인 콘솔 프로그램과 같이 cout이나 printf 등을 사용하면 된다.
'Skills > Programming' 카테고리의 다른 글
C++ 반전 연산자~와 논리 연산자 !의 차이 (0) | 2014.12.16 |
---|---|
공유 메모리를 이용한 IPC (0) | 2014.12.15 |
[C/C++] double 형 데이터에 분수 넣기 (0) | 2014.12.09 |
첫째 예외가 있습니다. 0xC0000005: 0x00000018 위치를 읽는 동안 액세스 위반이 발생했습니다. (0) | 2014.11.12 |
클래스 객체 생성 방법에 관하여.. (new 사용에 관하여) (0) | 2014.11.12 |
글
[C/C++] double 형 데이터에 분수 넣기
함수를 정의할 때, parameter로 double 형 데이터를 활용하게 되는 경우가 종종 있다.
그런데 이 때, 함수를 사용하는 쪽에서 double 형 데이터에 소수점 값을 넣게되는 경우가 있는데
소수점 값을 직접 입력하지 않고 분수로 값을 입력할 때 실수가 가장 많다.
예를 들면 아래와 같은 코드를 생각해 보자.
#include <stdio.h>
void test(double num)
{
printf("%lf \n", num);
}
int main()
{
test(0.001);
test(1/1000);
return 1;
}
이 때, 1/1000 을 넣으면 값은 0 이 나온다.
분수의 형태로 넣고 싶다면 1.0/1000.0 처럼 double 형으로 인식할 수 있도록 해 주어야 한다.
(혹은 casting을 해 주어도 괜찮다.)
'Skills > Programming' 카테고리의 다른 글
C++ 반전 연산자~와 논리 연산자 !의 차이 (0) | 2014.12.16 |
---|---|
공유 메모리를 이용한 IPC (0) | 2014.12.15 |
MFC dialog에서 콘솔(console)로 디버깅하기 (0) | 2014.12.15 |
첫째 예외가 있습니다. 0xC0000005: 0x00000018 위치를 읽는 동안 액세스 위반이 발생했습니다. (0) | 2014.11.12 |
클래스 객체 생성 방법에 관하여.. (new 사용에 관하여) (0) | 2014.11.12 |