Three.js b-spline fitting, how can i do it? - three.js

I have large number of points in 3D space. I want to fit b-spline and display this spline with three.js. How can i do this? Preferably I want some tips or examples how to do it.

Related

How can we compute the minimum bounding sphere enclosing a 3D mesh object?

I want to plot a sphere unit around a 3D object (.obj format file) with matlab, in order to guarantee a normalization of all the objects in my DB, and so on to achieve the scale invariance. I found in the state of the art that there are some algorithms implemented with C++ like Gartner's algorithm that is the fastest https://www.inf.ethz.ch/personal/gaertner/miniball.html, Fisher's algorithm which is more efficient for high dimensions https://github.com/hbf/miniball or welzl'one, or Mogiddo's algorithm too.
My question is: does the function sphere in matlab do the same thing, so all we have to do is to change the center of the sphere, or there is a specific matlab implementation for one of those algorithms above?

Find 2D plane in the center of 3D object

I'm building a segmentation algorithm. I'm segmenting pieces of paper in a book that have been slightly crumpled. Imagine taking a piece of paper, crumpling it into a ball, and then trying to straighten it back out.
The piece of paper is an actually 3D object (has depth -- small but still existent), but I want to segment a 2D plane running through the geometric center of the 3D object. Is this a center of mass problem?
I have a 3D matrix of binary values -- 1 being on the piece of paper, and 0 not on the piece of paper.
What kind of algorithm can I run to find the 2D plane?
You may want a 3D least-squares plane fit. This will minimize the separation between your plane and the voxel points. See here for math and code: http://www.ilikebigbits.com/blog/2015/3/2/plane-from-points

convert polygon to svg bezier curve

As far as I can tell, there isn't a great answer to this problem, but hoping someone out there might be able to provide some guidance. Polygons rendering in canvas or SVG are fine, but the more granular the data, the more dismal the performance gets. This is especially true when a spline-basis algorithm is applied to polygon to create the illusion of a 'smooth' polygon. A smooth polygon is technically impossible because they are simply lines, so all you can do is add more points to create the this illusion.
Does anyone know of a way to take a polygon and convert it to bezier curves using a spline basis algorithm?
Edit:
Essentially I'm looking for what this Corona SDK is doing in this video:
Take a large amount of straight points and converting them to fewer curve points creating a smooth look of the original path (and less data).
https://www.youtube.com/watch?v=v63NAzQE7Bw

Kabsch Algorithm for 2d to 3d Rotation and Translation

My problem involves matching a set of 2d points to a set of 3d points, with known correspondence between the two. Basically I have points on an image, and I need the optimal translation and rotation to fit the points to a known 3d point cloud. Kabsch algorithm is originally meant for finding the best fit of 3d points to another point cloud, and there are implementations out there for 2d to 2d, but not something I can use. I do know it's possible, but just don't know how to go about it. I searched for code out there and came up empty. I'm programming in matlab at the moment, but any language would do.
Thank you.
Edit: The goal is getting a rotation and translation of the 3d point cloud to best match the 2d points when it is projected onto an image plane.
I should also mention that the 3d to 2d projection is done using a weak perspective.
So basically, you have a "plane" or a "line" of points, like the third dimension was 0. You could threat them like this, and use the tipicall kabsh algorithm of squared distance minimisation, don't you?
EDIT: maybe it's a nonsense, but what about projecting the 3d body to 2d coordinates, and do a 2d comparison? Computationally is expensive, so it includes exploring all the angles of the 3d object + projection, but it's easier losing one dimension by applying a projection, that adding a new dimenssion to a 2d point.

Is there an algorithm for solving such projection reconstruction geometric problem?

We have a grid with red squares on it. Meaning we have an array of 3 squares (with angles == 90 deg) which as we know have same size, lying on the same plane and with same rotation relative to the plane they are lying on, and are not situated on same line on plane.
We have a projection of the space which contains the plane with squares.
We want to turn our plane projection with squares so that we would see it like it's facing us, in general we need a formula for turning each point of that original plane projection so that it would be facing us like on the image below.
What formulas can be used for solving such problem, how to solve it, has any one faced something like this before?
This is a special case of finding mappings between quadrilaterals that preserve straight lines. These are generally called homographic transforms. Here, one of the quads is a square, so this is a popular special case. You can google these terms ("quad to quad", etc) to find explanations and code, but here are some for you.
Perspective Transform Estimation
a gaming forum discussion
extracting a quadrilateral image to a rectangle
Projective Warping & Mapping
ProjectiveMappings for ImageWarping by Paul Heckbert.
The math isn't particularly pleasant, but it isn't that hard either. You can also find some code from one of the above links.

Resources