use crate::{ImagePoint, KeyPoint};
use nalgebra::{Unit, Vector3};
pub trait Bearing {
fn bearing(&self) -> Unit<Vector3<f64>> {
Unit::new_normalize(self.bearing_unnormalized())
}
fn bearing_unnormalized(&self) -> Vector3<f64>;
fn from_bearing_vector(bearing: Vector3<f64>) -> Self;
fn from_bearing_unit_vector(bearing: Unit<Vector3<f64>>) -> Self
where
Self: Sized,
{
Self::from_bearing_vector(bearing.into_inner())
}
}
impl Bearing for Unit<Vector3<f64>> {
fn bearing(&self) -> Unit<Vector3<f64>> {
*self
}
fn bearing_unnormalized(&self) -> Vector3<f64> {
self.into_inner()
}
fn from_bearing_vector(bearing: Vector3<f64>) -> Self {
Unit::new_normalize(bearing)
}
fn from_bearing_unit_vector(bearing: Unit<Vector3<f64>>) -> Self {
bearing
}
}
pub trait CameraModel {
type Projection: Bearing;
fn calibrate<P>(&self, point: P) -> Self::Projection
where
P: ImagePoint;
fn uncalibrate(&self, projection: Self::Projection) -> KeyPoint;
}