Calculate matrix null space through rust nalgebra library - rust

How can I get the basis of the null space (kernel) of a matrix through the rust nalgebra lib?

Related

Rust Equivalent to Python scipy.interp1d?

I'm porting some scientific python code to Rust as a learning exercise. In the Python version, I make use of scipy.interp1d, which I'm using to do things like the following:
Given sorted array x and array y, calculate array new_y using new_x. (with some flexibility of algorithm, linear, cubic etc.).
https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interp1d.html#scipy.interpolate.interp1d
Does anyone have nice Rust examples of this? I found the 'enterpolate' crate, but it seems mostly suited to interpolating to fixed interval x data. Is there anything in 'ndarray' that does interpolation?

Convert an Array<Array2> to Array3 in rust ndarray

Using the ndarray crate in rust.
I got a vector of array2 (which i know is not the best performance setup). I want to create a a Array3 from the this, but when I use from vector, or use the iter map, I only get Array1.
What would be the methode to flatten to Array3?

nalgebra convention about roll pitch yaw

I write small ray tracer to learn rust language. I decided to use nalgebra as library for vectors and so on.
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=79c13e8cf2725d2398dcf1fac61c047c
From that example you can see that roll rotate over X but my expectation was that roll should rotate over Z. I didn't find the nalgebra convention in the documentation. Is it possible for someone that use the library to point me to that convention and to tell me if it is possible to change it trough cargo config
Nalgebra apparently uses this definition for rotation:
(Picture from another answer on SO)
So your (0,1,0) vector is rotated 90 degrees around the X axis and thus becomes (0,0,1).

Dynamic array of uniforms (GLSL OpenGL ES 2.0)

In a shader (using OpenGL ES 2.0) I want to have an array with a dynamic size.
I can declare an array with fixed size:
uniform vec2 vertexPositions[4];
But now I want to set the size dynamic to the number of points, which I will pass.
I thought about making a string replacement in the shader source before compiling it, but than I have to compile it everytime I draw a different element. That seems to be CPU-intensive.
The typical approach would be to size the uniform array to the maximum number of elements you expect to use, and then only update the subset of it that you're actually using. You can then pass in the effective size of the array as a separate uniform.
uniform vec2 arr[MAX_SIZE];
uniform int arr_size;

Is there a way to insert circle with algebraic coordinate into an arrangement?

I am working on a motion planning problem and I'm facing problems with numeric precision.
My goal is to divide the two-dimensional vector space of real numbers with segments and circular arcs. The 2D Arrangement of the CGAL library is well indicated for this purpose. Here are the types I have defined:
typedef CGAL::CORE_algebraic_number_traits Nt_traits;
typedef Nt_traits::Rational Rational;
typedef Nt_traits::Algebraic Algebraic;
typedef CGAL::Cartesian<Rational> Rat_kernel;
typedef CGAL::Cartesian<Algebraic> Alg_kernel;
typedef CGAL::Arr_conic_traits_2<Rat_kernel, Alg_kernel, Nt_traits> Conic_traits_2;
typedef CGAL::Arrangement_2<Conic_traits_2> Arrangement_2;
During the computation I need to displaced a segment whose endpoints have rational coordinates, (due to the length of the segment, i.e. square root,) the image of this segment then have algebraic coordinates. I also need to add two circular arcs to the endpoints of this image.
All I have found in the manual is a way to add circular arcs with rational coordinates for the center, how to treat those with algebraic coordinates (without precision error) ?
Thanks.
The most efficient way to subdivide the plane with linear segments and circular arcs exploiting CGAL arrangements is to use the CGAL::Arr_circle_segment_traits_2 traits. As the manual says, it should be instantiated with a rational kernel (a kernel defined with an exact rational number type). However, the Point_2 type nested in the traits class is different than the Kernel::Point_2 type. Its coordinates are an instantiation of CGAL::Sqrt_extension. This special number type is much more efficient than a standard algebraic number type. If you must use a (standard) algebraic number type for some reason, then you can use the CGAL::Arr_algebraic_segment_traits_2 traits. The latter supports any general algebraic curve.
As far as I know, and as I understand the section of the CGAL manual about it, there is no traits class to deal with circular arcs with algebraic coordinates.
(I will forward your question to CGAL developers to be sure. I will edit my answer once I know more.)

Resources