I'm trying to create a Vector3
from the nalgebra
crate with components (1.0, 1.0, 1.0)
. I can't find what I need from the documentation, and my IDE's suggestions don't help.
Asked
Active
Viewed 513 times
1

Shepmaster
- 388,571
- 95
- 1,107
- 1,366

Dario
- 37
- 8
-
1You can just use `let vec = Vector3::new(1.0, 1.0, 1.0);` Or doesn't that work for you? – Peter Hall Aug 25 '20 at 17:52
-
@PeterHall Hey, this works. I think it's was a problem of my IDE which told me new() didn't exist. thanks ! – Dario Aug 25 '20 at 17:57
1 Answers
6
To be fair, the types in nalgebra
are a little complicated: Vector3<N>
is a type alias of VectorN<N, U3>
, which is a type alias of MatrixMN<N, D, U1>
, which is a type alias of Matrix<N, R, C, Owned<N, R, C>>
!
The documentation for Matrix
includes a large number of different new
methods, depending on the constraints, and you want this one.
let my_vec = Vector3::new(1.0, 1.0, 1.0);

Peter Hall
- 53,120
- 14
- 139
- 204