Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

How to creat a surface and contours from 3D lines data (x,y,z)

Asked by stamatis

stamatis (view profile)

on 29 Dec 2012
 Hello i've generated this code to creat the borderlines and center line of a vertical curve road. Basicly i want to creat the contours through the road so as far as i understand i have to creat first the surface of the road. I am not very familiar with the plots of matlab so if anyone have any ideas to creat the surface and or the contours of the road would be really healpfull. A perfect senario would be someone to reveal me how i can transfer the hole project in an autocad drawing.
%MILEAGE start position of the road
 XB1=0;
%road wide
bl=20;
%longitudinal to the road slopes
s1=0.02;
s2=-0.02;
%vertical to the road slope
e=0.025;
%Height of start position of the road
HB1=10;
%Radius of the curve of the road
Hw=3000;
%Tangent length
T=(Hw/2)*(s1-s2);
%2*T=Total  milage curve length
% milage end of the road
XB2=XB1+2*T;
%rates of quadratic parabola
a=(s1-s2)/(2*(XB1-XB2));
b=s2-2*a*XB2;
g=HB1-a*XB1^2-b*XB1;
%Quadratic parabola
H= @(x) a*x^2+b*x+g;
i=0;
L=zeros(((2*T)/0.1),3);
for x = XB1 : 0.1 : XB2
    i=i+1;
    %L(i,x,y,z)=[x,y,z of center line of the road]
    L(i,:)=[XB1+x,0,H(x)];
end
% X Y Z Center line of the road
x=L(:,1);
y=L(:,2);
z=L(:,3);
% Υ Ζ Right Borderline
yr=y+(bl/2); 
zr=z+((bl/2)*e);
% Υ Ζ Left Borderline
yl=y-(bl/2);
zl=z-((bl/2)*e);
hold on
%plots center line left borderline and right borderline
plot3(x,y,z)
plot3(x,yl,zl)
plot3(x,yr,zr)

0 Comments

stamatis

stamatis (view profile)

Products

No products are associated with this question.

0 Answers

Contact us