{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Christmas tree with lights\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n"
],
"text/plain": [
"Graphics3d Object"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"var('t k')\n",
"from sage.plot.plot3d.shapes import *\n",
"num_wraps=4\n",
"num_lights=30\n",
"c=rainbow(num_lights)\n",
"f(t) = ( (1-t)*cos(2*pi*t*num_wraps), (1-t)*sin(2*pi*t*num_wraps),t)\n",
"lights=add([point(f(1/(num_lights)*(k+1)),color=c[k],size=50) for k in range(0,num_lights)])\n",
"S = Cone(1, 1, color='green')\n",
"S += parametric_plot3d(f(t),(t,0,1),thickness=3 )\n",
"S += lights\n",
"S.show()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n"
],
"text/plain": [
"Graphics3d Object"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"S.show(frame=False)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
"S.save('Tree.png',frame=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"jupyter": {
"outputs_hidden": true
}
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "SageMath 9.7",
"language": "sagemath",
"name": "sage-9.7"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}