2
$\begingroup$

I think someone should have asked this, but I could not find the answer. If anyone knows similar question, please let me know on the comment!

I want to convert 3D data to 2D cross section data.

For example, I have 3D data such as

Flatten[Table[{i, j, Sqrt[(i/2)^2 + j^2]}, {i, -100, 100}, {j, -100, 100}], 1]

Data looks like this.

enter image description here

I want to see the cross-sectional plot along the linear line. If I have any linear line on this 3D plot such as

enter image description here

I am expected to get 2D data like this along the linear cut that I made

enter image description here

Because I know how the function looks like so I can analytically calculate the 2d cross-section.

Assume that I do not know how the data looks like, can I do it numerically with Mathematica? Does it still work even if I have big data such as (2500x2500x2500)?

$\endgroup$

1 Answer 1

3
$\begingroup$

You can create an interpolating function that you can then call with a parametric equation representing cross sections. Try this:

    dat = Flatten[Table[{i, j, Sqrt[(i/2)^2 + j^2]}, {i, -100, 100}, {j, -100, 100}], 1];
    res = Interpolation[dat];
    Plot[{res[t, t/2], res[t, t], res[t, -t + 3]}, {t, -100, 100}]
    Show[{ListContourPlot[dat], ParametricPlot[{{t, t/2}, {t, t}, {t, -t + 3}}, {t, -100, 100}]}]

enter image description here

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.