Projection

Class parallel-projection and perspective-projection process projection transformation, which is represented with a 4X4 matrix, i.e., the transformation is taken in the three dimensional homogeneous coordinates. Class projection is an abstract class for both of these. Since these projection classes inherit the viewing class, two coordinates transformation, world-to-viewing and projection can be performed at the same time. By sending the :project3 message with a 3D vector to a projection object, a float-vector of four elements is returned. Homo2normal function is used to convert this homogeneous vector to the normal representation. The result is a vector represented in so called normalized device coordinates (NDC), in which a visible vector ranges within -1 to 1 in each of x,y, and z dimensions. For the simulation of real cameras in a robot world, the perspective projection is used more often than the parallel-projection. Perspective-projection defines a few more parameters. Screenx and screeny are the sizes of the window on the viewing plane on which observed objects are projected, and with the larger screen, the wider space is projected. Viewdistance which defines the distance between the viewpoint and the viewplane also concerns with the viewing angle. The larger viewdistance maps the smaller region to the window on the view plane. Hither and yon parameters determine the distance to the front and back depth clipping planes. Objects outside these two planes are clipped out. Actually, this clipping procedure is performed by the viewport object.




projection [class]


  :super   viewing 

:slots (screenx screeny hither yon projection-matrix)


defines projection transformation with a 4x4 matrix.


:projection &optional pmat [method]

if pmat is given, it is set to the projection-matrix slot. :projection returns the current 4x4 projection matrix.


:project vec [method]
Vec is a three-dimensional homogeneous float-vector of four elements. Vec is transformed by projection-matrix, and the resulted homogeneous representation is returned.


:project3 vec [method]
Vec is a normal 3D float-vector. Vec is homogenized and transformed by projection-matrix, and the resulted homogeneous representation is returned.


:view vec [method]
applies viewing transformation and projection transformation to vec successively. The resulted homogeneous representation is returned.


:screen xsize (&optional (ysize xsize)) [method]
changes the size of the viewing screen. The larger the size, the wider view you get.


:hither depth-to-front-clip-plane [method]
determines the distance from the viewpoint to the front-clipping plane. Objects before the front-clipping (hither) plane are clipped out.


:yon depth-to-back-clip-plane [method]
changes the distance between the viewpoint and the back-clipping plane. Objects behind the back-clipping (yon) plane are clipped out.


:aspect &optional ratio [method]
Aspect ratio is the ratio between screen-y and screen-x. If ratio is given, the aspect ratio is changed by setting screen-y to screen-x * ratio. :aspect returns the current aspect ratio.



\begin{emtabbing}
{\bf :init}
\it
\&key \= :hither \hspace{5mm} \= 100.0 \\lq [met...
... :screen-y \> (* screen-x aspect) \\
\> \&allow-other-keys
\rm
\end{emtabbing}
initializes viewing and projection.





parallel-viewing [class]


  :super   projection 

:slots ()


defines parallel projection. Hid (the hidden-line elimination function) cannot handle parallel projection.


:make-projection [method]




perspective-viewing [class]


  :super   projection 

:slots (viewdistance)


defines a perspective projection transformation.


:make-projection [method]



:ray u v [method]
returns the normalized direction-vector pointing (u,v) on the normalized screen from the viewpoint.


:viewdistance &optional vd [method]
Viewdistance is the distance between viewpoint and the screen. If vd is given, it is set to viewdistance. The viewdistance corresponds to the focal length of a camera. The greater the viewdistance, the more zoomed-up view you get. :viewdistance returns the current viewdistance.


:view-angle &optional ang [method]
set screen size so that the prospective angle of the diagonal of the screen becomes ang radian. Note that angles somewhat between 20 degree (approx. 0.4 rad.) and 50 degree (0.9 rad.) can generate a natural perspective view. Wider angle generates a skewed view, and narrower a flat view like orthogonal (parallel) viewing. :view-angle returns current or new view angle in radian.


:zoom &optional scale [method]
If scale is given, the screen is changed relatively to the current size by scale (the viewdistance is unchanged). If you give 0.5 for scale, you get two times as wide view as before. :zoom returns new view angle in radian.


:lookaround alfa beta [method]
translates and rotates the viewpoint. The center of rotation is taken at the midst of the hither plane and the yon plane on the viewline. The viewing coordinates is rotated alfa radian around world's z-axis and beta radian around x-axis locally. :lookaround allows you to move around the object in the center of viewing.


:look-body bodies [method]
changes view direction, screen sizes, and hither/yon so that all the bodies fit in the viewport. Viewpoint does not change. View direction is chosen so that the viewing line penetrate the center of the bounding box of all bodies.


:init &key (:viewdistance 100.0) &allow-other-keys [method]


k-okada 2013-05-21