reflection of a curve with respect to a plane
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Federico Cotugno
el 25 de Jun. de 2022
Comentada: Federico Cotugno
el 25 de Jun. de 2022
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 comentarios
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!