Ask Your Question
1

New Project Looking for Help: Plotting great circles

asked 2010-12-01 04:17:24 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

Hi,

I'm working on a project and found that sage may be the best program to help. Information can be found at vividdynamics.com. I'm not a math student but study it as a hobby(mainly geometry) and have some art backround.

I'm looking for a way to generate a sphere with great circles plotted at cumulatively smaller intervals as they get closer to axis, x and y. Like I said, I'm not a math student so, I'm not sure how to define it in mathematical terms. basically it would look like an orange but with smaller and smaller pieces at, 90º, 180º, 270º, and 0º.


EDIT (niles):

Are you looking for formulas to parametrize these various great circles (so that you can plot them with sage)? If so, maybe rotation matrices are one easy way to produce them. You could start with a great circle whose parametrization you know (e.g. the one in the x-z plane) and then get others by rotating about the z-axis, say 45º, 67.5º, 78.75º, etc. Is that something like what you're looking for?

If so, the Wikipedia article for rotation matrices looks useful. I believe you can plot parametric curves with sage, and apply arbitrary transformation matrices to them. For starters, here's a circle:

sage: u = var('u')
sage: parametric_plot3d( (cos(u), 0, sin(u)), (u, 0, 2*pi))

EDIT (dividenot):

Thanks for the reply. That sounds exactly what I'm looking to do. I must say though, I'm somewhat confused about the ask/answer system here. Initially I was looking for some kind of forum where I could have a discussion or look up any needed information but ask.sagemath.org was the closest thing I could find. Is editing the message like this the best way to have a discussion?

I looked at the Wikipedia article on rotation matrices. I suspect that SAGE doesn't have a command for rotation matrices so I would have to make an array defining my own range. And call the values of each circle from the matrix. Does that sound like a good way to go about it?

edit retag flag offensive close merge delete

3 answers

Sort by » oldest newest most voted
2

answered 2010-12-03 22:10:14 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

I don't know if you can do it using plot3d via a spherical transform, but you can just do a 3 dimensional parametric plot directly providing the transformation as follows:

var('phi')
r = 1
theta = 0
parametric_plot3d((r*cos(theta)*sin(phi), r*sin(theta)*sin(phi), r*cos(phi)), (phi, 0, 2*pi))

Then as above, you can create a function and show many circles

cp = lambda theta: parametric_plot3d((r*cos(theta)*sin(phi), r*sin(theta)*sin(phi), r*cos(phi)), (phi, 0, 2*pi))
many_circles = cp(0) + sum(cp(pi/(2^n)) for n in range(1,7)) + sum(cp(-pi/(2^n)) for n in range(1,7))
many_circles.show()

image description

edit flag offensive delete link more
2

answered 2010-12-01 16:16:00 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

Hi dividenot,

... I must say though, I'm somewhat confused about the ask/answer system here. ... Is editing the message like this the best way to have a discussion?

We're sort of figuring out how this site can be useful as we go -- it's not that old yet. Only people with sufficiently hight karma can edit the wiki question, so in general it's not the best way to go; I did it in this case because my comments didn't really seem like an "answer".

Initially I was looking for some kind of forum where I could have a discussion or look up any needed information but ask.sagemath.org was the closest thing I could find.

There are also the sage-* google groups -- the two most relevant are probably sage-support and sage-devel. They're both very active, and the only down side is that you have to be approved to join the groups; that usually takes less than a day though.


Now on to something more like an answer: Looking at the documentation for 3d graphics, I found that Sage has support for alternate (non-cartesian) coordinate systems; e.g. spherical coordinates -- no rotation matrices needed. To me, the documentation was a little confusing (especially the part where, I think, the words dependent and independent are interchanged!), but eventually I realized that you can plot a "segment" of a sphere simply with:

sage: T = Spherical('radius', ['azimuth', 'inclination'])
sage: var('theta, phi')
sage: plot3d(2, (theta, 0, pi/4), (phi, 0, pi), transformation=T, aspect_ratio=(1,1,1))

spherical section

Now comes the real fun: you can make a very narrow section with, e.g.

sage: plot3d(2, (theta, 0,.01), (phi, 0, 2*pi), transformation=T, aspect_ratio=(1,1,1))

and, even better, define a function which returns the plot starting at theta=t:

sage: cp = lambda t: plot3d(2, (theta, t, t+.01), (phi, 0, 2*pi), transformation=T, aspect_ratio=(1,1,1))

You can draw multiple plots in the same picture by adding, or, if you have a lot of things to add, use summation over a range!

sage: many_circles = cp(0) + sum(cp(pi/(2^n)) for n in range(1,7)) 
sage: many_circles.show()

image description

edit flag offensive delete link more

Comments

You could also use the spherical_plot3d. Also, I opened up a trac ticket to improve the independent/dependent mistakes in the documentation: http://trac.sagemath.org/sage_trac/ticket/10367

Jason Grout gravatar imageJason Grout ( 2010-12-01 22:05:38 -0500 )edit

Just noticed the post a comment button. *feeling kind of silly now*. Thanks alot for the help. I noticed that before evaluating sage: T = Spherical('radius', ['azimuth', 'inclination']) sage: plot3d(2, (theta, 0, pi/4), (phi, 0, 2*pi), transformation=T, aspect_ratio=(1,1,1)) I had to define theta and phi. After that everything worked smoothly. That helps a lot. Thanks again!

dividenot gravatar imagedividenot ( 2010-12-02 01:47:49 -0500 )edit

oh, thanks for catching that -- I've updated the answer now :)

niles gravatar imageniles ( 2010-12-02 02:49:44 -0500 )edit
0

answered 2010-12-04 11:12:37 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

var('phi') 
r = 1
theta = 0

cp = lambda theta: parametric_plot3d((r*cos(theta)*sin(phi), r*sin(theta)*sin(phi),
r*cos(phi)), (phi, 0, pi*2)) + parametric_plot3d((r*sin(theta)*sin(phi), 
r*cos(theta)*sin(phi), r*cos(phi)), (phi, 0, pi*2))

many_circles = cp(0) + sum(cp(pi/(2^n)) for n in range(1,7)) + sum(cp(-pi/(2^n))
for n in range(1,7));
many_circles

I found that I don't have to use .show. This is more like what I've been trying to do:

http://t2nb.math.washington.edu:8000/home/pub/53/

Thanks again for the help

edit flag offensive delete link more

Comments

karma is not awarded for the wiki posts, sorry it's not self evident. I've added 10 points manually to compensate for the damages.

Evgeny gravatar imageEvgeny ( 2010-12-04 12:08:31 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2010-12-01 04:17:24 -0500

Seen: 633 times

Last updated: Dec 04 '10