-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrational_bezier_surface_3d.mac
89 lines (62 loc) · 1.7 KB
/
rational_bezier_surface_3d.mac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
https://github.com/t-o-k/Maxima-bezier/rational_bezier_surface_3d.mac
Copyright (c) 2020 Tor Olav Kristensen, http://subcube.com
Use of this source code is governed by the GNU Lesser General Public License version 3, which can be found in the LICENSE file.
*/
kill(all);
load("draw");
load("bezier");
tau: 2*%pi;
angle: tau/4;
w: matrix([ 1, cos(angle/2), 1 ]);
weights: transpose(w).w;
/*
The 9 points; <x, y, z> in the control grid:
< 0, +Rmaj+Rmin, 0> <+Rmaj+Rmin, +Rmaj+Rmin, 0> <+Rmaj+Rmin, 0, 0>
< 0, +Rmaj+Rmin, +Rmin> <+Rmaj+Rmin, +Rmaj+Rmin, +Rmin> <+Rmaj+Rmin, 0, +Rmin>
< 0, +Rmaj , +Rmin> <+Rmaj , +Rmaj , +Rmin> <+Rmaj , 0, +Rmin>
This will create a surface that is 1/16 of the surface of a torus, or 1/8 of the surface of a sphere if Rmaj is 0.
*/
points_x:
matrix(
[ 0, +Rmaj+Rmin, +Rmaj+Rmin ],
[ 0, +Rmaj+Rmin, +Rmaj+Rmin ],
[ 0, +Rmaj , +Rmaj ]
)
;
points_y:
matrix(
[ +Rmaj+Rmin, +Rmaj+Rmin, 0 ],
[ +Rmaj+Rmin, +Rmaj+Rmin, 0 ],
[ +Rmaj , +Rmaj , 0 ]
)
;
points_z:
matrix(
[ 0, 0, 0 ],
[ +Rmin, +Rmin, +Rmin ],
[ +Rmin, +Rmin, +Rmin ]
)
;
define(f_x(u, v), rational_bezier_function_2a(points_x, weights, u, v));
define(f_y(u, v), rational_bezier_function_2a(points_y, weights, u, v));
define(f_z(u, v), rational_bezier_function_2a(points_z, weights, u, v));
Rmaj: 0;
Rmin: 1;
f_x(u, v);
f_y(u, v);
f_z(u, v);
plot3d(
[ f_x(u, v), f_y(u, v), f_z(u, v) ],
[ u, 0, 1 ],
[ v, 0, 1 ],
same_xyz
);+
Rmaj: 2;
Rmin: 1;
plot3d(
[ f_x(u, v), f_y(u, v), f_z(u, v) ],
[ u, 0, 1 ],
[ v, 0, 1 ],
same_xyz
);