문제

나를 생성하는 광선에서 카메라를 통해 보기입니다.이를 위해서,내 카메라 위치를("아이"),최대,오른쪽으로는 벡터(곳으로는 벡터에서 카메라는 방향에는 개체의 카메라가보고서),P,점에서 보기입니다.면 나는 이레이 생성되는가:

ray = camera_eye + t*(P-camera_eye);

t 은 거리와 함께 레이(가 t=1 현재).

나의 질문은,어떻게 획득하 3D 좌표의점 P 주어진 그것은 위치에서 위치를(i,j)에 보면?가정 왼쪽과 오른쪽 하단 모서리의 보기 주어진다.

참고:기기가 실제로 비행기에서 의미하지 않는 것 무한하게 확장에서 모든 방향.오히려,하나 생각할 수 있습니다 이 비행기적으로 너비 x 높 이미지입니다.X 방향,범위는 0-->폭 y 방향의 범위가 0-->높이입니다.내가 찾 3D 좌표계의(i,j)번째 요소,0

도움이 되었습니까?

해결책 3

때로 직접 연결에서 제안한 수식으로 내 산의 샘을 찾아가 직접 시음하길 권하지 않았을 얻 정확한 결과를(아마도 디버깅 할 필요가를 수행할 수 있습니다).내 초기에 문제가 될 듯에서 오해의(x,y,z)의 좌표를 보간 코너에 포인트입니다.나는 치료하는 x,y,z 좌표를 별도로 곳에 나가지 않아야(그리고 이 될 수있다 특정 응용 프로그램,카메라를 지정할 수 있는 어떤 방향으로).대신,해결책을 수 있는 간단한 보간의 모서리 점의 보 비행기:

  • 보간 하단 모서리 점에서 나는 방향으로 P1
  • 보간 상단 모서리 점에서 나는 방향으로 P2
  • 보간 P1 및 P2j 방향으로 세계의 좌표 최종점

다른 팁

General solution of the itnersection of a line and a plane see http://local.wasp.uwa.edu.au/~pbourke/geometry/planeline/

Your particular graphics lib (OpenGL/DirectcX etc) may have an standard way to do this

edit: You are trying to find the 3d intersection of a screen point (eg a mouse cursor) with a 3d object in you scene?

To work out P, you need the distance from the camera to the near clipping plane (the screen), the size of the window on the near clipping plane (or the view angle, you can work out the window size from the view angle) and the size of the rendered window.

  1. Scale the screen position to the range -1 < x < +1 and -1 < y < +1 where +1 is the top/right and -1 is the bottom/left
  2. Scale normalised x,y by the view window size
  3. Scale by the right and up vectors of the camera and sum the results
  4. Add the look at vector scaled by the clipping plane distance

In effect, you get:

p = at * near_clip_dist + x * right + y * up

where x and y are:

x = (screen_x - screen_centre_x) / (width / 2) * view_width
y = (screen_y - screen_centre_y) / (height / 2) * view_height
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top