Professional Documents
Culture Documents
Grasshopper
Rhino Script GH Robert McNeel
& Associates Grasshopper
script
wahlim.bryan.shih@gmail.com
Bryan Shih
GSAPP Columbia University
Aug 21st 2011
ii
3D
NURBS
NURBS
Robert McNeel and Associates Greg Arden
Robert McNeel and Associates
Margaret Becker
University of Texas at Arlington2010 2 Tex-Fab event
Rajaa Issa
Robert McNeel & Associates
iii
1 ....................................................................................................................................................1
.................................................................................................................................................... 1
.................................................................................................................................................... 3
............................................................................................................................................. 13
............................................................................................................................................. 14
2 ............................................................................................................................................. 16
......................................................................................................................................................... 16
......................................................................................................................................................... 16
......................................................................................................................................................... 17
3 ...................................................................................................................................... 22
......................................................................................................................................................... 22
...................................................................................................................................... 22
............................................................................................................................................. 25
......................................................................................................................................................... 26
........................................................................................................................... 28
NURBS .......................................................................................................................................... 31
NURBS ............................................................................................................................... 33
NURBS .......................................................................................................................................... 36
NURBS ............................................................................................................................... 37
................................................................................................................................................. 39
.............................................................................................................................. 42
..................................................................................................................... 43
iv
v = <a1, a2>
anchor points
X 5.18
v = <5.18, 0, 0>
P0 (0,0,0) v = <a1,a2,a3>
P0 P1
P0 = (0,0,0)
P1 = (a1,a2,a3)
v= < a1, a2, a3 >(0,0,0)
(a1, a2, a3)
Grasshopper P1
a b a+b
Grasshopper a b
a+b
Grasshopper :
5
GH vector addition
1
Grasshopper
Grasshopper vector L
9
GH vector
10
ab c s t :
1. a + b = b + a
2. a +0= a
3. s(a+b)= sa +sb
4. st(a)= s(ta)
5. a+(b + c)=(a+b)+ c
6. a + (-a)=0
7. (s + t)a = sa + ta
8. 1* a = a
11
12
GH vector dot product
-1 +1
a.a =|a|2
a.a =a12+a22+a32
a.a = |a|2
Grasshopper
13
a.b =|a||b|cos(),
cos()= a.b / (|a||b|)
a b
cos()= a.b
ABC
|AB|2 = |CA|2 + |CB|2 -2|CA||CB|cos()
:
|a-b|2 = |a|2 + |b|2 -2|a||b|cos() ---(1)
|AB|2 |a-b|2
|a-b|2 =(a-b).(a-b)
= a.a -a.b -b.a + b.b
=|a|2 -2a.b +|b|2 ---(2)
(1) (2)
|a|2 -2a.b +|b|2
= |a|2 + |b|2 -2|a||b|cos()
2a.b = 2|a||b|cos()
:
cos()= a.b / (|a||b|)
a.b = 0 a b
Grasshopper x
v v x
14
ab c s :
1. a . a =| a |2
2. a .(b + c)= a . b + a . c
3. 0. a =0
4. a . b = b . a
5. (sa). b = s(a . b)= a .(sb)
15
16
GH cross product
a x b a b
a b
|a x b| = |a||b|sin()
a b
a b
|a x b| = sin()
10
GH cross product
17
GH
a = <1, 0, 0>
b = <0, 1, 0>
a x b = <0, 0, 1>
b x a = <0, 0, -1>
Rhino a X b a=b=
=
11
a x b = 0 a b
ab c s :
1. a X b = -b X a
2. (sa) X b = s(a X b) = a X (sb)
3. a X (b + c) = a X b + a X c
4. (a + b) X c = a X c + b X c
5. a . (b X c) = (a X b) . c
6. a X (b X c) = (a . c)b (a . b)c
1-
2-
3- 4-
Grasshopper
0 0
18
12
:
L =
v =
P0 =
r = r0 + a --- (1)
a = t * v --- (2)
12
r = r0 + t*v --- (3)
3
<x,y,z> = <x0,y0,z0> + <ta, tb, tc>
<x,y,z> = <x0+ta, y0+tb, z0+tc>
x = x0 + ta
y = y0 + tb
z = z0 + tc
P = P0 + tv
Grasshopper
19
13
P0P1P
aP0
bP1
vP0P1
a + v = b,
v=b-a
P = P0 + t*vt=0.5v=b-a
P = P0 + 0.5(b-a)
Grasshopper
20
t01P0P1
14
P0(x0,y0,z0 ) =
r0<x0,y0,z0> =P0
n<a,b,c>
=
P(x,y,z)
=
r<x,y,z>
=P
0
n.(r - r0) =0
Grasshopper
21
15
mn
m:
n :
M
dim(M) = [2,3]
16
1.
dim(M1)=[axb], dim( M2)=[cxd], bc
2.
1,1
3.2
3,2
P' = P + V
P(x,y,z)
v<a,b,c>
P'(x) = x + a
P'(y) = y + b
P'(z) = z + c
14x1
17
P(2,3,1)v<2,2,2>
P= P + v = (2+2, 3+2, 1+2) = (4, 5, 3)
P(x,y)x,yb
x = d cos(a)
---(1)
y = d sin(a)
---(2)
x' = d cos(b+a) ---(3)
y' = d sin(b+a) --- (4)
3
4
x' = d cos(a)cos(b) - d sin(a)sin(b) ---(5)
y' = d cos(a)sin(b) + d sin(a)cos(b) ---(6)
1
2
x' = x cos(b) - y sin(b)
y' = x sin(b) + y cos(b)
1 z :
x b :
y b :
1 http://zh.wikipedia.org/zh-cn/%E9%BD%90%E6%AC%A1%E5%9D%90%E6%A0%87
18
Grasshopper
22
P' = (S) * P
:
P'.x = Sx * P.x
P'.y = Sy * P.y
P'.z = Sz * P.z
19
z
xy
xzy
yzx
xyz
GH
23
20
P(x,y,z) xy
Pxy(x,y,0), P xz Pxz(x,0,z) yz Pxz = (0,y,z)
2
,
xy NURBS
2 http://en.wikipedia.org/wiki/Projection_(linear_algebra)
21
t 3
0 1
x2 + y2 = r2
t
x = r cos(t)
y = r sin(t)
x/r = cos(t)
y/r = sin(t)
cos(t)2 + sin(t)2 = 1
(x/r)2 + (y/r)2 = 1, or x2 + y2 = r2
Hermite4 Bzier5
Hermite Bzier
3 http://en.wikipedia.org/wiki/Parametric_equation
4 http://en.wikipedia.org/wiki/Cubic_Hermite_spline
5 http://en.wikipedia.org/wiki/B%C3%A9zier_curve
22
10 Bezier
Hermite Bzier 4
Non
Uniform Rational B-Spline6 (NURBS)
6 http://en.wikipedia.org/wiki/Non-uniform_rational_B-spline
23
24
G0
G1
G2
GN
abcd
GH scriptP
A=
L=
24
25
ABG0
ACG1
ADG2G1
G0G1G2
26
A
B :
C0
0
0
0
CMC
0 CMC
27
BzierDe Casteljau7
De CasteljauPaul De CasteljauBzier
GrasshopperDe Casteljaut
A, B, C, D
t0-1
ABtM
BCtN
CDtO
MNtP
NOtQ
PQtR
25
GH Bzier
7De Casteljauhttp://en.wikipedia.org/wiki/De_Casteljau%27s_algorithm
28
26
De Casteljau Bzier
NURBSDe Boor8
De BoorBzierDe Casteljau
NURBSDe Boor9NURBS
7P0P6
u0 = 0.0
u1 = 0.0
u2 = 0.0
u3= 0.25
u4 = 0.5
u5 = 0.75
u6 = 1.0
u7 = 1.0
u8 = 1.0
u=0.4
8De Boorhttp://en.wikipedia.org/wiki/De_Boor's_algorithm
9
http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/de-Boor.html
29
1.
Ac = (u u1) / ( u1+3 u1) = 0.8
Bc = (u u2) / ( u2+3 u2) = 0.53
Cc = (u u3) / ( u3+3 u3) = 0.2
2.
A = 0.2P1 + 0.8P2
B = 0.47 P2 + 0.53 P3
C = 0.8 P3 + 0.2 P4
3.
Dc = (u u2) / (u2+3-1 u2) = 0.8
Ec = (u u3) / (u3+3-1 u3) = 0.3
4.
D = 0.2A+ 0.8B
E = 0.7B + 0.3C
5.
Fc = (u u3)/ (u3+3-2 u3) = 0.6
6. u=0.4
F= 0.4D + 0.6E
Grasshopper De Boor NURBS u=0.4
27
De Boor
30
NURBS
NURBS
(http://en.wikipedia.org/wiki/NURBS)NURBS
NURBS
NURBS
Rhino 1 5
5
1NURBS
=2=+1
2NURBS
=3
3 NURBS
=4
NURBS +1NURBS
Grasshopper
31
NURBS3D
SDKSoftware Development Kit
-1
1.
2.
32
=3
=7
=(0,0,0,1,2,3,5,5,5)
=3
=7
=(0,0,0,1,1,1,4,4,4)
:
SDK
(m_t(0))
(m_t(1))
NURBS
NURBS
3
+1
NURBS
33
34
vs NURBS
NURBS
28
NURBS
29
NURBS
4+
35
30
2 NURBS
NURBS 1 NURBS
Grasshopper
31
NURBS
NURBS
NURBS NURBS
NURBS u v
36
32
NURBS
NURBS NURBS
NURBS
33
NURBS
NURBS
NURBS
NURBS NURBS NURBS
3
u v +1
u v
NURBS NURBS
NURBS
37
u v 1
u 3 v 1
u 3 v 1
38
u 3 v 1
NURBS
uv
brep
brep
brep
34
NURBS
39
35
NURBS
NURBS
NURBS
40
41
42
2D coordinate system
multiple transformations
3D coordinate system
non- rational
affine transformations
normal curvature
anchor point
NURBS curves
NURBS
average direction
NURBS surfaces
NURBS
Bzier curve
Bzier
order
orthogonal
parametric curves
parametric surfaces
coefficient
column
polyline
component
polysurfaces
position vector
contral point
principal curvatures
control point
projection
rational
curvature
real number
curve seam
reciprocal
De Boor algorithm
De Boor
recursive method
De Casteljau algorithm
De Casteljau
right-handed system
degree
rotation
determinant
row
dimension
scalar
full-multiplicity knot
scale
Gaussian curvature
shear
geometric continuity
simple knot
Hermite curve
Hermite
solid
homogenous coordinate
tangent line
iteration
tangent vector
kink
translation
knot
knot multiplicity
unit vector
knot vector
line-segment
matrices
vector length
matrix multiplication
vector mathematics
mean curvature
vector operations
minimal surface
weights
43