reflection of a curve with respect to a plane

6 ビュー (過去 30 日間)
Federico Cotugno
Federico Cotugno 2022 年 6 月 25 日
コメント済み: Federico Cotugno 2022 年 6 月 25 日
Hi, given a curve, i have to plot it's reflection respect a plane defined by a point and a vector.
The curve is: x=-1:0.2:10 and y=x.^2+2, the point and the vector that define the space are P=[2 2 2] and V=[0 0 1].
This is my code by now:
clc;
clear all;
x=-1:0.2:10;
y=x.^2+2;
P=[2 2 2];
V=[0 0 1];
z=zeros(1,56);
ONE=ones(1,56)
A=[x.',y.',z.',ONE.'];
I know that i have to find the distance of each point of the curve from the plane, but i can't find the right way to use the for cycle, i want to use the dot function for each row and than create the reflection matrix.Use this matrix to calculate the new coordinate for each point and create the new matrix made with the coordinate of the reflect curve.This is my cycle for,it's not right but i write for make my self clear about my idea:
for i=1:length(x)
A2{i}=A(i,:);
A2t=A2'
C=cell2mat(A2t)
dist=dot(C-P,V);
d=abs(dist);
T=[1 0 0 (2*d*0);0 1 0 (2*d*0);0 0 1 (2*d*1);0 0 0 1];
B=T*C'
F=[B 56]
end
  5 件のコメント
Federico Cotugno
Federico Cotugno 2022 年 6 月 25 日
maybe i didn't make myself clear.This is a specific unversity assignment,i have to do it in that way,with the matrix of reflection.I just need to know how to make that foor loop work
Federico Cotugno
Federico Cotugno 2022 年 6 月 25 日

サインインしてコメントする。

採用された回答

Torsten
Torsten 2022 年 6 月 25 日
編集済み: Torsten 2022 年 6 月 25 日
x = -1:0.2:10;
y = x.^2 + 2;
z = zeros(size(x));
P = [2 2 2];
V = [0 0 1];
d = (P.' - [x;y;z]).' * V.';
Ps = [x;y;z] + 2*V.'*d.'
Ps = 3×56
-1.0000 -0.8000 -0.6000 -0.4000 -0.2000 0 0.2000 0.4000 0.6000 0.8000 1.0000 1.2000 1.4000 1.6000 1.8000 2.0000 2.2000 2.4000 2.6000 2.8000 3.0000 3.2000 3.4000 3.6000 3.8000 4.0000 4.2000 4.4000 4.6000 4.8000 3.0000 2.6400 2.3600 2.1600 2.0400 2.0000 2.0400 2.1600 2.3600 2.6400 3.0000 3.4400 3.9600 4.5600 5.2400 6.0000 6.8400 7.7600 8.7600 9.8400 11.0000 12.2400 13.5600 14.9600 16.4400 18.0000 19.6400 21.3600 23.1600 25.0400 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000 4.0000
  1 件のコメント
Federico Cotugno
Federico Cotugno 2022 年 6 月 25 日
Thanks, ours prof told us to use the for loop,i don't get why if it was this simple.Thank you very much <3

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCurve Fitting Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by