how to generate Bezier curves from 3D mesh?

459 Views Asked by At

after generating 3D mesh (car chassis) By : RGB-D camera (Like : Kinect - Intel Real Sense etc ... ) and extracting feature lines on the surface of the 3D mesh.

I need to generate the Bezier curves from the lines extracted on the car chassis

so is there any algorithm to do it.

1

There are 1 best solutions below

0
On BEST ANSWER

Reverse engineering Bezier curves ....

B(t) = (1t) 3p0 + 3(1t) 2tp1 + 3(1t) t2p2 + t3p3 where p0, p1, p2, p3 are the control points.

So the interesting thing about Bezier curves is that they are easy to work with, theoretically and programmatically.

There’s only one problem; the curve does not pass through its control points. The curve actually lies in the convex hull of the control points.

This means the control points may not lie on the curve, which makes calculating tangents and normals (for use in 3D trigonometry) tedious.

What I want to do is to define four points and have a Bezier curve passing through all four points. Basically, given the four original points q0, q1, q2 and q3, I will find four points p0, p1, p2 and p3 such that the Bezier curve calculated using points p(i), will pass through the points q(i).

So going back to the equation above, when t is zero, the equation effectively collapses into just p0. When t is one, the equation gives p3.

When t is between zero and one, the resulting point lies on the curve itself, so iterating t from zero to one will give the Bezier curve. Since we know the curve will pass through p0 and p3, we need to find p1 and p2.

Suppose we want the curve to pass through p0 when t=0, f when t=u, g when t=v and p3 when t=1, where f and g are the points to be passed through. Next, we make sure that 0 < u,v < 1 and u not equal to v. These conditions will ensure a solution can be found.

Next, we substitute the desired points into the equation:

f = (1u) 3p0 + 3(1u) 2up1 + 3(1u) u2p2 + u3p3

g = (1v) 3p0 + 3(1v) 2vp1 + 3(1v) v2p2 + v3p3

The two equations are then simplified into

3(1u) * 2up1 + 3(1u) * u2p2 = c

3(1v) * 2vp1 + 3(1v) * v2p2 = d

where ;

c = f – (1u)3p0 – u3p3

d = g – (1v)3p0 – v3p3

This set of equations has a unique solution when 0 < u,v < 1 and u not equal to v, and assuming c and d aren’t both zero vectors. The equations have a unique solution because the determinant is not zero. Let’s transform the set of equations into matrix form before explaining what a determinant is. [the equation's matrix] in the link below

The determinant for the above 2 by 2 matrix on the leftmost side is 3(1u) 2u * 3(1v) v2 – 3(1u) u2 * 3(1v)2v

Factorising this, we get

9uv(1u)( 1v)[( 1u) v u( 1v)] = 9uv(1u)( 1v)[ v uv u +uv] = 9uv(1u)( 1v)[ v u]

Since 9 obviously is not equal to 0, and 0 < u,v < 1 (so u,v not equal to 0 and (1u),( 1v) not equal to 0) and u not equal to v (so vu is not equal to 0), therefore, the determinant is not equal to 0.

By a theorem in linear algebra, this means the set of (linear) equations has a unique solution. For a 2 by 2 matrix, the determinant can be obtained by taking the product of the topleft element and bottomright element, then subtract the product of the topright element and bottomleft element. Like drawing a cross.

Next, we multiply the inverse of the 2 by 2 matrix on the left of both sides of the equation and we get

Note that the inverse will cancel the matrix on the left side. The inverse (of a 2 by 2 matrix) is obtained by swapping the topleft and bottomright elements, then switch the signs of the topright and bottomleft elements, and then divide each element by the determinant. The determinant is nonzero, so division by zero is not a problem. A nonzero determinant also means an inverse actually exists (by another theorem in linear algebra), so all of this works out fine. Now all you have to do is calculate that right side and that’s it. Make sure you calculate for x, y and z, meaning you have to do the calculation three times.

I found this solution in this link 3