Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scilab 0.57 KB | None | 0 0
  1. function bezier_quad()
  2.     P = [4 8 16;2 8 4]
  3.     M = [1 -2 1; -2 2 0; 1 0 0]
  4.     B = [ ]
  5.     for t = 0:0.2:1
  6.         T = [t.^2; t; 1]
  7.         C = P * M * T
  8.         B = cat(2, B, C)
  9.     end
  10.     Bx = B(1,:)
  11.     By = B(2,:)
  12.     plot(Bx,By,"-o")
  13. endfunction
  14.  
  15. function bezier_cubic_mat(steps)
  16.     Px = [1 4 8 11]
  17.     Py = [-3 5 -5 3]
  18.     M = [-1 3 -3 1; 3 -6 3 0; -3 3 0 0; 1 0 0 0]
  19.     t = [0:(1/steps):1]
  20.     T = [t.^3; t.^2; t; t.^0]
  21.     Cx = Px*M*T
  22.     Cy = Py*M*T
  23.     disp(Cx)
  24.     disp(Cy)
  25.    
  26.     plot (Px, Py, "-o")
  27.     plot (Cx, Cy, "-r")
  28. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement