周期性の無い3次元の​点を繋ぎ合わせたグラ​フと平面(例えばY=​0)の交点の座標を調​べる方法はありません​か?

6 views (last 30 days)
Ryouga Kojima
Ryouga Kojima on 12 Jan 2023
Commented: Ryouga Kojima on 16 Jan 2023
matlabで周期性の無い3次元の点を繋ぎ合わせたグラフと平面(例えばY=0)の交点の座標を調べる方法はありませんか? 例えを使って簡単に説明すると、Y=0の平面とあるグラフの交点を取りたいのですが、そのグラフではY=0の所に点がある訳ではなく、Y=-5とY=5にある点同士が繋がってる(線形補間?)感じです。
スプライン補完などでできるのでしょうか?

Accepted Answer

交感神経優位なあかべぇ
Edited: 交感神経優位なあかべぇ on 16 Jan 2023
おそらくあまり単純にはできず、地味に計算していくしかなさそうですね……。
下記は2次元の例(X = 0.5の場合のYデータの計算)ですが、このようなことを3次元でやらないといけないと思います。
x = [-2,-1,1,-1.5,5,6];
y = 0:5;
plot(x,y);
hold on;
crossX = 0.5;
xline(crossX);
over0 = x > crossX;
flg = over0(1);
crossIdx = [];
for idx = 2 : length(over0)
if flg && ~over0(idx)
crossIdx(end + 1) = idx;
flg = false;
elseif ~flg && over0(idx)
crossIdx(end + 1) = idx;
flg = true;
end
end
crossY = zeros(1, length(crossIdx));
for idx = 1 : length(crossIdx)
i = crossIdx(idx);
slope = (y(i) - y(i - 1)) / (x(i) - x(i - 1));
crossY(idx) = slope * (crossX - x(i - 1)) + y(i - 1);
end
crossY
crossY = 1×3
1.7500 2.2000 3.3077
  1 Comment
Ryouga Kojima
Ryouga Kojima on 16 Jan 2023
ありがとうございます。頑張ります!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!