pub struct PinholeCamera {
pub fx: f32,
pub fy: f32,
pub cx: f32,
pub cy: f32,
pub width: u32,
pub height: u32,
}Expand description
Pinhole camera intrinsics.
Fields§
§fx: f32Focal length in x (pixels).
fy: f32Focal length in y (pixels).
cx: f32Principal point x (pixels).
cy: f32Principal point y (pixels).
width: u32Image width in pixels.
height: u32Image height in pixels.
Implementations§
Source§impl PinholeCamera
impl PinholeCamera
Sourcepub fn new(
fx: f32,
fy: f32,
cx: f32,
cy: f32,
w: u32,
h: u32,
) -> NerfResult<Self>
pub fn new( fx: f32, fy: f32, cx: f32, cy: f32, w: u32, h: u32, ) -> NerfResult<Self>
Create a new pinhole camera model.
§Errors
Returns InvalidCameraIntrinsics for non-positive focal lengths or zero dimensions.
Sourcepub fn ray_through_pixel(
&self,
u: f32,
v: f32,
c2w: &[f32; 12],
) -> NerfResult<Ray>
pub fn ray_through_pixel( &self, u: f32, v: f32, c2w: &[f32; 12], ) -> NerfResult<Ray>
Generate the ray through pixel (u, v) in camera coordinates.
c2w is a row-major 3×4 camera-to-world transform:
[ R[0,0] R[0,1] R[0,2] t[0]
R[1,0] R[1,1] R[1,2] t[1]
R[2,0] R[2,1] R[2,2] t[2] ]§Errors
Returns ZeroRayDirection if the transformed direction is near-zero.
Sourcepub fn generate_rays(&self, c2w: &[f32; 12]) -> NerfResult<Vec<Ray>>
pub fn generate_rays(&self, c2w: &[f32; 12]) -> NerfResult<Vec<Ray>>
Generate all W×H rays for the camera with given c2w matrix.
Output: width * height rays in row-major order (left-to-right, top-to-bottom).
§Errors
Returns ZeroRayDirection if any pixel ray has near-zero direction.
Trait Implementations§
Source§impl Clone for PinholeCamera
impl Clone for PinholeCamera
Source§fn clone(&self) -> PinholeCamera
fn clone(&self) -> PinholeCamera
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PinholeCamera
impl Debug for PinholeCamera
impl Copy for PinholeCamera
Auto Trait Implementations§
impl Freeze for PinholeCamera
impl RefUnwindSafe for PinholeCamera
impl Send for PinholeCamera
impl Sync for PinholeCamera
impl Unpin for PinholeCamera
impl UnsafeUnpin for PinholeCamera
impl UnwindSafe for PinholeCamera
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more