spiegedj – HW4
May 12, 2015 by spiegedj. Filed under
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378
Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379
Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380
Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381
Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382
Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378
Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379
Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380
Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381
Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382
Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378
Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379
Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380
Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381
Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382
Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
cs455, postmortems, spring 2015.
Deprecated: ltrim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/twodee/blog/wp-includes/wp-db.php on line 3030
Deprecated: parse_str(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/class.jetpack.php on line 4255
Deprecated: Creation of dynamic property Jetpack_Carousel::$localize_strings is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/modules/carousel/jetpack-carousel.php on line 339
So I like math things so I decided to start with a Möbius Strip. Luckily, there is a relatively simple parametrization that gives you exactly the coordinates you need for the moveto command!


R = 10
w = 2
for s in -w .. w
for t to 361
x = (R + s * cos ( 0.5 * t)) * cos (t)
y = (R + s * cos ( 0.5 * t)) * sin (t)
z = s * sin ( 0.5 * t)
moveto x, y, z
end
end
surface 361, w * 2 + 1
Next I wanted to do a Klein bottle. This was more challenging because the parametric equation is rather large and you need to be careful how you compute it else it will never finish. A trouble I ran into was that at first my Klein bottle was all twisted up. I was about to give up on it I stumbled upon the solution: StepV needs to twice stepU.


stepU = 5
stepV = 10
for u in 0,stepU..(180)
cu = cos(u)
su = sin(u)
for v in 0,stepV..(360)
cv = cos(v)
sv = sin(v)
x = (-2//15) * cu * (3 * cv - 30 * su + 90 * cu ^ 4 * su - 60 * cu ^ 6 * su + 5 * cu * cv * su)
A = 3 * (cos v) - 3 * cu ^ 2 * cv - 48 * cu ^ 4 * cv + 48 * cu ^ 6 * cv - 60 * su + 5 * cu * cv * su
B = -5 * cu ^ 3 * cv * su - 80 * cu^5 * cv * su + 80 * cu ^ 7 * cv * su
y = (-1//15) * su * (A + B)
z = (2//15) * (3 + 5 * cu * su) * sv
moveto x, y, z
end
end
surface (180 / stepU) + 1, (360 / stepV) + 1
I thing I noticed is that the parenthesis in cos(v) does not do what I would expect. Instead you have to do this: (cos u). This is part of the reason I pulled out the cos and sin evaluations into their own variables.
And finally a “Bagel” Klein just for fun:


r = 3
step = 5
for v in 0, step.. 360
sv = sin(v)
sdv = sin(2 * v)
for t in 0, step..360
cht = cos (t // 2)
sht = sin (t // 2)
ct = cos(t)
st = sin(t)
a = (r + cht * sv - sht * sdv)
x = a * ct
y = a * st
z = sht * sv + cht * sdv
moveto x, y, z
end
end
surface 360 / step + 1, 360 / step + 1