Camera#

class ansys.stk.core.graphics.Camera#

Implemented by the scene camera. Contains operations to manipulate the camera position, view direction and orientation in the scene.

Overview#

visibility_test

Get the visibility of a sphere against the view frustum and any occluding central bodies.

cartographic_to_window

Convert a cartographic position to a pixel coordinate relative to the globe control. This method can throw an exception. Returns an array containing the pixel coordinate (in the order x, y) of the cartographic position relative to the globe control…

try_cartographic_to_window

Convert a cartographic position to a pixel coordinate relative to the globe control. This method does not throw an exception.

window_to_cartographic

Convert a pixel coordinate relative to the globe control to a cartographic position. For speed, terrain is not considered; if the pixel coordinate does not intersect the ellipsoid, an exception is thrown. Returns the cartographic position…

try_window_to_cartographic

Convert a pixel coordinate relative to the globe control to a cartographic position. For speed, terrain is not considered. This method does not throw an exception.

view_central_body

Zoom to a central body and use the specified axes for rotation. The reference point is set to the center of the central body and the camera’s position is set so the entire central body is visible.

view_extent

Zooms to a cartographic extent on the centralBody. The camera will be looking straight down at the extent, with the up vector pointing toward local north. The axes is set to an east-north-up axes at the center of extent.

view_rectangular_extent

Zooms to a rectangular extent composed of west, south, east, north on the centralBody. The camera will be looking straight down at the extent, with the up vector pointing toward local north…

view_with_up_axis

View from a point to a point. Sets the camera’s position and the reference point the camera is looking at.

view

View from a point to a point. Sets the camera’s position and the reference point the camera is looking at.

view_direction_with_up_axis

View from a point to a direction. Sets the camera’s position and the direction vector indicating where the camera is looking.

view_direction

View from a point to a direction. Sets the camera’s position and the direction vector indicating where the camera is looking.

view_offset_with_up_axis

Set the camera’s reference point - the point the camera is looking at. The camera’s position is the reference point translated by the offset.

view_offset

Set the camera’s reference point - the point the camera is looking at. The camera’s position is the reference point translated by the offset.

view_offset_direction_with_up_axis

Set the camera’s reference point - the point the camera is looking at. The camera’s position is the reference point translated by the direction vector.

view_offset_direction

Set the camera’s reference point - the point the camera is looking at. The camera’s position is the reference point translated by the direction vector.

position

Get or set the position of the camera. The array contains the components of the position arranged in the order x, y, z.

reference_point

Get or set the reference point of the camera. The array contains the components of the reference point arranged in the order x, y, z.

direction

Get or set the direction of the camera in axes. The array contains the components of the direction arranged in the order x, y, z.

up_vector

Get or set the up direction of the camera in axes. The array contains the components of the direction arranged in the order x, y, z.

distance

Get or set the distance the camera position is from the reference point.

axes

Get or set camera’s axes of rotation.

constrained_up_axis

Get or set the axis to constrain the up vector to.

allow_rotation_over_constrained_up_axis

Get or set whether the camera can rotate over the constrained up axis. For example, if true the camera would be able to flip over the North Pole and view the globe upside down.

lock_view_direction

Get or set whether the camera’s direction is locked.

field_of_view

Get or set field of view. The field of view is applied to the larger of the window dimensions. For example, if the window width was 640 and the height was 480, the field of view applies to the horizontal…

horizontal_field_of_view

Get the horizontal field of view.

vertical_field_of_view

Get the vertical field of view.

near_plane

Get or set the distance from the camera to the near plane.

far_plane

Get or set the distance from the camera to the far plane.

far_near_plane_ratio

Get or set the value that is used to compute subdivisions of the viewing frustum. A large value will be faster but lose z-value precision. A small value will have better precision but perform slower…

distance_per_radius

Return the distance that the Camera’s Position should be from the ReferencePoint in order to ensure that a sphere with a 1 meter radius centered at the ReferencePoint fits entirely in the view frustum.

snapshot

Get the camera snapshot settings.

video_recording

Get the camera video recorder.

pixel_size_per_distance

Get the approximate number of meters covered by a pixel that is 1 meter away from the camera. This is commonly multiplied by the distance from the camera to an object to compute the approximate number of meters covered by a pixel of the object.

position_reference_frame

Get the reference frame that the position is returned in. This reference frame is composed of the camera’s from point and the axes.

reference_point_reference_frame

Get the reference frame that the reference point is returned in. This reference frame is composed of the camera’s to point and the axes.

Examples#

Change the camera reference frame

