how to assign 3D points? i have 3D points on graph but i need to use those points as a variable in equation
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
i have generated a virtual 3D cube. as a result a graph is generated and on the graph, at each surface there are 4x4 points. i need to use those points as variables for an equation. can you please tell me how to assign some points that are on a graph, to a variable? this is the code
%%Generate 3D calibration pattern:
%%Pw holds 32 points on two surfaces (Xw = 1 and Yw = 1) of a cube
%%Values are measured in meters.
%%There are 4x4 uniformly distributed points on each surface.
cnt = 1;
%%plane : Xw = 1
Pw = zeros(4,3);%preallocating Pw
for i=0.2:0.2:0.8,%it means it starts from 0.2 gives an interval 0.2 and goes till 0.8
for j=0.2:0.2:0.8,
Pw(cnt,:) = [1 i j];%is the cnt-th row of pw , pw is a matrix whos cnt-th row is a row matrix, cnt is a variable that starts from 1 and after forming
%the row matrix, it goes on till i and j conditions are fulfilled.
cnt = cnt + 1;
end
end
%%plane : Yw = 1
for i=0.2:0.2:0.8,
for j=0.2:0.2:0.8,
Pw(cnt,:) = [i 1 j];
cnt = cnt + 1;
end
end
N = cnt;
%%plot3(Pw(:,1), Pw(:,2), Pw(:,3), '+');
%%Virtual camera model
%%Extrinsic parameters : R = RaRbRr
gamma = 40.0*pi/180.0;
Rr = [ [cos(gamma) -sin(gamma) 0];
[sin(gamma) cos(gamma) 0];
[ 0 0 1]; ];
beta = 0.0*pi/180.0;
Rb = [ [cos(beta) 0 -sin(beta)];
[0 1 0];
[sin(beta) 0 cos(beta)]; ];
alpha = -120.0*pi/180.0;
Ra = [ [1 0 0];
[0 cos(alpha) -sin(alpha)];
[0 sin(alpha) cos(alpha)]; ];
R = Ra*Rb*Rr;
T = [0 0 4]';
%%Intrinsic parameters
f = 0.016;
Ox = 256;
Oy = 256;
Sx = 0.0088/512.0;
Sy = 0.0066/512.0;
Fx = f/Sx;
Fy = f/Sy;
%%asr is the aspect ratio
asr = Fx/Fy;
%%Generate Image coordinates
%%surface Xw = 1
cnt = 1;
Pc = zeros(16,3);
n=length([(Ox - Fx*Pc(cnt,1)/Pc(cnt,3)) (Oy - Fy*Pc(cnt,2)/Pc(cnt,3))]);
p=zeros(16,n);
for cnt = 1:1:16,
Pc(cnt,:) = (R*Pw(cnt,:)' + T)';
p(cnt,:) = [(Ox - Fx*Pc(cnt,1)/Pc(cnt,3)) (Oy - Fy*Pc(cnt,2)/Pc(cnt,3))];
end
plot(p(:,1), p(:,2), 'r+');
axis([0 512 0 512]);
grid;
hold;
%%surface Yw = 1
for cnt = 17:1:32,
Pc(cnt,:) = (R*Pw(cnt,:)' + T)';
p(cnt,:) = [(Ox - Fx*Pc(cnt,1)/Pc(cnt,3)) (Oy - Fy*Pc(cnt,2)/Pc(cnt,3))];
end
plot(p(17:32,1), p(17:32,2), 'g+');
%%plot3(Pc(:,1), Pc(:,2), Pc(:,3), '+');
grid;
this is the graph
please open the picture in new tab to preview the graph.. thank you
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Graph and Network Algorithms finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!