3D plot from 1×n(one column) vector - wolfram-mathematica

I want to Plot 3D figure from a 1×n(column vector) containing numeric data. I have used ListPlot3D but its not working as I need to convert 1×n(column vector) vector into n×n matrix first then I can use the command
ListPlot3D[{{x1,y1,z1},{x2,y2,z2},…}]
Please guide me how I can convert first 1×n(column vector) into a matrix of order n×n or is there any other way to get 3D plot in Mathematica. I am very new on Mathematica programming. Need your's help to sort out my problem. Highly Appreciated!

I assume that your column vector contains groups of three values that constitute the coordinates of the surface points. In the simplest case, these values are contiguous. In that case, simply use "Partition", like so:
If more rearranging is necessary, use the tools for rearranging lists, as shown here: https://reference.wolfram.com/language/guide/RearrangingAndRestructuringLists.html

Related

Indexing image according to polar coordinates?

Ok, this might be a little dumb to ask but I'm really having a hard time understanding the image coordinates in Matlab.
So, in a mathematical equation, f(x,y) f is the image function where x and y are the coordinates of the image. For example, in matlab code, we can:
img = imread('autumn.tif');
img(1,4); %f(x,y)
where img(1,4) is equivalent to the function f(x,y). Now, in Matlab, there is an option to convert the cartesian coordinate (x,y) to polar coordinate (rho,theta) with cart2pol() function.
Now, here's where I don't understand. Is it possible to apply f(rho,theta) which is the polar coordinates instead of the cartesian coordinate in Matlab?
I tried doing something like:
img(2.14,1.5)
But I get the error message saying about array indexing is only supported with integers or logical values.
Could anyone clear up my understanding on this? Because I'm required to apply f(rho,theta) instead of the conventional f(x,y).
An image in Matlab is basically just an 2D array (if you consider just a greyscale image). Therefore you also need integer indices, just as for all other arrays, to access the pixels of the image.
% i,j integers, not doubles, floates, etc.
pixel = img(i,j);
The polar coordinates from yor last question (theta, rho) can therefore not be used to access the image array. That is also the exact reason for the error message. At least you'd need to round them or find some other way to use them as indices (e.g. convert them back to cartesian coords. would be best, due to matrix indexing)
Regarding your application: As far as I have found out, these polar coordinates are used as parameters for the Zernike polynomials. So why would you use them to access the image?

Projection of a image from inside a cylinder to a plane 2D [Matlab]

With a camera inside a cylinder I capture a image. I want to transform that image into a plane 2d. The image inside the cylinder have a lot of dots which forms a grid.
What I tried to do was estimating the transformation. With blob analysis I can detect the center of each point and obtain the coordinates in pixels. I save this in matrix called ImCilynder. After that i create a matrix with coordinates of that points in the plane with the name Im2d.
I calculate the transformation (H) solving the equation:
Imcilynder * H= Im2d;
H= matrix [9x1]
H=pinv(Imcilynder) * Im2d
But, when i'm doing the test with the same points, the result is completely random, so i'm doing something wrong.
Is there a better way to solve this? Can you help me?
Explaining better,
I'm trying to find the transformation which transforms the image above to this image:
So, to clarify, I want the projection of the points which i see in the first image to a plane. Basically i want o unwrap the cylinder.
After the calculation of the transformation matrix. I'm expecting to multiply the first image with the transformation matrix and obtain the points in the plane. Or to multiply the coordinates of the center of the black dots and obtain the coordinates of that dots in the plane. Is this possibly?
Thank you very much,
Afonso
Well, what do yo wish to have in a plane? the circles forming a grid? Because if this is the case you need to remove the radial distortion, these kind of models are represented by some parameters, are non-linear by the way. May be if you can find a very good algorithm, you are going to obtain something like this:
If this is not your idea, you need to apply an elastic transformation and this kind of transformation needs to use a kind of grid that is the model of the transformation and you need to propose your model of grid. If you want to do this automatically you need to resort to elastic registration algorithms and you can use a model like this one:
Any ways, this is not a trivial task, there are a lot of research about complex transformations of course if you want to automatically obtain the transformation. Otherwise you can use photoshop ;).

