FreeMat

- Main Page
- Related Pages

vtkCamera

Section: Visualization Toolkit Rendering Classes

# Usage

vtkCamera is a virtual camera for 3D rendering. It provides methods to position and orient the view point and focal point. Convenience methods for moving about the focal point also are provided. More complex methods allow the manipulation of the computer graphics model including view up vector, clipping planes, and camera perspective.

To create an instance of class vtkCamera, simply invoke its constructor as follows

      obj = vtkCamera

# Methods

The class vtkCamera has several methods that can be used. They are listed below. Note that the documentation is translated automatically from the VTK sources, and may not be completely intelligible. When in doubt, consult the VTK website. In the methods listed below, `obj` is an instance of the vtkCamera class.

- `string = obj.GetClassName ()`
- `int = obj.IsA (string name)`
- `vtkCamera = obj.NewInstance ()`
- `vtkCamera = obj.SafeDownCast (vtkObject o)`
- `obj.SetPosition (double x, double y, double z)` - Set/Get the position of the camera in world coordinates. The default position is (0,0,1).
- `obj.SetPosition (double a[3])` - Set/Get the position of the camera in world coordinates. The default position is (0,0,1).
- `double = obj. GetPosition ()` - Set/Get the position of the camera in world coordinates. The default position is (0,0,1).
- `obj.SetFocalPoint (double x, double y, double z)` - Set/Get the focal of the camera in world coordinates. The default focal point is the origin.
- `obj.SetFocalPoint (double a[3])` - Set/Get the focal of the camera in world coordinates. The default focal point is the origin.
- `double = obj. GetFocalPoint ()` - Set/Get the focal of the camera in world coordinates. The default focal point is the origin.
- `obj.SetViewUp (double vx, double vy, double vz)` - Set/Get the view up direction for the camera. The default is (0,1,0).
- `obj.SetViewUp (double a[3])` - Set/Get the view up direction for the camera. The default is (0,1,0).
- `double = obj. GetViewUp ()` - Set/Get the view up direction for the camera. The default is (0,1,0).
- `obj.OrthogonalizeViewUp ()` - Recompute the ViewUp vector to force it to be perpendicular to camera->focalpoint vector. Unless you are going to use Yaw or Azimuth on the camera, there is no need to do this.
- `obj.SetDistance (double )` - Move the focal point so that it is the specified distance from the camera position. This distance must be positive.
- `double = obj.GetDistance ()` - Return the distance from the camera position to the focal point. This distance is positive.
- `double = obj. GetDirectionOfProjection ()` - Get the vector in the direction from the camera position to the focal point. This is usually the opposite of the ViewPlaneNormal, the vector perpendicular to the screen, unless the view is oblique.
- `obj.Dolly (double value)` - Divide the camera's distance from the focal point by the given dolly value. Use a value greater than one to dolly-in toward the focal point, and use a value less than one to dolly-out away from the focal point.
- `obj.SetRoll (double angle)` - Set the roll angle of the camera about the direction of projection.
- `double = obj.GetRoll ()` - Set the roll angle of the camera about the direction of projection.
- `obj.Roll (double angle)` - Rotate the camera about the direction of projection. This will spin the camera about its axis.
- `obj.Azimuth (double angle)` - Rotate the camera about the view up vector centered at the focal point. Note that the view up vector is whatever was set via SetViewUp, and is not necessarily perpendicular to the direction of projection. The result is a horizontal rotation of the camera.
- `obj.Yaw (double angle)` - Rotate the focal point about the view up vector, using the camera's position as the center of rotation. Note that the view up vector is whatever was set via SetViewUp, and is not necessarily perpendicular to the direction of projection. The result is a horizontal rotation of the scene.
- `obj.Elevation (double angle)` - Rotate the camera about the cross product of the negative of the direction of projection and the view up vector, using the focal point as the center of rotation. The result is a vertical rotation of the scene.
- `obj.Pitch (double angle)` - Rotate the focal point about the cross product of the view up vector and the direction of projection, using the camera's position as the center of rotation. The result is a vertical rotation of the camera.
- `obj.SetParallelProjection (int flag)` - Set/Get the value of the ParallelProjection instance variable. This determines if the camera should do a perspective or parallel projection.
- `int = obj.GetParallelProjection ()` - Set/Get the value of the ParallelProjection instance variable. This determines if the camera should do a perspective or parallel projection.
- `obj.ParallelProjectionOn ()` - Set/Get the value of the ParallelProjection instance variable. This determines if the camera should do a perspective or parallel projection.
- `obj.ParallelProjectionOff ()` - Set/Get the value of the ParallelProjection instance variable. This determines if the camera should do a perspective or parallel projection.
- `obj.SetUseHorizontalViewAngle (int flag)` - Set/Get the value of the UseHorizontalViewAngle instance variable. If set, the camera's view angle represents a horizontal view angle, rather than the default vertical view angle. This is useful if the application uses a display device which whose specs indicate a particular horizontal view angle, or if the application varies the window height but wants to keep the perspective transform unchanges.
- `int = obj.GetUseHorizontalViewAngle ()` - Set/Get the value of the UseHorizontalViewAngle instance variable. If set, the camera's view angle represents a horizontal view angle, rather than the default vertical view angle. This is useful if the application uses a display device which whose specs indicate a particular horizontal view angle, or if the application varies the window height but wants to keep the perspective transform unchanges.
- `obj.UseHorizontalViewAngleOn ()` - Set/Get the value of the UseHorizontalViewAngle instance variable. If set, the camera's view angle represents a horizontal view angle, rather than the default vertical view angle. This is useful if the application uses a display device which whose specs indicate a particular horizontal view angle, or if the application varies the window height but wants to keep the perspective transform unchanges.
- `obj.UseHorizontalViewAngleOff ()` - Set/Get the value of the UseHorizontalViewAngle instance variable. If set, the camera's view angle represents a horizontal view angle, rather than the default vertical view angle. This is useful if the application uses a display device which whose specs indicate a particular horizontal view angle, or if the application varies the window height but wants to keep the perspective transform unchanges.
- `obj.SetViewAngle (double angle)` - Set/Get the camera view angle, which is the angular height of the camera view measured in degrees. The default angle is 30 degrees. This method has no effect in parallel projection mode. The formula for setting the angle up for perfect perspective viewing is: angle = 2*atan((h/2)/d) where h is the height of the RenderWindow (measured by holding a ruler up to your screen) and d is the distance from your eyes to the screen.
- `double = obj.GetViewAngle ()` - Set/Get the camera view angle, which is the angular height of the camera view measured in degrees. The default angle is 30 degrees. This method has no effect in parallel projection mode. The formula for setting the angle up for perfect perspective viewing is: angle = 2*atan((h/2)/d) where h is the height of the RenderWindow (measured by holding a ruler up to your screen) and d is the distance from your eyes to the screen.
- `obj.SetParallelScale (double scale)` - Set/Get the scaling used for a parallel projection, i.e. the height of the viewport in world-coordinate distances. The default is 1. Note that the "scale" parameter works as an "inverse scale" — larger numbers produce smaller images. This method has no effect in perspective projection mode.
- `double = obj.GetParallelScale ()` - Set/Get the scaling used for a parallel projection, i.e. the height of the viewport in world-coordinate distances. The default is 1. Note that the "scale" parameter works as an "inverse scale" — larger numbers produce smaller images. This method has no effect in perspective projection mode.
- `obj.Zoom (double factor)` - In perspective mode, decrease the view angle by the specified factor. In parallel mode, decrease the parallel scale by the specified factor. A value greater than 1 is a zoom-in, a value less than 1 is a zoom-out.
- `obj.SetClippingRange (double dNear, double dFar)` - Set/Get the location of the near and far clipping planes along the direction of projection. Both of these values must be positive. How the clipping planes are set can have a large impact on how well z-buffering works. In particular the front clipping plane can make a very big difference. Setting it to 0.01 when it really could be 1.0 can have a big impact on your z-buffer resolution farther away. The default clipping range is (0.1,1000).
- `obj.SetClippingRange (double a[2])` - Set/Get the location of the near and far clipping planes along the direction of projection. Both of these values must be positive. How the clipping planes are set can have a large impact on how well z-buffering works. In particular the front clipping plane can make a very big difference. Setting it to 0.01 when it really could be 1.0 can have a big impact on your z-buffer resolution farther away. The default clipping range is (0.1,1000).
- `double = obj. GetClippingRange ()` - Set/Get the location of the near and far clipping planes along the direction of projection. Both of these values must be positive. How the clipping planes are set can have a large impact on how well z-buffering works. In particular the front clipping plane can make a very big difference. Setting it to 0.01 when it really could be 1.0 can have a big impact on your z-buffer resolution farther away. The default clipping range is (0.1,1000).
- `obj.SetThickness (double )` - Set the distance between clipping planes. This method adjusts the far clipping plane to be set a distance 'thickness' beyond the near clipping plane.
- `double = obj.GetThickness ()` - Set the distance between clipping planes. This method adjusts the far clipping plane to be set a distance 'thickness' beyond the near clipping plane.
- `obj.SetWindowCenter (double x, double y)` - Set/Get the center of the window in viewport coordinates. The viewport coordinate range is ([-1,+1],[-1,+1]). This method is for if you have one window which consists of several viewports, or if you have several screens which you want to act together as one large screen.
- `double = obj. GetWindowCenter ()` - Set/Get the center of the window in viewport coordinates. The viewport coordinate range is ([-1,+1],[-1,+1]). This method is for if you have one window which consists of several viewports, or if you have several screens which you want to act together as one large screen.
- `obj.SetObliqueAngles (double alpha, double beta)` - Get/Set the oblique viewing angles. The first angle, alpha, is the angle (measured from the horizontal) that rays along the direction of projection will follow once projected onto the 2D screen. The second angle, beta, is the angle between the view plane and the direction of projection. This creates a shear transform x' = x + dz*cos(alpha)/tan(beta), y' = dz*sin(alpha)/tan(beta) where dz is the distance of the point from the focal plane. The angles are (45,90) by default. Oblique projections commonly use (30,63.435).
- `obj.ApplyTransform (vtkTransform t)` - Apply a transform to the camera. The camera position, focal-point, and view-up are re-calculated using the transform's matrix to multiply the old points by the new transform.
- `double = obj. GetViewPlaneNormal ()` - Get the ViewPlaneNormal. This vector will point opposite to the direction of projection, unless you have created an sheared output view using SetViewShear/SetObliqueAngles.
- `obj.SetViewShear (double dxdz, double dydz, double center)` - Set/get the shear transform of the viewing frustum. Parameters are dx/dz, dy/dz, and center. center is a factor that describes where to shear around. The distance dshear from the camera where no shear occurs is given by (dshear = center * FocalDistance).
- `obj.SetViewShear (double d[3])` - Set/get the shear transform of the viewing frustum. Parameters are dx/dz, dy/dz, and center. center is a factor that describes where to shear around. The distance dshear from the camera where no shear occurs is given by (dshear = center * FocalDistance).
- `double = obj. GetViewShear ()` - Set/get the shear transform of the viewing frustum. Parameters are dx/dz, dy/dz, and center. center is a factor that describes where to shear around. The distance dshear from the camera where no shear occurs is given by (dshear = center * FocalDistance).
- `obj.SetEyeAngle (double )` - Set/Get the separation between eyes (in degrees). This is used when generating stereo images.
- `double = obj.GetEyeAngle ()` - Set/Get the separation between eyes (in degrees). This is used when generating stereo images.
- `obj.SetFocalDisk (double )` - Set the size of the cameras lens in world coordinates. This is only used when the renderer is doing focal depth rendering. When that is being done the size of the focal disk will effect how significant the depth effects will be.
- `double = obj.GetFocalDisk ()` - Set the size of the cameras lens in world coordinates. This is only used when the renderer is doing focal depth rendering. When that is being done the size of the focal disk will effect how significant the depth effects will be.
- `vtkMatrix4x4 = obj.GetViewTransformMatrix ()` - Return the matrix of the view transform. The ViewTransform depends on only three ivars: the Position, the FocalPoint, and the ViewUp vector. All the other methods are there simply for the sake of the users' convenience.
- `vtkTransform = obj.GetViewTransformObject ()` - Return the projection transform matrix, which converts from camera coordinates to viewport coordinates. The 'aspect' is the width/height for the viewport, and the nearz and farz are the Z-buffer values that map to the near and far clipping planes. The viewport coordinates of a point located inside the frustum are in the range ([-1,+1],[-1,+1],[nearz,farz]). WARNING: the name of the method is wrong, it should be GetProjectionTransformMatrix() (it is used also in parallel projection)
  Precondition:
    source_exists!=0
    not_this: source!=this
- `obj.DeepCopy (vtkCamera source)` - Copy the properties of `source' into `this'. Copy the contents of the matrices.
  Precondition:
    source_exists!=0
    not_this: source!=this