I know the unit vector of the axis to a cylinder oriented in 3D space. Is there any module or function in OpenSCAD to reorient the cylinder after I create it about the z-axis? Regular rotate function just rotates about the corresponding axis but I have the angle between the central axis to the cylinder and my coordinate axis.
Look at the line module in the User Manual:
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Tips_and_Tricks#Drawing_%22lines%22_in_OpenSCAD
Related
I wish to put 2D curve fitting to different axis within a 3D plot. I am attaching an image for reference.
on this actual data set:
As you can see the curve fitting for x and y axis is at z=0 value, I need that at say z=10.
Further, when I try to do curve fitting for x and z data set or y and z data set, the fitted curve instead of appearing on the the X-Z plane or Y-Z plane, is appearing on the X-Y plane.
All help is appreciated.
I have a 3d plane (made up of number of points) which is rotated at weird angle. I want to make it flat i.e lie on xy-plane. I have plane equation but I think my calculated angles are not correct or might be using wrong rotation matrix. By wrong rotation matrix is that I meant that I am not sure about which axis should I rotate. attached is the picture of my plane:
I tried to calculate by using following formulas:
theta=-acosd((dot(n1,n2))/(norm(n1)*norm(n2)));
Calculate spherical angles: theta and phi;
both methods are giving same angle, I rotated my plane first about z-axis and then about y-axis. The resulted plane is almost flat but it still has some anlge.
I tried both rotation matrix and Rodrigues' rotation matrix. It would be really helpful if someone could suggest how to rotate this plane to make it flat.
When a plane is not parallel to the xy-plane, then it's normal vector will not be parallel to the z-axis. So the cross product of the normal vector and the z-axis (unit) vector will be non-zero. This vector is in the plane and parallel to the xy-plane. Take it as rotation axis. The rotation angle to make the plane parallel to the xy-plane is the same as the angle between the normal vector and the z-axis.
I am wondering if there is a way to build a random 3D surface from only one (top-down) 2D image of this surface. The fact is that the 3D surface needs the z-coordinates (the heights and the depths) and the 2D (top-down) image gives only the x and y coordinates.
I believe that the main problem is that we can't get the real ranges of the dimensions (x,y,z) of the surface from one 2D (top-down) image but we can get some kind of normalized scaling which is not the real one (it's just similar).
For example:
If we have an image with a surface (2D) and we want 3D of this surface (x,y,z) we can have easily the x and the y coordinates from the image. We can't have the real range of the amplitude (z coordinate) in each point of the surface but only the gray-tones scaling. Is there any ideas on how could we take the real sizes of the amplitudes of a surface from one 2D (top-down) image?
Left is a sample of 2D top-down image and Right is a surface which created by the 2D
http://www.sendspace.com/file/9wzx0u
p.s.
I can't post an image because of my reputation, so I uploaded one on sedspace.com.
Read in the image:
A = imread(filename)
Plot the surface plot using the magnitude of the value read in for each x and y from the file:
surf(A)
I'm trying to compute 2d projections of a 3d mesh from different views using matlab.
The solution I m using now, is to plot the 3d mesh, rotate it, and make a screenshot.
I would like to know if there is any matlab internal functions or any other solution that allow me, given a set of vertices and triangles, to compute the projections without having to plot the 3D mesh
Thanks
You can use the view command to rotate the axes and change the viewpoint. The azimuth and elevation are given in degrees (ref. documentation for more info). Here's a small example:
ha=axes;
[x,y,z]=peaks;
surf(x,y,z);
xlabel('x');ylabel('y');zlabel('z')
%#projection on the X-Z plane
view(ha,[0,0])
%#projection on the Y-Z plane
view(ha,[90,0])
%#projection on the X-Y plane
view(ha,[0,90])
This is what it looks like:
Projections on different 2D planes
X-Z
Y-Z
X-Y
I know Matlab has a function called cylinder to create the points for a cylinder when number of points along the circumference, and the radius length. What if I don't want a unit cylinder, and also don't want it to center at the default axis (for example along z-axis)? What would be the easiest approach to create such a cylinder? Thanks in advance.
The previous answer is fine, but you can get matlab to do more of the work for you (because the results of cylinder separate x,y,z components you need to work a little to do the matrix multiplication for the rotation). To have the center of base of the cylinder at [x0 y0 z0], scaled by [xf yf xf] (use xf=yf unless you want an elliptic cylinder), use:
[x y z] = cylinder;
h=mesh(x*xf+x0,y*yf+y0,z*zf+z0)
If you also want to rotate it so it isn't aligned along the z-axis, use rotate. For example, to rotate about the x-axis by 90 degrees, so it's aligned along the y-axis, use:
rotate(h,[1 0 0],90)
Multiply the points by your favourite combination of a scaling matrix, a translation matrix, and a rotation matrix.