Brief introduction of ruled surface and matlab program realization

1. The definition of ruled surface

        A ruled surface is a special kind of curved surface, which can be "woven" by a family of straight lines, that is, a straight line passing through every point on the curve falls on the curved surface.
        The ruled surface is widely used in geometric modeling . A ruled surface is a trajectory formed by a straight line moving along a certain curve in space. The fixed curve is called a guideline, and the straight line is called a generatrix. As shown below:
Insert picture description here

        Let the guideline be h (u) h(u)h ( u ) ,the direction vector of thebusisl (u) l(u)l ( u ) ,the equation of the ruled surface is:
       
P (u, v) = h (u) + vh (u), P(u,v) = h(u) + vh(u),P(u,v )=h(u)+vh(u),
其中, u ∈ [ u 0 , u 1 ] , v ∈ [ v 0 , v 1 ] . u\in[u_0,u_1],v\in[v_0,v_1]. u[ u0,u1],v[ v0,v1].

       In practical applications, the ruled surface can also be expressed as
       
P (u, v) = (1 − v) a (u) + vb (u), P(u,v) = (1-v)a(u) + vb(u),P(u,v )=(1v)a(u)+vb(u),
其中, u ∈ [ u 0 , u 1 ] , v ∈ [ 0 , 1 ] . u\in[u_0,u_1],v\in[0,1]. u[ u0,u1],v[0,1 ] . Curved curvea (u), b (u) a (u), b (u)a(u),b ( u ) is the ruled surface wherev = 0, 1 v = 0,1v=0,Two boundary curves at 1 o'clock
       
       

Insert picture description here

       
       
       

2. Matlab program:

function Ruled_surface
% 直纹面编程示例:
% 直纹面方程:p(u,v) = (1-u)*a(v) + u*b(v) ; 
% 其中a(v),b(v)程序中分别取了两个bezier曲线
clear;
clc;
[U,V] = meshgrid(0:0.02:1,0:0.02:1);
%第一条bezier曲线  a(v)
rx=[0,1,2,3,4,7];
ry=[0,0,-3,5,6,6];                         %控制顶点(0,0),(1,0),(2,-3),...
M = 40;
hx = 1/M;                                    %将[0,1]区间M等分
x = V;
n=length(rx)-1;
Rx = 0;
Ry = 0;
for i = 1:n+1
    Rx = Rx + rx(i)*B(x,n,i-1) ;       %将控制顶点与Bernstein基函数相乘得到bezier曲线
    Ry = Ry + ry(i)*B(x,n,i-1) ;
end
figure(1)
plot(Rx,Ry,'r')                             %bezier曲线a(v)

%第二条bezier曲线  b(v)
px=[0,1,2,3,4,6];
py=[0,2,15,5,6,6];                       %控制顶点(0,0),(1,2),....
M = 40;
hx = 1/M;                                    %将[0,1]区间M等分
x = V;
n=length(px)-1;
PX = 0;
PY = 0;
for i = 1:n+1
    PX = PX + px(i)*B(x,n,i-1) ;       %将控制顶点与Bernstein基函数相乘得到bezier曲线
    PY = PY + py(i)*B(x,n,i-1) ;
end
figure(2)
plot(PX,PY,'b')                              %bezier曲线b(v)

%将两条边界bezier曲线带入直纹面方程
X = (1-U).*Rx + U.*PX;
Y = (1-U).*Ry + U.*PY ;
Z = (1-U).*2 + U.*(33) ;
%两种方式画图
figure(3)
surf(U,V,Y)
figure(5)
surf(X,Y,Z)
figure(4)
mesh(X,Y,Z)
end
%  第i个bernstein基函数
function y = B(x,n,i)
y = N(n,i).*(x.^i).*((1-x).^(n-i));
end
% 组合数  Number of combinations
function y = N(n,i)
y1 = factorial(n);            %n的阶乘
y2 = factorial(i)*factorial(n-i);
y = y1/y2;
end

It can be run directly on matlab.

              
       

3. Image

1. The first boundary bezier curve:
Insert picture description here
      
        
2. The second boundary bezier curve:

Insert picture description here

       
3. The final ruled surface
Insert picture description here

Insert picture description here

Guess you like

Origin blog.csdn.net/mw_1422102031/article/details/108904455