Here is an example

57 views
Skip to first unread message

HG

unread,
Jul 10, 2017, 5:49:50 AM7/10/17
to sage-support
Hi,
This is a mathematica example, but I am not able to do something ressembling this yin yang grid a challenger ?
https://github.com/aishenri/sage/blob/master/gridyy.pdf
the cdf and noteboob are on the same dir.
As sagemath seems to be an alternative would be great ?
Regards
Henri

Nils Bruin

unread,
Jul 10, 2017, 8:04:27 AM7/10/17
to sage-support
sage has parametric_plot3d. If you read its documentation you can probably figure out how to accomplish the same result that you get from mathematica.

Henri Girard

unread,
Jul 10, 2017, 8:27:10 AM7/10/17
to sage-s...@googlegroups.com

thanks but I am trying already for a long time... I think that even sagemanifolds is very near capacity of doing it but I am not good to make it !

I don't understand the f[switch_] ;= Module .... part

--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
To post to this group, send email to sage-s...@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Nils Bruin

unread,
Jul 10, 2017, 10:11:08 AM7/10/17
to sage-support
On Monday, July 10, 2017 at 2:27:10 PM UTC+2, HG wrote:

thanks but I am trying already for a long time... I think that even sagemanifolds is very near capacity of doing it but I am not good to make it !

I don't understand the f[switch_] ;= Module .... part

That question might be more suitable for a mathematica forum. It looks to me that this is just

def f(switch):
  if switch=="yin":
    coords = ...
  else:
    coords = ...
  ....
  return (surfaceRad, surfaceTht, surfacePhi)

Nils Bruin

unread,
Jul 11, 2017, 8:16:09 AM7/11/17
to sage-support
On Monday, July 10, 2017 at 11:49:50 AM UTC+2, HG wrote:

You could probably clean up the code a bit, but I think the sage construction is more straightforward:


var("r,theta,phi");
def coordfunc(r,theta,phi,switch,shift=0):
    if switch=="yin":
        return (r*sin(theta)*cos(phi)+shift,r*sin(theta)*sin(phi),r*cos(theta))
    else:
        return (-r*sin(theta)*cos(phi)+shift,r*cos(theta),r*sin(theta)*sin(phi))
       
yin=(parametric_plot3d(coordfunc(1,theta,phi,"yin",1),(theta,pi/4,3*pi/4),(phi,-3*pi/4,3*pi/4))+
  parametric_plot3d(coordfunc(0.6,theta,phi,"yin",1),(theta,pi/4,3*pi/4),(phi,-3*pi/4,3*pi/4),color="yellow")+
   parametric_plot3d(coordfunc(r,theta,-3*pi/4,"yin",1),(r,0.6,1),(theta,pi/4,3*pi/4))+
   parametric_plot3d(coordfunc(r,theta,3*pi/4,"yin",1),(r,0.6,1),(theta,pi/4,3*pi/4))+
   parametric_plot3d(coordfunc(r,pi/4,phi,"yin",1),(r,0.6,1),(phi,-3*pi/4,3*pi/4))+
   parametric_plot3d(coordfunc(r,3*pi/4,phi,"yin",1),(r,0.6,1),(phi,-3*pi/4,3*pi/4))
  )
yang=(parametric_plot3d(coordfunc(1,theta,phi,"yang",-1),(theta,pi/4,3*pi/4),(phi,-3*pi/4,3*pi/4))+
  parametric_plot3d(coordfunc(0.6,theta,phi,"yang",-1),(theta,pi/4,3*pi/4),(phi,-3*pi/4,3*pi/4),color="yellow")+
   parametric_plot3d(coordfunc(r,theta,-3*pi/4,"yang",-1),(r,0.6,1),(theta,pi/4,3*pi/4))+
   parametric_plot3d(coordfunc(r,theta,3*pi/4,"yang",-1),(r,0.6,1),(theta,pi/4,3*pi/4))+
   parametric_plot3d(coordfunc(r,pi/4,phi,"yang",-1),(r,0.6,1),(phi,-3*pi/4,3*pi/4))+
   parametric_plot3d(coordfunc(r,3*pi/4,phi,"yang",-1),(r,0.6,1),(phi,-3*pi/4,3*pi/4))
  )
(yin+yang).show(viewer="threejs")

Henri Girard

unread,
Jul 11, 2017, 10:37:21 AM7/11/17
to sage-s...@googlegroups.com

Thanks a lot I needed this trame to maybe go further !

At least I know now it's possible to do it

Best regards

Henri

Eric Gourgoulhon

unread,
Jul 11, 2017, 2:02:56 PM7/11/17
to sage-support
Nice answer Nils!

Henri Girard

unread,
Jul 11, 2017, 3:54:51 PM7/11/17
to sage-s...@googlegroups.com

True !

And thanks for your help :)


Le 11/07/2017 à 20:02, Eric Gourgoulhon a écrit :
Nice answer Nils!
sageyytest.ipynb
Reply all
Reply to author
Forward
0 new messages