Camera#

pyenki.viewer.to_3d(xy: VectorLike, z: SupportsFloat) Vector3#

Concatenate a 2D vector and an vertical component as a 3D vector

Parameters:
  • xy – The horizontal vector (x, y)

  • z – The vertical component

Returns:

The concatenation (x, y, z)

pyenki.viewer.rotate(value: Vector3, angle: float) Vector3#

Rotates a 3D vector around the vertical axis

Parameters:
  • value – The vector

  • angle – The rotation angle in rad.

Returns:

The rotated vector

class pyenki.viewer.CameraConfig#
camera_altitude: NotRequired[SupportsFloat]#
camera_is_ortho: NotRequired[bool]#
camera_pitch: NotRequired[SupportsFloat]#
camera_position: NotRequired[VectorLike]#
camera_reset: NotRequired[bool]#
camera_yaw: NotRequired[SupportsFloat]#
class pyenki.viewer.Camera#

This class describes a camera.

position#

the position of the camera in cm.

Type:

Vector3

yaw#

the rotation around the vertical axis in rad.

Type:

float

pitch#

the rotation around the lateral axis in rad.

Type:

float

is_ortho#

whether it uses orthographic projection.

Type:

bool

fov#

the vertical field of view in rad.

Type:

float

near_distance#

the near clipping distance in cm.

Type:

float

far_distance#

the far clipping distance in cm.

Type:

float

view_port#

the size of the viewport in pixels if set.

Type:

tuple[float, float] | None

forward#

The unit vector in the forward direction (readonly).

Type:

Vector3

up#

The unit vector in the up direction (readonly).

Type:

Vector3

left#

The unit vector in the left direction (readonly).

Type:

Vector3

__init__(position: Vector3 = array([0., 0., 0.]), yaw: float = 0, pitch: float = 0, is_ortho: bool = False) None#

Constructs a new instance.

Parameters:
  • position – The position

  • yaw – The yaw

  • pitch – The pitch

  • is_ortho – Whether to use orthographic projection

move(target_position: Vector3Like, target_distance: float = 30.0) None#

Translates the camera to point a target while maintaining its attitude.

Parameters:
  • target_position – The target position

  • target_distance – The target distance

point(target_position: Vector3Like) None#

Rotates the camera to point a target while maintaining its position.

Parameters:

target_position – The target position

reset(world: World | None = None) None#

Resets the camera to capture the world from a default POV.

Parameters:

world – An optional The world

set_viewport(width: float, height: float) None#

Sets the viewport.

Parameters:
  • width – The width in pixels

  • height – The height in pixels

property config: CameraConfig#

Returns the relevant camera attributes as a dictionary

Returns:

The camera configuration.

class pyenki.viewer.camera.HasCamera#

Mixins for classes that hold and manipulate a camera, like pyenki.viewer.WorldView and pyenki.buffer.EnkiRemoteFrameBuffer

move_camera(target_position: VectorLike, target_altitude: SupportsFloat = 0.0, target_distance: SupportsFloat = 30.0, yaw: SupportsFloat | None = None, pitch: SupportsFloat | None = None) None#

Translates the camera to point a target while maintaining its attitude.

Parameters:
  • target_position – The target horizontal position in cm.

  • target_altitude – The target vertical position in cm.

  • target_distance – The distance to the target.

  • yaw – Optionally sets the camera yaw.

  • pitch – Optionally sets the camera pitch.

point_camera(target_position: VectorLike, target_altitude: SupportsFloat = 0.0, position: VectorLike | None = None, altitude: SupportsFloat | None = None) None#

Rotates the camera to point a target while maintaining its position.

Parameters:
  • target_position – The target horizontal position in cm.

  • target_altitude – The target vertical position in cm.

  • position – Optionally sets the camera position.

  • altitude – Optionally sets the camera altitude.

reset_camera() None#

Resets the camera configuration

update_camera_config(**config: Unpack[CameraConfig]) None#

Updates the camera configuration

Parameters:

config – The (potentially partial) configuration

property camera_altitude: float#

The camera vertical position (in cm).

property camera_config: CameraConfig#

The camera configuration

property camera_is_ortho: bool#

Whether the camera uses an orthographic projection

property camera_matrix: QMatrix4x4#

The transformation matrix between camera frame to world frame

property camera_pitch: float#

The camera pitch (in rad).

property camera_position: Vector#

The camera horizontal position (in cm).

property camera_projection: QMatrix4x4#

The projection matrix

property camera_yaw: float#

The camera yaw (in rad).

property is_tracking: bool#

Whether it is tracking an object

property tracked_object: PhysicalObject | None#

The object being tracked