Computing a non-affine transformation matrix from 3D data

I have an array of 3D paired points in two different coordinate spaces (A and B).
Given points are not coplanar, how do I compute a non-affine transformation matrix which is able to transform a point from A into B?
I have managed to do this in 2D (using a homography), but can't work out how to make it work in 3D. A quick code example would be much appreciated if possible. :)
The approach described in this post will generalize to three dimensions: If you know the coordinates of five points in both coordinate systems, then you can use them to compute a 4×4 projective transformation matrix for this, which will be unique except for a scale factor which is without geometric relevance.
I've included variations of the required code for 2D in various posts, written for sage, and there is also the JavaScript example mentioned along with the description. Any of these could be adapted to the 3D case, but if you also want to change programming language, then you might be better off implementing the formula directly, keeping in mind that the adjoint may serve as alternative for the inverse of a matrix in several locations.
Here are some details on the generalization to 3D:
Use a 4×4 system of linear equations, with the homogenous coordinates of four points on the left and a fifth point on the right hand side.
Use the four solution variables to scale these four columns in order to obtain the transformation matrix.
(as before)
(as before)
(as before)
(as before)
Divide the first three coordinates of the homogenous coordinate vector by the fourth coordinate to obtain dehomogenized coordinates.

How can I construct a 4x4 rotation matrix to look in the direction of a 4 dimensional vector?

How can I construct a 4x4 rotation matrix to look in the direction of a 4d vectors?
I have two 4d vectors, representing points in four dimensional space, and I need to rotate an object to point from one to the other.
Every solution to similar problems that I've seen only works in three space.
Ideally I would like an efficient solution, as this operation will need to be done every frame, possibly for multiple objects in my game. The project is in the Unity3d engine, and I'm scripting in c#, in case that's relevant.

how to Rotate about an arbitrary axis?

Givens
1- X,y,and Z the world co-ordinate system
2-i,j,k another co-ordinate system.
3-the cosines in which each of i,j, and k make with the X,Y,Z.
problem
how to rotate the i,j,k system about i or j or k??
If you have the cosines of the angles formed by pairing each of i,j,k with each of xhat, yhat, and zhat (nine angles altogether), you have the makings for the direction cosine matrix. For example, see http://www.ae.illinois.edu/~tbretl/ae403/handouts/06-dcm.pdf (or just google direction cosine matrix). The direction cosine matrix is just another name for a transformation or rotation matrix.
Be careful, though!
There is no single standard scheme. You need to know that this is the case and read the literature carefully.
Are you rotating the object or transforming coordinates? Rotation and transformation are conjugate operations. Some people (many people!) use the term 'rotation matrix' when they mean 'transformation matrix', and vice versa.
Do you represent vectors as column vectors or row vectors? Here there is a lot more consistency; most people use column vectors rather than row vectors for things like positions, velocities, etc. BUT there are very good reasons to use row vectors (or column vectors if you are one of those contrarians) for things that properly belong in the dual space.
Quaternions have even more ambiguity of representation than matrices. There's nothing wrong with that (I use quaternions all the time), but you do have to beware of these ambiguities when you read a paper or book, look at someone else's code, or exchange data.
Finally, matrices and quaternions are only two of many charts on SO(3). There are lots of ways to represent rotations in 3-space.
You can first create either a rotation matrix or a quaternion. Then you use that to transform your vectors.
You can find the code to create a rotation matrix or a quaternion in pretty much any 3d maths library.
If I recall correctly you calculated the rotation quaternion as(assuming normalized axis):
q.x=axis.x*sin(alpha)
q.y=axis.y*sin(alpha)
q.y=axis.z*sin(alpha)
q.w=cos(alpha)

Resources