# Scenario scenario: Scenario object
# STKObjectRoot root: STK Object Model Root
manager = scenario.scene_manager
manager.scenes.item(0).camera.view_central_body(
    "Earth", root.central_bodies.earth.analysis_workbench_components.axes.item("Fixed")
)
manager.render()

Change the camera view to Imagery Extents

# Scenario scenario: Scenario object
# AGIProcessedImageGlobeOverlay imageryTile: Image Overlay object
manager = scenario.scene_manager
extent = imageryTile.extent
# Change extent in the default 3D window
manager.scenes.item(0).camera.view_extent("Earth", extent)
manager.render()

Import detail#

from ansys.stk.core.graphics import Camera

Property detail#

property Camera.position: list#

Get or set the position of the camera. The array contains the components of the position arranged in the order x, y, z.

property Camera.reference_point: list#

Get or set the reference point of the camera. The array contains the components of the reference point arranged in the order x, y, z.

property Camera.direction: list#

Get or set the direction of the camera in axes. The array contains the components of the direction arranged in the order x, y, z.

property Camera.up_vector: list#

Get or set the up direction of the camera in axes. The array contains the components of the direction arranged in the order x, y, z.

property Camera.distance: float#

Get or set the distance the camera position is from the reference point.

property Camera.axes: IVectorGeometryToolAxes#

Get or set camera’s axes of rotation.

property Camera.constrained_up_axis: ConstrainedUpAxis#

Get or set the axis to constrain the up vector to.

property Camera.allow_rotation_over_constrained_up_axis: bool#

Get or set whether the camera can rotate over the constrained up axis. For example, if true the camera would be able to flip over the North Pole and view the globe upside down.

property Camera.lock_view_direction: bool#

Get or set whether the camera’s direction is locked.

property Camera.field_of_view: float#

Get or set field of view. The field of view is applied to the larger of the window dimensions. For example, if the window width was 640 and the height was 480, the field of view applies to the horizontal…

property Camera.horizontal_field_of_view: float#

Get the horizontal field of view.

property Camera.vertical_field_of_view: float#

Get the vertical field of view.

property Camera.near_plane: float#

Get or set the distance from the camera to the near plane.

property Camera.far_plane: float#

Get or set the distance from the camera to the far plane.

property Camera.far_near_plane_ratio: float#

Get or set the value that is used to compute subdivisions of the viewing frustum. A large value will be faster but lose z-value precision. A small value will have better precision but perform slower…

property Camera.distance_per_radius: float#

Return the distance that the Camera’s Position should be from the ReferencePoint in order to ensure that a sphere with a 1 meter radius centered at the ReferencePoint fits entirely in the view frustum.

property Camera.snapshot: CameraSnapshot#

Get the camera snapshot settings.

property Camera.video_recording: CameraVideoRecording#

Get the camera video recorder.

property Camera.pixel_size_per_distance: float#

Get the approximate number of meters covered by a pixel that is 1 meter away from the camera. This is commonly multiplied by the distance from the camera to an object to compute the approximate number of meters covered by a pixel of the object.

property Camera.position_reference_frame: IVectorGeometryToolSystem#

Get the reference frame that the position is returned in. This reference frame is composed of the camera’s from point and the axes.

property Camera.reference_point_reference_frame: IVectorGeometryToolSystem#

Get the reference frame that the reference point is returned in. This reference frame is composed of the camera’s to point and the axes.

Method detail#

Camera.visibility_test(self, reference_frame: IVectorGeometryToolSystem, sphere: BoundingSphere) Visibility#

Get the visibility of a sphere against the view frustum and any occluding central bodies.

Parameters:

reference_frame : IVectorGeometryToolSystem

sphere : BoundingSphere

Returns:

Visibility

Camera.cartographic_to_window(self, central_body: str, position: list) list#

Convert a cartographic position to a pixel coordinate relative to the globe control. This method can throw an exception. Returns an array containing the pixel coordinate (in the order x, y) of the cartographic position relative to the globe control…

Parameters:

central_body : str

position : list

Returns:

list

Camera.try_cartographic_to_window(self, central_body: str, position: list) list#

Convert a cartographic position to a pixel coordinate relative to the globe control. This method does not throw an exception.

Parameters:

central_body : str

position : list

Returns:

list

Camera.window_to_cartographic(self, central_body: str, position: list) list#

Convert a pixel coordinate relative to the globe control to a cartographic position. For speed, terrain is not considered; if the pixel coordinate does not intersect the ellipsoid, an exception is thrown. Returns the cartographic position…

Parameters:

central_body : str

position : list

Returns:

list

Camera.try_window_to_cartographic(self, central_body: str, position: list) list#

