# Viviani's Curve

Hello! How can I plot Viviani's curve in Sage onto cylinder and sphere? My problem is putting sphere into or inside cylinder and then put Viviani's Curve on this.

edit retag close merge delete

Sort by » oldest newest most voted

Here is a full working example that semi-resembles the original example on Wikipedia:

var('u v')

sph_obj = parametric_plot3d(
(sin(u)*cos(v), sin(u)*sin(v), cos(u)),
(v, 0, 2*pi),
(u, 0, 2*pi),
opacity=0.3,
color=(0.2, 0.1, 0.1),
)

cyl_obj = parametric_plot3d(
(sin(v)/2, cos(v)/2 + 1/2, u),
(v, 0, 2*pi),
(u, -3/2, 3/2),
opacity=0.7,
color=(0.2, 0.2, 0.3),
plot_points=(80, 3)
)

v_curve_obj = parametric_plot3d(
(sin(v)*cos(v), sin(v)*sin(v), cos(v)),
(v, 0, 2*pi),
color="green",
thickness=2,
)

(sph_obj + cyl_obj + v_curve_obj).rotateZ(3/2).show(
viewer="tachyon",
aspect_ratio=1,
frame=False,
zoom=1.3
)


more

1

very nice!

( 2011-05-19 09:27:48 -0600 )edit

Huh, I didn't know one could attach images.

( 2011-05-20 14:50:23 -0600 )edit

If you have a parametrization of the curve, then parametric_plot3d will probably be the best way to plot the curve. Spheres and cylinders are easy to plot -- here is one example:

S = sphere((0,1,2),2,opacity=.6)

theta,z=var('theta,z')
C = cylindrical_plot3d(2,(theta,0,4*pi/2),(z,-2,2),opacity=.5,color='red')

(S+C).show(aspect_ratio=1)

more

Thank you for quick answer! But still we have a problem with plotting. We have this equasions: for sphere:

parametric_plot3d((sin(u)*cos(v),sin(u)*sin(v),cos(u)),(v,0,2*pi),(u,0,2*pi))


for cylinder:

parametric_plot3d((sin(v),cos(v),u),(v,0,2*pi),(u,0,2*pi))


and viviani's curve:

parametric_plot3d((sin(v)*cos(v),sin(v)*sin(v),cos(v)),(v,0,2*pi))


and now we don't know how to put it all together. :(

more

1

You can just add them! Notice how Niles does S+C. So literally putting + in between should work.

( 2011-05-19 06:35:21 -0600 )edit

By the way, I recommend that you make your cylinder a lot shorter, like let u go between 0 and 1. Also, if you add the keywords thickness=4 and color='red' to your curve, it will show up better.

( 2011-05-19 06:36:42 -0600 )edit

Finally, your cylinder is too thick! You'll need to have it centered elsewhere to have it line up with the curve. But that's just math, not Sage :)

( 2011-05-19 06:37:35 -0600 )edit