Add missing documentation
CI / cargo fmt (push) Failing after 25s
CI / cargo test (GPU) (push) Has been cancelled
CI / cargo test (push) Has been cancelled

This commit is contained in:
2026-06-27 11:02:19 -04:00
parent a9da463041
commit 344ecc3450
4 changed files with 46 additions and 8 deletions
+12 -5
View File
@@ -1,7 +1,14 @@
//! # Camera
//!
//! Map points from the IFS coordinate system to pixel coordinates. This is a lossy transformation.
use bytemuck::{Pod, Zeroable};
use glam::{Affine2, IVec2, UVec2, Vec2, vec2};
use libm::powf;
/// Settings used to map IFS coordinates to pixel coordinates.
///
/// The camera is itself an affine transformation, capable of zoom, rotation, and translation
/// of the IFS coordinates before rendering to the final image.
#[derive(Copy, Clone, Pod, Zeroable)]
#[repr(C)]
pub struct Camera {
@@ -10,10 +17,10 @@ pub struct Camera {
}
impl Camera {
/// Construct a new camera that maps IFS coordinates to pixel coordinates.
/// Construct a new camera for translating IFS coordinates to pixel coordinates.
///
/// The camera object is itself an affine transformation, but it's helpful to express
/// the parameters in individual steps, and compose them internally.
/// While the camera is implemented as a single affine transformation, it's helpful
/// to express the transform steps individually.
///
/// # Arguments
///
@@ -24,7 +31,7 @@ impl Camera {
/// `center` translation, so it is about the new origin.
/// * `zoom` - Zoom factor applied to IFS coordinates. IFS coordinates are scaled by
/// `pow(2, zoom)`, so a zoom factor of 0 is the identity.
/// * `scale` - Pixels per unit of IFS coordinates. By default, this parameter is chosen such
/// * `scale` - Pixels per unit of IFS coordinates. This parameter is usually chosen such
/// that the largest dimension will cover the range `[-2, 2]`, but values higher or lower
/// can be used as a secondary zoom.
pub fn new(dimensions: UVec2, center: Vec2, rotate: f32, zoom: Vec2, scale: Vec2) -> Camera {
@@ -67,7 +74,7 @@ impl Camera {
self.transform.transform_point2(point).as_ivec2()
}
/// Map a point from IFS coordinates to pixel coordinates (like [`transform_point`]),
/// Map a point from IFS coordinates to pixel coordinates (like [`transform_point`](Camera::transform_point)),
/// and check that the result is within the provided image dimensions.
pub fn transform_point_to_image(&self, point: Vec2) -> Option<UVec2> {
let pixel_coordinates = self.transform_point(point);