How can I plot a tube surface with Scilab - surface

I have to draw a tube, aligned along a sine wave in the (x,y) plane. The length and radius of the tube is known. I have read in the Wikipedia page https://en.wikipedia.org/wiki/Channel_surface that this surface is called a "pipe" surface and that the parametric equations are given in the 3D space by
x=x(u,v)=c(u)+R*(e1(u)cos(v)+e2(u)sin(v))
where r is the radius of the pipe, u->c(u) is the parametric equation of the curve, (e1(u),e2(u)) two vectors forming a basis of the normal plane at c(u) and v is the parameter of the circle (from 0 to 2*pi).
How can I apply this for a sinus curve in the plane and plot the resulting surface with Scilab ?

If the curve is defined by u->c(u)=(u,sin(u),0), then the vectors of the normal plane can be defined by e1(u)=(cos(u),-1,0)/sqrt(1+cos(u)^2) and e2=(0,0,1). The following code draws a tube of radius 0.5 along u->c(u) for u in [0,2*pi]:
[u,v]=meshgrid(linspace(0,2*%pi,40),linspace(0,2*%pi,40));
r=0.5;
cu=cos(u);
d=sqrt(1+cos(u).^2);
clf
mesh(u+r*cos(v).*cu./d,sin(u)-r*cos(v)./d, r*sin(v));
isoview("on")

Related

Calculate angle on a plane in 3D space from a 2D image

I have 2 input images of a plane where the (static) camera is at an unknown angle. I managed to extract edges and points of interests using opencv. But I'm stuck calculating real angles from the images.
From image #1 I need to calculate the camera angle relative to the plane. I know 3 points on the plane that form a equilateral triangle (angles of 60 degree). The center point of the triangle is also the centerpoint of the plane. However the plane center point on the image is covered by another object.
From image #2 I need to calculate the real angle of an object (Point C) on the plane to one of the 3 points and the plane center point (= line A to B).
How can I calculate the real angle β as if the camera had no angle towards the plane?
Update:
I was looking for a solution for my problem at https://docs.opencv.org/3.4/d9/d0c/group__calib3d.html
There is a number of functions but I couldn't figure out how to apply them to my specific problem.
There is a function to calculate Homography using two images with keypoints but I do not have images of the scene from different camera angles.
Then there is cv::findHomography which Finds a perspective transformation between two planes. I know 4 source points but what are my 4 destination points?
Another one I was looking at is cv::solvePnP and cv::solvePnPRansac but again I only know 4 source points on the plane. I don't know about their 3D correspondence point.
What am I missing?
#Micka: Thanks for your input. I have 4 points for processing the image (the 3 static base points + the object at point C). I can assume these points are all located on the plane at z=0. However I do not have coordinates for a second plane neither the (x,y) of the corresponding 3D points.
Your description does not explicitly say it, but if you can assume that segment AB bisects the base of the triangle, then you have 4 point correspondences between the plane and its image, so you can use cv::findHomography.

Intersection of a plane with surface of ListSurfacePlot3d

If I have a list of points in 3D space that are only roughly located on a surface, this surface can be visualized with ListSurfacePlot3D in Mathematica. How can I find the intersection of this approximate surface with a plane, that spans between two vectors u and v? And to continue this, how would I find the intersection of the resulting line with another plane that spans between two vectors m and n?
The dataset of points is available here: https://www.dropbox.com/s/rlj91jrh1bp4g2c/data.txt?dl=0

Convert grid of dots in XY plane from camera coordinates to real world coordinates

I am writing a program. I have, say, a grid of dots on a piece of paper. I fix one end and bend the paper toward the screen, giving me a trapezoidal shape from the camera's point of view. I have the (x,y) camera coordinate of each dot. Is there a simple way I can change these (x,y) to real life (x,y) which should give me a rectangle? I have the camera/real (x,y) of the original flat sheet of paper pre-bend if that helps.
I have looked at 3D Camera coordinates to world coordinates (change of basis?) and Transforming screen coordinates from security camera to real world coordinates.
Look up "homography". The transformation from a plane in 3D space to its image as captured by an ideal pinhole camera is a homography. It can be represented as a 3x3 matrix H that transforms the 3D coordinates X of points in the world to their corresponding homogeneous image coordinates x:
x = H * X
where X is a 3x1 vector of the world point coordinates, and x = [u, v, w]^T is the image point in homogeneous coordinates.
Given a minimum of 4 matches between world and image points (e.g. the corners of a rectangle) you can estimate the parameters of the matrix H. For details, look up "DLT algorithm". In OpenCV the routine to use is findHomography.

3D alpha shape yielding unexpected convex hull of surface

I executed the 3D alpha shape function with CGAL and I got unexpected results.
My input data was a set of 3D points (x, y, z) that represents one building (box) in a flat area (with some noise in the coordinates - small ones). I supposed I would get as a result only the surface triangles that represent the building (walls and roof) and the ground.
But, as a result I got triangles forming a convex hull of the surface.
I tried to change the "optimal alpha value" but it was the same.
Is there any filtering process or parameter that I can set to get the surface triangles only?
You need to find the tetrahedons on the surface of the shape first. Then you can try alpha shapes and remove the edges exceeding alpha. In CGAL you Then check all tetrahedons if they are connected with a super tetrahedon. These are the tetrahedons on the surface of the shape. Then apply alpha shapes.

kinect object measuring

I am currently trying to figure out a way to calcute the size of a given object with kinect
since I have the following data
angular field of view of the lens
distance
and width in pixels from a 800*600 resolution
I believe this can be possible to calculate. Does anyone has math skills to give me a little help?
With some trigonometry, it should be possible to approximate.
If you draw a right trangle ABC, with the camera at one of the legs (A), and the object at the far end (edge BC), where the right angle is (C), then the height of the object is going to be the height of leg BC. the distance to the pixel might be the distance of leg AC or AB. The Kinect sensor specifications are going to regulate that. If you get distance to the center of a pixel, then it will be AC. if you have distances to pixel corners then the distance will be AB.
With A representing the angle at the camera that the pixel takes up, d is the distance of the hypotenuse of a right angle and y is the distance of the far leg (edge BC):
sin(A) = y / d
y = d sin(A)
y is the length of the pixel projected into the object plane. You calculate it by multiplying the sin of the angel by the distance to the object.
Here I confess I do not know the API of the kinect, and what level of detail it provides. You say you have the angle of the field of vision. You might assume each pixel of your 800x600 pixel grid takes up an equal angle of your camera's field of vision. If you do, then you can break up that field of vision into equal pieces to measure the linear size of your object in each pixel.
You also mentioned that you have the distance to the object. I was assuming that you have a distance map for each pixel of the 800x600 grid. If this is incorrect, some calculations can be done to approximate a distance grid for the pixels involving the object of interest if you make some assumptions about the object being measured.