IGLCamera

Module: core

Camera class for orthographic viewport control with orbit, pan, and zoom. The camera maintains eye, look-at, and up vectors together with an orthographic scale and viewport size. It provides view and projection matrix generation for rendering a mesh or finite element model in an OpenGL-style scene.

__init__

method
__init__(self)
Initialize the camera state with default orthographic settings.

GetAspect

method
GetAspect(self)
Compute the viewport aspect ratio.

Returns

float: The width divided by the height of the viewport.

view_matrix

method
view_matrix(self)
Create the view matrix from the current camera orientation.

Returns

QMatrix4x4: The look-at view matrix based on eye, look-at, and up.

projection_matrix

method
projection_matrix(self)
Create an orthographic projection matrix for the current viewport.

Returns

QMatrix4x4: The orthographic projection matrix using the current ortho_scale, viewport aspect ratio, and near/far range.

get_eye

method
get_eye(self)
Return the current camera eye position.

Returns

QVector3D: The world-space position of the camera.

up_vector

method
up_vector(self)
Return the current up direction of the camera.

Returns

QVector3D: The camera up vector.

get_forward

method
get_forward(self)
Return the normalized forward direction from eye to look-at.

Returns

QVector3D: The normalized viewing direction.

rotate_orbit

method
rotate_orbit(self, dx: float, dy: float)
Rotate the camera around the pivot or look-at point.

Args

Name Type Description
dx (float) Rotation amount around the camera right axis, in degrees.
dy (float) Rotation amount around the camera up axis, in degrees.

pan

method
pan(self, dx: float, dy: float)
Pan the camera and look-at point in screen space.

Args

Name Type Description
dx (float) Horizontal pan displacement in screen units.
dy (float) Vertical pan displacement in screen units.

zoom

method
zoom(self, delta: float)
Zoom the orthographic camera by adjusting the scale.

Args

Name Type Description
delta (float) Zoom increment representing mouse wheel or drag delta.

zoom_to_cursor

method
zoom_to_cursor(self, mouse_pos: Tuple[float, float], viewport_size: Tuple[int, int], delta: float)
Zoom around the cursor location while preserving the world point under the cursor.

Args

Name Type Description
mouse_pos (Tuple[float, float]) Cursor position in viewport coordinates.
viewport_size (Tuple[int, int]) Viewport width and height.
delta (float) Zoom increment representing mouse wheel or drag delta.

zoom_to_region

method
zoom_to_region(self, dx: float, dy: float, scale: float)
Pan and zoom the camera to a specified region.

Args

Name Type Description
dx (float) Horizontal pan displacement in screen units.
dy (float) Vertical pan displacement in screen units.
scale (float) New orthographic scale for the region.

set_view

method
set_view(self, name: str)
Set the camera to a standard orthographic view orientation.

Args

Name Type Description
name (str) View name, one of "front", "back", "top", "bottom", "right", "left", or "iso".

FitView

method
FitView(self, bbox: Any, margin: float)
Fit the camera view to a bounding volume.

Args

Name Type Description
bbox (Any) Bounding volume providing Center() and BoundingRadius().
margin (float) Scale factor applied to the orthographic extent.

_rotate_axis

method
_rotate_axis(self, v: QVector3D, axis: QVector3D, angle_deg: float)

__Crossed

method
__Crossed(self, v1: QVector3D, v2: QVector3D)

__scaleBy

method
__scaleBy(self, v: QVector3D, factor: float)

_screen_to_world

method
_screen_to_world(self, ndc_x: float, ndc_y: float)
Proper orthographic unprojection