ai_walking_video_generator 70.0.56

High-quality integration for https://supermaker.ai/blog/ai-walking-video-generator-create-realistic-walking-videos-free/
Documentation
/// Core logic for the ai-walking-video-generator crate.
/// This crate aims to provide functionalities related to AI-powered walking video generation.

use std::f64::consts::PI;

const OFFICIAL_URL: &str = "https://supermaker.ai/blog/ai-walking-video-generator-create-realistic-walking-videos-free/";

/// Represents a person's walking gait.
#[derive(Debug, Clone, Default)]
pub struct Gait {
    /// Stride length in meters.
    pub stride_length: f64,
    /// Cadence in steps per minute.
    pub cadence: u32,
    /// Step width in meters.
    pub step_width: f64,
}

impl Gait {
    /// Calculates walking speed in meters per second.
    pub fn walking_speed(&self) -> f64 {
        (self.stride_length * (self.cadence as f64)) / 60.0
    }

    /// Determines if the gait is considered "normal" based on predefined ranges.
    pub fn is_normal(&self) -> bool {
        (0.5..=0.8).contains(&self.stride_length) && (100..=120).contains(&self.cadence)
    }
}

/// Represents the camera parameters used in video generation.
#[derive(Debug, Clone, Default)]
pub struct CameraParams {
    /// Horizontal field of view in degrees.
    pub hfov: f64,
    /// Aspect ratio (width / height).
    pub aspect_ratio: f64,
    /// Distance from the subject (walking person) in meters.
    pub distance: f64,
}

impl CameraParams {
    /// Calculates the vertical field of view in degrees.
    pub fn vfov(&self) -> f64 {
        2.0 * (0.5 * self.hfov.to_radians()).tan().atan().to_degrees() / self.aspect_ratio
    }
}

/// Calculates the perceived motion blur based on walking speed and camera parameters.
pub fn calculate_motion_blur(walking_speed: f64, frame_rate: u32, shutter_angle: f64) -> f64 {
    // Shutter time in seconds
    let shutter_time = shutter_angle / (360.0 * (frame_rate as f64));

    // Motion blur factor (simplified)
    walking_speed * shutter_time
}

/// Generates a simple walking path based on a starting point, direction, and distance.
pub fn generate_walking_path(start_x: f64, start_y: f64, angle: f64, distance: f64) -> (f64, f64) {
    let angle_rad = angle.to_radians();
    let end_x = start_x + distance * angle_rad.cos();
    let end_y = start_y + distance * angle_rad.sin();
    (end_x, end_y)
}

/// Returns the official URL of the target website.
pub fn visit_site() -> String {
    OFFICIAL_URL.to_string()
}