[][src]Struct kalman_rs::Rectangle

pub struct Rectangle { /* fields omitted */ }

A struct for sensors of rectangular geometry

Methods

impl Rectangle[src]

pub fn new(
    points: [Point3<f32>; 4],
    tfm_matrix: Matrix<f32>
) -> Result<Rectangle, &'static str>
[src]

This is the constructor for the rectangular geometry. It expects a 4x4 nalgebra::Matrix4<f32> that is invertible and a 4 element array of nalgebra::Point3<f32>. If the matrix is not invertible it will return Err(&str). The provided matrix should be an affine transformation for converting from R2->R3

Examples

use nalgebra as na;
use na::Point3;
 
let rectangular_points = [Point3::new(0.0, 0.0, 0.0), 
                          Point3::new(5.0,0.0,0.0), 
                          Point3::new(0.0,5.0,0.0), 
                          Point3::new(5.0,5.0,0.0)];
let tfm_matrix : na::Matrix4<f32>= na::Matrix4::new(1.0,5.0,7.0,2.0,  3.0,5.0,7.0,4.0,  8.0,4.0,1.0,9.0, 2.0,6.0,4.0,8.0);
let mut rectangle_sensor = kalman_rs::Rectangle::new(rectangular_points, tfm_matrix).unwrap();

Trait Implementations

impl Plane for Rectangle[src]

fn plane(&mut self) -> Vector<f32>[src]

Calculate the current normal vector of the plane of the surface. NOTE: plane() must be called before contains_from_local since contains_from_local requires the normal vector to be defined

Examples

use nalgebra as na;
use na::Point3;
use kalman_rs::sensor_traits::Plane;
 
let rectangular_points = [Point3::new(0.0, 0.0, 0.0), 
                          Point3::new(5.0,0.0,0.0), 
                          Point3::new(0.0,5.0,0.0), 
                          Point3::new(5.0,5.0,0.0)];
let tfm_matrix : na::Matrix4<f32>= na::Matrix4::new(1.0,5.0,7.0,2.0,  3.0,5.0,7.0,4.0,  8.0,4.0,1.0,9.0, 2.0,6.0,4.0,8.0);
let mut rectangle_sensor = kalman_rs::Rectangle::new(rectangular_points, tfm_matrix).unwrap();
 
let normal_vector = rectangle_sensor.plane();

fn on_plane(&self, input_point: &Point3<f32>) -> Result<bool, &'static str>[src]

Check if a given point is located on the same plane as the sensor NOTE: plane() must be called becuase the normal vector is not currently known

Examples

use nalgebra as na;
use na::Point3;
use kalman_rs::sensor_traits::Plane;
 
let rectangular_points = [Point3::new(0.0, 0.0, 0.0), 
                          Point3::new(5.0,0.0,0.0), 
                          Point3::new(0.0,5.0,0.0), 
                          Point3::new(5.0,5.0,0.0)];
let tfm_matrix : na::Matrix4<f32>= na::Matrix4::new(1.0,5.0,7.0,2.0,  3.0,5.0,7.0,4.0,  8.0,4.0,1.0,9.0, 2.0,6.0,4.0,8.0);
let mut rectangle_sensor = kalman_rs::Rectangle::new(rectangular_points, tfm_matrix).unwrap();
 
let on_plane = rectangle_sensor.on_plane(&na::Point3::new(1.0, 3.0, 0.0)); //true

impl Transform for Rectangle[src]

fn to_global(&self, input_point: Point3<f32>) -> Point3<f32>[src]

Converts a point in the global reference frame to a point in the local reference frame of the sensor.

Examples

use nalgebra as na;
use na::Point3;
use kalman_rs::sensor_traits::Transform;
 
let rectangular_points = [Point3::new(0.0, 0.0, 0.0), 
                          Point3::new(5.0,0.0,0.0), 
                          Point3::new(0.0,5.0,0.0), 
                          Point3::new(5.0,5.0,0.0)];
let tfm_matrix : na::Matrix4<f32>= na::Matrix4::new(1.0,5.0,7.0,2.0,  3.0,5.0,7.0,4.0,  8.0,4.0,1.0,9.0, 2.0,6.0,4.0,8.0);
let mut rectangle_sensor = kalman_rs::Rectangle::new(rectangular_points, tfm_matrix).unwrap();
 
let global_point = rectangle_sensor.to_global(na::Point3::new(1.0, 2.0, 0.0));

fn to_local(&self, input_point: Point3<f32>) -> Point3<f32>[src]

Converts a point in the local refernce frame of the sensor to the global reference frame.

Examples

use nalgebra as na;
use na::Point3;
use kalman_rs::sensor_traits::Transform;
 
let rectangular_points = [Point3::new(0.0, 0.0, 0.0), 
                          Point3::new(5.0,0.0,0.0), 
                          Point3::new(0.0,5.0,0.0), 
                          Point3::new(5.0,5.0,0.0)];
let tfm_matrix : na::Matrix4<f32>= na::Matrix4::new(1.0,5.0,7.0,2.0,  3.0,5.0,7.0,4.0,  8.0,4.0,1.0,9.0, 2.0,6.0,4.0,8.0);
let mut rectangle_sensor = kalman_rs::Rectangle::new(rectangular_points, tfm_matrix).unwrap();
 
let global_point = rectangle_sensor.to_local(na::Point3::new(6.0, 3.0, 5.0));

fn contains_from_local(&self, input: &Point3<f32>) -> Result<bool, &'static str>[src]

Checks if a local point is contained within the bounds of a sensor. NOTE: plane() must be called before checking for bounds of the sensor since the normal vector must be calculated first.

Examples

use nalgebra as na;
use na::Point3;
use kalman_rs::sensor_traits::Transform;
 
let rectangular_points = [Point3::new(0.0, 0.0, 0.0), 
                          Point3::new(5.0,0.0,0.0), 
                          Point3::new(5.0,5.0,0.0),
                          Point3::new(5.0, 0.0, 0.0)];
let tfm_matrix : na::Matrix4<f32>= na::Matrix4::new(1.0,5.0,7.0,2.0,  3.0,5.0,7.0,4.0,  8.0,4.0,1.0,9.0, 2.0,6.0,4.0,8.0);
let mut rectangle_sensor = kalman_rs::Rectangle::new(rectangular_points, tfm_matrix).unwrap();
 
let is_point_on_sensor = rectangle_sensor.contains_from_local(&na::Point3::new(1.0, 6.0, 0.0));

fn contains_from_global(
    &mut self,
    input_point: Point3<f32>
) -> Result<bool, &'static str>
[src]

Checks if a global point is contained within the localized bounds of a sensor.

Auto Trait Implementations

impl Send for Rectangle

impl Sync for Rectangle

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf for SP where
    SS: SubsetOf<SP>,