How to convert Eigen::Affine3f to Affine3d - point-cloud-library

I used pcl::TransformationFromCorrespondeces to get 3D transformation, but I want to convert the Affine3f result to Affine3d to facilitate my following process.

I just found the answer. It's quite easy actually:
Eigen::Affine3f A;
Eigen::Affine3d B = A.cast<double>();

Related

create a vector increased by 0.5 in julia

Suppose I want to create a vector in Julia. The vector should be [0,0.5,1,1.5,2,....20].
What's the quick command to create a vector like this, from 0 to 20, increasing by 0.5?
This will create a range, which is a kind of vector:
0:0.5:20
This does the same thing
range(0, 20; step=0.5)
If you absolutely need to make a Vector, you can use collect on either of these, but in most cases you should not, and just use 0:0.5:20 directly.
There are many ways to do this. While I prefer the colon array syntax already mentioned, this could be used for more general construction:
[0.5*i for i in 1:20]

What is the reason for failure of simple slicing in my script in R?

I am trying use simple slice operator as follows, but the result is not correct.
arr = c(1,2,3,4,5,6,7)
arr[2:2+3]
I expected to get the sliced array 2,3,4,5 but instead I get 5. Does R interpret arr[2:2+3] as arr[2:2]+3 ? If so, then why?
The correct version of slice would be arr[2:(2+3)], right?
As #camille pointed out in the comment section, the reason of failure is due to the order of operations!

How can I concatenate vectors in loop in R

everyone
I brought some new trivial questions to ask. I've searched, but I failed to look for the most efficient answer.
The string(or list) I would like to make looks like:
c("who","expr1","who","expr2",...,"who","expr100")
How can I efficiently make this string using loop(or another function) in R?
Thank you~!!
At least this is one choice:
c(rbind("who", paste0("expr", 1:100)))

Every nth column from in matlab to R

I am trying to translate some matlab code to R.
This is the code:
v_i = vfull(:,i:ns:k*ns);
I think this means take every ns_th column from i to k*ns in the matrix v_i, right? If I am wrong, can someone please tell me what it means?
Regardless, how would one implement this in R?
You interpretation of what Matlab is doing is correct. Here is how to do the equivalent in R
v_i = vfull[ ,seq(i,(k*ns),ns)]

R or MATLAB: permute a large sparse matrix into a block diagonal matrix

I have a large sparse matrix, and I want to permute its rows or columns to turn the original matrix into a block diagonal matrix. Anyone knows which functions in R or MATLAB can do this? Thanks a lot.
I'm not really set up to test this, but for a matrix m I would try:
p = symrcm(m);
block_m = m(p,p);
If that doesn't work, look through the other functions listed in help sparfun to see if any will help you out.
The seriation package in R has a number of tools for problems related to this one.
Not exactly sure if this is what you want, but in MATLAB this is what I have used in the past. Probably not the most elegant solution.
I go from sparse to full and then chop the thing into square blocks.
A=full(A);
Then:
blockedmatrix = mat2cell(A, (n*ones(1,size(A,1)/n)), ...
(n*ones(1,size(A,1)/n))); %found somewhere on internetz
This returns a cell, where each entry is of size nxn.
It's easy to extract the blocks of interest, manipulate them, and then restore them to a matrix with cell2mat.
Maybe a bit late to the game, but since there are available commands, here is a simple one. If you have a matrix H and the block diagonal form is needed, you can obtain it through the following lines (MATLAB):
[p,q] = dmperm(H);
H(p,q)
which is equivalent to Dulmage - Mendelsohn permutation.

Resources