Message Boards Message Boards

0
|
4214 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How to get more points?

Posted 10 years ago

Hi there,

Let me try to explain what I need. I have a .txt file of three columns. In the first column is the x coordinate, the second is displacement above the horizontal axis, and the third column is displacement below the horizontal axis. You can roughly imagine that the object that those coordinates represent is an ellipse with center somewhere in first quadrant. I would add the file here, but my professor said I should not publish it anywhere online.

Now this file has about 100 x-coordinates, but this is not sufficient. It is super sufficient to fit a BezierCurve, but I would need to have at least 5-10 more points between the two existing ones.

So my question is: I have a super good fit of BezierCurve to the 100 points in my text file. Now I need to get 500-1000 points for the same body (in the same format: first column x, second column top displacement, third column displacement below the horizontal line).

Is there like any easier way, than manually reading coordinates from a graph?

I highly appreciate any help! I am not a master in mathematica programming.

POSTED BY: Mitja Jan?i?
4 Replies

Flatten to join the step column into a flat list. Map to try the BesierFunction for each new step. Export to make a new data file.

extraSteps = Map[f, Flatten[step]];
Export["C:\Users\Mitja\Documents\nova\extraSteps.txt", extraSteps, "CSV"]

Haha :D

I can't stop talking to myself. In excel I created a txt file of: 0.000, 0.001, 0.002, ... Which I than Imported into matematica.

In[79]:= f = BezierFunction[up]

Out[79]= BezierFunction[{{0., 1.}}, <>]

In[76]:= step = 
 Import["C:\\Users\\Mitja\\Documents\\nova\\hungary.txt", "Table"]

Out[76]= {{0}, {0.001}, {0.002}, {0.003}, {0.004}, {0.005}, {0.006}, \
{0.007}, {0.008}, {0.009}, {0.01}, {0.011}, {0.012}, {0.013}, \
{0.014}, {0.015}, {0.016}, {0.017}, {0.018}, {0.019}, {0.02}, \.................
{0.982}, {0.983}, {0.984}, {0.985}, {0.986}, {0.987}, {0.988}, \
{0.989}, {0.99}, {0.991}, {0.992}, {0.993}, {0.994}, {0.995}, \
{0.996}, {0.997}, {0.998}, {0.999}, {1}}

Now how do I convince Mathematica to return me coordinates of "f" in values of this step.txt file and maybe even export the coordinates in a new .txt file. ?

POSTED BY: Mitja Jan?i?
In[35]:= f = BezierFunction[up]

Out[35]= BezierFunction[{{0., 1.}}, <>]

In[38]:= f[.006]

Out[38]= {0.0079828, 0.174925}

Haha, I apologize for talking with myself here. :D

The code above, shows that it is possible to get coordinates using BezierFunction. If I parametrize it (for parameter t in [0,1]) I can get coordinates along the whole Bezier curve.

Now this I do not know: How to now split the interval [0,1] to 1000 equal parts so that Mathematica will return me the coordinates (it can also export it directly in some txt file). I really don't want to manually write 1000 values of parameter to get all the coordinates.

Now I wait for your help. :D Because this is where my knowledge of mathematica ends.

Thank you!

POSTED BY: Mitja Jan?i?

I don't know how BezierFunction works (I don't know the theory behind it) but maybe there is a way to get more points from this?

POSTED BY: Mitja Jan?i?
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract