Curve Fitting in Matlab [duplicate] - math

This question already has answers here:
Equation of a helix parametrized by arc length between two points in space
(2 answers)
Closed 3 years ago.
Given two points say (1,2,3) and (4,7,8). The endpoint tangents at these points are also given as inputs say pi/4 and -pi/2 respectively. How to fit a helix of arc length 2 between these points?
How to implement this in Matlab?

I'm not sure what toolboxes you have access to, but you should check the documentation for these two:
Curve Fitting toolbox
Spline toolbox
I think there may be a number of different ways you could approach the problem (i.e. different types of curves to use to match an arbitrary set of points and tangents).

Related

Finding correspondence between two sets of 3d points

I am currently implementing the gradient descent algorithm for finding the best possible transformation of a set of points to another set of points.
The problem I'm having is currently the problem of finding the corresponding points in each set, I used the minimum distance to correspond the points but I ran into the problem that all points correspond to only points on one side
Like for example the 2d image below
Is there any approach that I can take to resolve this?

Approximate a list of points with a short list of Bézier curves

I have a list of (x, y) points. I know how to make a list of Bézier curves which pass through all of those points and have a continuous first (and second, though less important) derivative. However, the list that I end up with is far too long. I would prefer to approximate the points I have if it lets me cut down on the number of curves I have. I would like to be able to pass a parameter of either how close an approximation I get or a maximum number of curves, preferably the former.
The reason I want this is that the end result will have a graphical UI where users can edit the Bézier curves, and it isn't critical that the curves pass through each point exactly, as long as they are close. More curves makes it harder to edit.
EDIT:
Some more information about the purpose of this. I'm trying to make image editing software. When someone loads a bitmap, I want to be able to trace a center line. Potrace is what I would use to trace the outline of a shape, but it won't work for tracing strokes. I've been able to identify lots of points along the center line, and I want to turn this data into a list of connected Bézier curves. The reason I don't want to make a Bézier spline is that there will be too many control points for this to be easy to edit. "Too many" is not an easy-to-define term, but I would like to be able to pass a parameter to limit the number of curves. Either a function that minimizes how far the curves are from the points based on a maximum number of curves or a function that minimizes the number of curves based on a maximum deviation from the points.
Several approaches exist for achieving what you want to do:
1) Use RDP algorithm to reduce the number of points, then create a list of Bezier curves passing thru the remaining points.
2) Use curve fitting algorithms (for example, Schneider algorithm) to produce multiple Bezier curves that are connected with G1 (tangent) continuity. Check out Schneider algorithm implementation in this link.
3) Use least square fitting with B-spline to produce a single B-spline curve.
From implementation point of view, approach 1 is probably the easiest one for you as you already know how to create Bezier curves interpolating a list of points. Approach 3 will be much more difficult to implement and you probably will have to convert the B-spline curve into Bezier curves so as to use them at the UI level. Please refer to this SO article for detailed discussion.

How to generate a mathematical formula by its graph? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Given a graph of a formula, how can I find its formula?
Do I need some OCR or something like that?
In general you need:
detect the graph position (bounding box) in image
you are usually looking for rectangle outlined (usually in black) area
extract/input graph scales
either input them by user or read via OCR (as you suggested). The scale values and units are usually along the x,y axises of the graph bounding box. You need to find at least 2 separate points per axis to form transformation from pixels to units. In case of non linear scales you need to have more points to detect log,etc scales ...
extract graph points
the graph curve is usually in different color or stroke width so it should be relatively easy to extract all points. Form a list of points (in case of function sorted by x).
apply curve fitting on the points from #3
there are many approaches ... can use piecewise interpolation, piecewise approximation BEZIER/SPLINE, interpolation polynomials (Lagrange...) or FFT/DCT (sin waves). For non complicated shapes approximation search minimizing distance between points and computed polynomial will be enough. This step mainly depends on what precision, output function form, runtime you need.
Hard to be more specific as you did not provide any details what so ever.
Finding the mathematical algorithm to which matches an input and output together might help a bit.

Tangents on a flat surface [duplicate]

This question already has answers here:
How to calculate Tangent and Binormal?
(4 answers)
Closed 9 years ago.
Currently I am trying to do some bump mapping but would like to know how to find the tangents of a flat surface. I have already defined my normals but not sure about tangents, I have drawn a diagram and would like some confirmation on whether this is correct or not.
T representing tangent and N representing normals
Here is a link for you showing pretty pictures for tangents and explaining why certain directions for tangents are chosen. Keep in mind that any vector that is perpendicular to the normal is a valid tangent (an entire circle of vectors around the normal that will travel along the tangent plane.) Therefore, your diagram is technically correct. The tangent (and bitangent) vectors aren normally chosen to move along the positive U and V direction of the texture at right angles to each other though to simplify bump/normal mapping. See the link.

quality analysis of fitted pyramid

sorry for posting this in programing site, but there might be many programming people who are professional in geometry, 3d geometry... so allow this.
I have been given best fitted planes with the original point data. I want to model a pyramid for this data as the data represent a pyramid. My approach of this modeling is
Finding the intersection lines (e.g. AB, CD,..etc) for each pair of adjacent plane
Then, finding the pyramid top (T) by intersecting the previously found lines as these lines don’t pass through a single point
Intersecting the available side planes with a desired horizontal plane to get the basement
In figure – black triangles are original best fitted triangles; red
and blue triangles are model triangles
I want to show that the points are well fitted for the pyramid model
than that it fitted for the given best fitted planes. (Assume original
planes are updated as shown)
Actually step 2 is done using weighted least square process. Each intersection line is assigned with a weight. Weight is proportional to the angle between normal vectors of corresponding planes. in this step, I tried to find the point which is closest to all the intersection lines i.e. point T. according to the weights, line positions might change with respect to the influence of high weight line. That mean, original planes could change little bit. So I want to show that these new positions of planes are well fitted for the original point data than original planes.
Any idea to show this? I am thinking to use RMSE and show before and after RMSE. But again I think I should use weighted RMSE as all the planes refereeing to the point T are influenced so that I should cope this as a global case rather than looking individual planes….. But I can’t figure out a way to show this. Or maybe I should use some other measure…
So, I am confused and no idea to show this.. Please help me…
If you are given the best-fit planes, why not intersect the three of them to get a single unambiguous T, then determine the lines AT, BT, and CT?
This is not a rhetorical question, by the way. Your actual question seems to be for reassurance that your procedure yields "well-fitted" results, but you have not explained or described what kind of fit you're looking for!
Unfortunately, without this information, your question cannot be answered as asked. If you describe your goals, we may be able to help you achieve them -- or, if you have not yet articulated them for yourself, that exercise may be enough to let you answer your own question...
That said, I will mention that the only difference between the planes you started with and the planes your procedure ends up with should be due to floating point error. This is because, geometrically speaking, all three lines should intersect at the same point as the planes that generated them.

Resources