Align camera position and rotation
조회 수: 2 (최근 30일)
이전 댓글 표시
So I have a list of faces and vertices, which I render with as a patch. The result is a 3d object consisting of triangles. Now I want to be able to specify a triangle (consisting of 3 points) and let the camera focus to this face of the whole object. This means that the camera don't show the whole object, but sets the camera position somewhere near the midpoint of the wanted faces. Additionally the camera should be aligned with the normal of the face i.e. the rendered image is parallel to the face.
So far I computed the midpoint and the normal
mp = mean([p1, p2 ,p3],2)'
normal = cross(p1 - p2, p1 - p3)'
But set the camera to the right position
view(normal);
campos(mp);
set(gca,'CameraPosition',mp);
This functions seems to have the same effect. The camera is rotated somehow, but still the whole object is visible and also it seems like the camera is not always aligned with the normal. Do you have any idea how to solve this?
댓글 수: 0
답변 (1개)
Vidip
2024년 8월 27일
I undertsand that you want to achieve the desired camera view where the camera focuses on a specific face of a 3D object and aligns with the face's normal.
You need to adjust the offset value to ensure the camera is far enough from the triangle to view it comfortably and the choice of the up vector can affect the orientation of the camera view. So, ensure it is orthogonal to the normal and not parallel to it.
Also, you can adjust the camera view angle according to your need by using "camva" function. Please refer to the below dcoumentation of "camup" and "camva" to get more information:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 MATLAB Support Package for USB Webcams에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!