WaDelma / poisson

n-dimensional poisson-disk distribution generation for rust.
MIT License
10 stars 8 forks source link

Example does not compile #17

Closed wilg closed 5 years ago

wilg commented 5 years ago

The example in the Readme:

extern crate poisson;
extern crate rand;
extern crate nalgebra as na;

use poisson::{Builder, Type, algorithm};

fn main() {
    let poisson =
        Builder::<_, na::Vector2<f64>>::with_radius(0.1, Type::Normal)
            .build(rand::weak_rng(), algorithm::Ebeida);
    let samples = poisson.generate();
    println!("{:?}", samples);
}

Does not compile. I'm not sure what the errors mean. Am I missing something or is the example incomplete?

poisson = "*"
rand = "*"
nalgebra="*"
› cargo -V && rustc -V
cargo 1.28.0 (96a2c7d16 2018-07-13)
rustc 1.28.0 (9634041f0 2018-07-30)
error[E0277]: the trait bound `na::Matrix<f64, na::U2, na::U1, na::MatrixArray<f64, na::U2, na::U1>>: rand::Rand` is not satisfied
 --> src/main.rs:9:9
  |
9 |         Builder::<_, na::Vector2<f64>>::with_radius(0.1, Type::Normal)
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `rand::Rand` is not implemented for `na::Matrix<f64, na::U2, na::U1, na::MatrixArray<f64, na::U2, na::U1>>`
  |
  = note: required because of the requirements on the impl of `poisson::Vector<_>` for `na::Matrix<f64, na::U2, na::U1, na::MatrixArray<f64, na::U2, na::U1>>`
  = note: required by `poisson::Builder`

error[E0277]: the trait bound `na::Matrix<f64, na::U2, na::U1, na::MatrixArray<f64, na::U2, na::U1>>: alga::linear::vector::FiniteDimVectorSpace` is not satisfied
 --> src/main.rs:9:9
  |
9 |         Builder::<_, na::Vector2<f64>>::with_radius(0.1, Type::Normal)
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `alga::linear::vector::FiniteDimVectorSpace` is not implemented for `na::Matrix<f64, na::U2, na::U1, na::MatrixArray<f64, na::U2, na::U1>>`
  |
  = note: required because of the requirements on the impl of `poisson::Vector<_>` for `na::Matrix<f64, na::U2, na::U1, na::MatrixArray<f64, na::U2, na::U1>>`
  = note: required by `poisson::Builder`

error[E0277]: the trait bound `na::Matrix<f64, na::U2, na::U1, na::MatrixArray<f64, na::U2, na::U1>>: alga::linear::vector::NormedSpace` is not satisfied
 --> src/main.rs:9:9
  |
9 |         Builder::<_, na::Vector2<f64>>::with_radius(0.1, Type::Normal)
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `alga::linear::vector::NormedSpace` is not implemented for `na::Matrix<f64, na::U2, na::U1, na::MatrixArray<f64, na::U2, na::U1>>`
  |
  = note: required because of the requirements on the impl of `poisson::Vector<_>` for `na::Matrix<f64, na::U2, na::U1, na::MatrixArray<f64, na::U2, na::U1>>`
  = note: required by `poisson::Builder`

error[E0599]: no function or associated item named `with_radius` found for type `poisson::Builder<_, na::Matrix<f64, na::U2, na::U1, na::MatrixArray<f64, na::U2, na::U1>>>` in the current scope
 --> src/main.rs:9:9
  |
9 |         Builder::<_, na::Vector2<f64>>::with_radius(0.1, Type::Normal)
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function or associated item not found in `poisson::Builder<_, na::Matrix<f64, na::U2, na::U1, na::MatrixArray<f64, na::U2, na::U1>>>`
  |
  = note: the method `with_radius` exists but the following trait bounds were not satisfied:
          `na::Matrix<f64, na::U2, na::U1, na::MatrixArray<f64, na::U2, na::U1>> : poisson::Vector<_>`

error: aborting due to 4 previous errors

Some errors occurred: E0277, E0599.
For more information about an error, try `rustc --explain E0277`.
WaDelma commented 5 years ago

Hmmm... Interesting that seems to be caused by changes in nalgebra. I'll look into it.

WaDelma commented 5 years ago

Yeah it's definitely caused by newer nalgebra version. It should work with nalgebra 0.11.

I started upgrading to a newer one.

wilg commented 5 years ago

Thank you for the help, I'll give that a try!