Rotate the centre plate in a geometry

Hi,
I wanted to rotate the inner rectangle (only) to 45 degree, which (0,0) as the fixed point as rotation. I am not sure how to do it by the coordinates. This is my code:
function Nano_Sphere_Dat_Generator
clear
clc
clf
%set value of geometric parameters
a=0.0;
b=0.0;
c=1000;
plate_length=30000;
plate_width=1000;
pos_CNN=10000;
channel_length=100000;
channel_width=60000;
upstream_dist=30000;
CNN_width=0.001;
%create the outer boundary
p1(1)=a-upstream_dist;
p1(2)=-channel_width/2;
p2(1)=a-upstream_dist+channel_length;
p2(2)=-channel_width/2;
p3(1)=a-upstream_dist+channel_length;
p3(2)=channel_width/2;
p4(1)=a-upstream_dist;
p4(2)=channel_width/2;
plot([p1(1),p2(1)],[p1(2),p2(2)])
hold on
plot([p2(1),p3(1)],[p2(2),p3(2)])
plot([p3(1),p4(1)],[p3(2),p4(2)])
plot([p4(1),p1(1)],[p4(2),p1(2)])
axis equal
%create the plate geometry
p5(1)=a;
p5(2)=b;
p6(1)=a+pos_CNN;
p6(2)=b;
p7(1)=a+pos_CNN+CNN_width;
p7(2)=b;
p8(1)=a+plate_length;
p8(2)=b;
p9(1)=a+plate_length;
p9(2)=b-plate_width;
p10(1)=a
p10(2)=b-plate_width;
scatter(p5(1),p5(2))
scatter(p6(1),p6(2))
scatter(p7(1),p7(2))
scatter(p8(1),p8(2))
scatter(p9(1),p9(2))
scatter(p10(1),p10(2))

Réponses (1)

darova
darova le 11 Août 2021

0 votes

You can rotate it using rotation matrix
Or you can use rotate()

8 commentaires

ka chun yick
ka chun yick le 11 Août 2021
Hi,
If i using rotate()
According to the Matlab tutorial: https://uk.mathworks.com/help/pde/ug/pde.discretegeometry.rotate.html
The theta is 45, but i could i define all the points into this statement?
Rewrite your code
x = [p6(1) p7(1) p8(1) p9(1) p10(1)];
y = [p6(2) p7(2) p8(2) p9(2) p10(2)];
h = scatter(x,y);
h1 = rotate(h,15,[0 0 0 ])
ka chun yick
ka chun yick le 13 Août 2021
I got the following errors:
Error using rotate
Too many output arguments.
Error in CNT_geom_generator (line 65)
h1 = rotate(h,60,[0,0,0])
Try withou output argument
rotate(h,60,[0 0 0])
ka chun yick
ka chun yick le 20 Août 2021
unfortunately, it seems not working...
darova
darova le 20 Août 2021
Modifié(e) : darova le 20 Août 2021
sorry, wrong order of arguments
t = linspace(0,2*pi,5)+pi/4;
[x,y] = pol2cart(t,1);
h = plot(x,y,'r');
rotate(h,[0 0 1],15,[0 0 0]) % (handle,axis rotation,angle,origin)
line(x,y)
axis equal
legend('rotated','original')
ka chun yick
ka chun yick le 20 Août 2021
Thanks, really appreciate the code. Regarding my question: how to rewrite the previous not working code of mine?
x = [p6(1) p7(1) p8(1) p9(1) p10(1)];
y = [p6(2) p7(2) p8(2) p9(2) p10(2)];
h = scatter(x,y);
h1 = rotate(h,15,[0 0 0 ])
darova
darova le 20 Août 2021
Change it to according to my previous code

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB Support Package for USB Webcams dans Centre d'aide et File Exchange

Tags

Question posée :

le 11 Août 2021

Commenté :

le 20 Août 2021

Community Treasure Hunt

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

Start Hunting!

Translated by