pub struct Point {
pub x: f64,
pub y: f64,
}Fields§
§x: f64§y: f64Implementations§
Source§impl Point
impl Point
Sourcepub fn new(x: f64, y: f64) -> Self
pub fn new(x: f64, y: f64) -> Self
Examples found in repository?
examples/basic_usage.rs (line 6)
3fn main() {
4 // 1. Create some messy data
5 let data = vec![
6 Point::new(1.0, 3.0), // 2x + 1
7 Point::new(2.0, 5.0), // 2x + 1
8 Point::new(3.0, 7.0), // 2x + 1
9 Point::new(4.0, 9.0), // 2x + 1
10 Point::new(2.5, 50.0), // OUTLIER!
11 Point::new(3.5, -10.0), // OUTLIER!
12 Point::new(5.0, 11.0), // 2x + 1
13 ];
14
15 // 2. Fit
16 let result = RansacSolver::new()
17 .with_seed(123)
18 .fit(&data);
19
20 // 3. Handle Result
21 match result {
22 Ok(model) => {
23 println!("Succcess!");
24 println!("y = {:.2}x + {:.2}", model.slope, model.intercept);
25 // Should predict close to y = 2*10 + 1 = 21
26 println!("Prediction for x=10: {}", model.predict(10.0));
27 },
28 Err(e) => println!("RANSAC failed: {}", e),
29 }
30}Trait Implementations§
impl Copy for Point
impl StructuralPartialEq for Point
Auto Trait Implementations§
impl Freeze for Point
impl RefUnwindSafe for Point
impl Send for Point
impl Sync for Point
impl Unpin for Point
impl UnwindSafe for Point
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