Convert a pixel coordinate relative to the globe control to a cartographic position. For speed, terrain is not considered. This method does not throw an exception.

Parameters:

central_body : str

position : list

Returns:

list

Camera.view_central_body(self, central_body: str, axes: IVectorGeometryToolAxes) None#

Zoom to a central body and use the specified axes for rotation. The reference point is set to the center of the central body and the camera’s position is set so the entire central body is visible.

Parameters:

central_body : str

axes : IVectorGeometryToolAxes

Returns:

None

Camera.view_extent(self, central_body: str, extent: list) None#

Zooms to a cartographic extent on the centralBody. The camera will be looking straight down at the extent, with the up vector pointing toward local north. The axes is set to an east-north-up axes at the center of extent.

Parameters:

central_body : str

extent : list

Returns:

None

Camera.view_rectangular_extent(self, central_body: str, west: float, south: float, east: float, north: float) None#

Zooms to a rectangular extent composed of west, south, east, north on the centralBody. The camera will be looking straight down at the extent, with the up vector pointing toward local north…

Parameters:

central_body : str

west : float

south : float

east : float

north : float

Returns:

None

Camera.view_with_up_axis(self, axes: IVectorGeometryToolAxes, camera_position: IVectorGeometryToolPoint, reference_point: IVectorGeometryToolPoint, up_axis: list) None#

View from a point to a point. Sets the camera’s position and the reference point the camera is looking at.

Parameters:

axes : IVectorGeometryToolAxes

camera_position : IVectorGeometryToolPoint

reference_point : IVectorGeometryToolPoint

up_axis : list

Returns:

None

Camera.view(self, axes: IVectorGeometryToolAxes, camera_position: IVectorGeometryToolPoint, reference_point: IVectorGeometryToolPoint) None#

View from a point to a point. Sets the camera’s position and the reference point the camera is looking at.

Parameters:

axes : IVectorGeometryToolAxes

camera_position : IVectorGeometryToolPoint

reference_point : IVectorGeometryToolPoint

Returns:

None

Camera.view_direction_with_up_axis(self, axes: IVectorGeometryToolAxes, camera_position: IVectorGeometryToolPoint, direction: IVectorGeometryToolVector, up_axis: list) None#

View from a point to a direction. Sets the camera’s position and the direction vector indicating where the camera is looking.

Parameters:

axes : IVectorGeometryToolAxes

camera_position : IVectorGeometryToolPoint

direction : IVectorGeometryToolVector

up_axis : list

Returns:

None

Camera.view_direction(self, axes: IVectorGeometryToolAxes, camera_position: IVectorGeometryToolPoint, direction: IVectorGeometryToolVector) None#

View from a point to a direction. Sets the camera’s position and the direction vector indicating where the camera is looking.

Parameters:

axes : IVectorGeometryToolAxes

camera_position : IVectorGeometryToolPoint

direction : IVectorGeometryToolVector

Returns:

None

Camera.view_offset_with_up_axis(self, axes: IVectorGeometryToolAxes, reference_point: IVectorGeometryToolPoint, offset: list, up_axis: list) None#

Set the camera’s reference point - the point the camera is looking at. The camera’s position is the reference point translated by the offset.

Parameters:

axes : IVectorGeometryToolAxes

reference_point : IVectorGeometryToolPoint

offset : list

up_axis : list

Returns:

None

Camera.view_offset(self, axes: IVectorGeometryToolAxes, reference_point: IVectorGeometryToolPoint, offset: list) None#

Set the camera’s reference point - the point the camera is looking at. The camera’s position is the reference point translated by the offset.

Parameters:

axes : IVectorGeometryToolAxes

reference_point : IVectorGeometryToolPoint

offset : list

Returns:

None

Camera.view_offset_direction_with_up_axis(self, axes: IVectorGeometryToolAxes, reference_point: IVectorGeometryToolPoint, direction: IVectorGeometryToolVector, up_axis: list) None#

Set the camera’s reference point - the point the camera is looking at. The camera’s position is the reference point translated by the direction vector.

Parameters:

axes : IVectorGeometryToolAxes

reference_point : IVectorGeometryToolPoint

direction : IVectorGeometryToolVector

up_axis : list

Returns:

None

Camera.view_offset_direction(self, axes: IVectorGeometryToolAxes, reference_point: IVectorGeometryToolPoint, direction: IVectorGeometryToolVector) None#

Set the camera’s reference point - the point the camera is looking at. The camera’s position is the reference point translated by the direction vector.

Parameters:

axes : IVectorGeometryToolAxes

reference_point : IVectorGeometryToolPoint

direction : IVectorGeometryToolVector

Returns:

None