Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function bezier_quad()
- P = [4 8 16;2 8 4]
- M = [1 -2 1; -2 2 0; 1 0 0]
- B = [ ]
- for t = 0:0.2:1
- T = [t.^2; t; 1]
- C = P * M * T
- B = cat(2, B, C)
- end
- Bx = B(1,:)
- By = B(2,:)
- plot(Bx,By,"-o")
- endfunction
- function bezier_cubic_mat(steps)
- Px = [1 4 8 11]
- Py = [-3 5 -5 3]
- M = [-1 3 -3 1; 3 -6 3 0; -3 3 0 0; 1 0 0 0]
- t = [0:(1/steps):1]
- T = [t.^3; t.^2; t; t.^0]
- Cx = Px*M*T
- Cy = Py*M*T
- disp(Cx)
- disp(Cy)
- plot (Px, Py, "-o")
- plot (Cx, Cy, "-r")
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement