Skip to main content

PinholeCamera

Struct PinholeCamera 

Source
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: f32

Focal length in x (pixels).

§fy: f32

Focal length in y (pixels).

§cx: f32

Principal point x (pixels).

§cy: f32

Principal point y (pixels).

§width: u32

Image width in pixels.

§height: u32

Image height in pixels.

Implementations§

Source§

impl PinholeCamera

Source

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.

Source

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.

Source

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

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for PinholeCamera

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for PinholeCamera

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.