Snowman

91 views
Skip to first unread message

Iva Polanec

unread,
Jan 14, 2022, 11:37:38 AM1/14/22
to sage-support
Hey!

Does anyone know how to draw a snowman?

Iva

Nils Bruin

unread,
Jan 14, 2022, 12:43:03 PM1/14/22
to sage-support
In a blizzard?

P=sage.plot.graphics.Graphics()
P.show(axes=False)

In general, though, this is not a very mathematical question, nor one for which a computer algebra package is going to be the best tool. Perhaps if you give some more context, someone will be able to give you more useful help.

Iva Polanec

unread,
Jan 14, 2022, 1:41:05 PM1/14/22
to sage-s...@googlegroups.com
Sorry, here is the picture how snowman has to look like..I started drawing with a Sphere, but I can't get it like in the picture. 

Screenshot_20220114_190232.jpg

slelievre

unread,
Jan 14, 2022, 11:58:21 PM1/14/22
to sage-support
2022-01-14, iva:
>
> Does anyone know how to draw a snowman?
> [...] picture how snowman has to look like...
> I started drawing with a Sphere, but I can't get it
> like in the picture.

Hi Iva!  What a nice seasonal project, and a good way
to learn some Sage while making something fun!

For inspiration, see this head with eyeballs and a hat
in Sage's 3D plotting shapes documentation:


Feel free to ask again if you need more help!  --Samuel

Emmanuel Charpentier

unread,
Jan 15, 2022, 3:44:08 AM1/15/22
to sage-support
Homework ?

Kwankyu

unread,
Jan 16, 2022, 9:39:56 PM1/16/22
to sage-support
After blizzard is gone,

from sage.plot.plot3d.shapes import *
P = Graphics()
P += Sphere(.5, color='white')
P += Sphere(1, color='white').translate(0,0,-1.2)
P += Sphere(1.5, color='white').translate(0,0,-2.5)
P += Sphere(.1, color='white').translate(.45,-.1,.15) + Sphere(.05, color='black').translate(.51,-.1,.17)
P += Sphere(.1, color='white').translate(.45, .1,.15) + Sphere(.05, color='black').translate(.51, .1,.17)
P += Cone(.1,.5, color='orange').rotateX(0).rotateY(-pi/2).translate(.3, 0, 0)
P.show()

Exercise: add arms to the snowman.

slelievre

unread,
Jan 19, 2022, 4:27:43 PM1/19/22
to sage-support
2022-01-17 02:39:56 UTC, Kwankyu:

>
> After blizzard is gone,
>
> from sage.plot.plot3d.shapes import *
> P = Graphics()
> P += Sphere(.5, color='white')
> P += Sphere(1, color='white').translate(0,0,-1.2)
> P += Sphere(1.5, color='white').translate(0,0,-2.5)
> P += Sphere(.1, color='white').translate(.45,-.1,.15) + Sphere(.05, color='black').translate(.51,-.1,.17)
> P += Sphere(.1, color='white').translate(.45, .1,.15) + Sphere(.05, color='black').translate(.51, .1,.17)
> P += Cone(.1,.5, color='orange').rotateX(0).rotateY(-pi/2).translate(.3, 0, 0)
> P.show()
>
> Exercise: add arms to the snowman.

Nice one. Here's my snowie (also missing arms).

from sage.plot.plot3d.shapes import Cone, Sphere

r_bot = 3
r_mid = 2.25
r_top = 1.75

z_bot = r_bot
z_mid = z_bot + r_bot + 1/2 * r_mid
z_top = z_mid + r_mid + 1/2 * r_top

# scale factors to shrink spheres along one axis

s_body = 3/4  # vertical scale for body
s_btns = 1/4  # horizontal scale for buttons
s_eyes = 3/4  # horizontal scale for eyes

z_bot_s = s_body * z_bot
z_mid_s = s_body * z_mid
z_top_s = s_body * z_top

nose_length = 3/2*r_top

r_button = 1/4
r_nose = 1/4
r_eye = 1/8

body_color = 'white'
button_color = 'red'
eye_color = 'black'
nose_color = 'orange'

body_bot = sphere((0, 0, z_bot), r_bot, color=body_color)
body_mid = sphere((0, 0, z_mid), r_mid, color=body_color)
body_top = sphere((0, 0, z_top), r_top, color=body_color)
body = (body_bot + body_mid + body_top).scale(1, 1, s_body)

button = Sphere(r_button, color=button_color).scale(s_btns, 1, 1)
button_bot = button.translate(r_bot, 0, z_bot_s)
button_mid = button.translate(r_mid, 0, z_mid_s)
buttons = button_bot + button_mid

eye_angle = pi/10
eye = Sphere(r_eye, color=eye_color).scale(s_eyes, 1, 1)
eye = eye.translate((r_top, 0, z_top_s))
eyes = sum(eye.rotateZ(t) for t in (-eye_angle, eye_angle))

nose = Cone(r_nose, nose_length, color=nose_color)
nose = nose.rotateY(-9/8*pi/2).translate(0, 0, z_top_s)

parts = [body, buttons, eyes, nose]
snowie = sum(parts)
snowie.show(frame=False)

Kwankyu

unread,
Jan 19, 2022, 10:49:23 PM1/19/22
to sage-support
As I wish that the artwork by Samuel Lelièvre is not lost, I posted it here:


if the author permits. If not, let me know.

Samuel Lelièvre

unread,
Jan 20, 2022, 2:57:34 AM1/20/22
to Sage-support
2022-01-20 03:49 UTC, Kwankyu:
>
> As I wish that the artwork by Samuel Lelièvre is not lost, I posted it here:
>
> https://wiki.sagemath.org/art#Snowman
>
> if the author permits. If not, let me know.

Fine with me. You should add your snow person too!
Then they can keep each other company:

sage: snowies = Graphics()
sage: snowies += P.translate(0, 0,
4).scale(2).rotateZ(-pi/5).translate(0, -4, 0)
sage: snowies += snowie.rotateZ(pi/5).translate(0, 3, 0)
sage: snowies.show(frame=False)

Kwankyu

unread,
Jan 20, 2022, 10:08:08 AM1/20/22
to sage-support
On Thursday, January 20, 2022 at 4:57:34 PM UTC+9 slelievre wrote:
Fine with me. You should add your snow person too!
Then they can keep each other company:

It is fun to look at them being together. But their destiny is not eternity. Thanks anyway.  
Reply all
Reply to author
Forward
0 new messages