# SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.

Home / forum / Animation / Mel Scripts & Programming / make the moon revolve around the earth
 Register FAQ Members List Calendar Mark Forums Read

 04-10-2003, 09:17 PM #1 nspiratn Registered User     Join Date: Dec 2002 Location: CA Posts: 211 Thanks: 0 Thanked 0 Times in 0 Posts make the moon revolve around the earth Hi, I'm trying to write a basic script to make 1)the earth revolve around the sun 2)the moon revolve around the earth At this point, I have both the earth and the moon revolving around the sun. This is the script - --------------------- sphere; select -r nurbsSphere1 ; addAttr -ln distance -at double -min 1 -max 10 -dv 8 |nurbsSphere1; setAttr -e -keyable true |nurbsSphere1.distance; expression -n "xexp" -s "nurbsSphere1.tx = nurbsSphere1.distance * sin(time)"; expression -n "yexp" -s "nurbsSphere1.ty = nurbsSphere1.distance * cos(time)"; sphere -r 0.25 ; select -r nurbsSphere2 ; addAttr -ln distance -at double -min 1 -max 10 -dv 10 |nurbsSphere2; setAttr -e -keyable true |nurbsSphere2.distance; expression -n "xexp" -s "nurbsSphere2.tx = nurbsSphere2.distance * sin(time)"; expression -n "yexp" -s "nurbsSphere2.ty = nurbsSphere2.distance * cos(time)"; sphere -r 3; playbackOptions -min 1 -max 300 ; ---------------------------------- The problem I have is : The moon's x and y co-ordinates have to change to keep up with the earth's orbit around the sun. BUT, the moon's x, y co-ordinates ALSO have to change locally with respect the earth itself so it can remain in orbit around the earth. So, how do I animate the moon so that it can do both?? I hope you're getting my drift here. btw, I have a gut feeling that there is a very simple solution to this but I am just blanking out. thanks. Attached Thumbnails   __________________ ~nspiratn
 04-10-2003, 09:47 PM #2 kbrown Moderator     Join Date: Sep 2002 Location: London, UK Posts: 3,198 Thanks: 0 Thanked 8 Times in 8 Posts You need to think of this how would you do it manually. Perhaps by setting the earth's pivot in the middle of the sun and the moon's pivot in the middle of the earth. Then parent the moon to the earth and create the necessary expressions to rotate everything. __________________ Kari - My Website - My IMDB Do a lot, Fail a lot and Learn a lot!
04-10-2003, 09:58 PM   #3
kbrown
Moderator

Join Date: Sep 2002
Location: London, UK
Posts: 3,198
Thanks: 0
Thanked 8 Times in 8 Posts

here's a quick (maya 4.5) scene file for you to investigate:
Attached Files
 earrh_moon_sun.zip (6.4 KB, 49 views)
__________________
Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!

 04-10-2003, 09:58 PM #4 mtmckinley The Maya Mountain     Join Date: Aug 2002 Location: Seattle, WA Posts: 8,245 Thanks: 1 Thanked 25 Times in 25 Posts I agree. __________________ -Mike www.mtmckinley.net The Maya Toolbelt
 13-10-2003, 11:53 PM #5 mark_wilkins Registered User     Join Date: Jan 2003 Posts: 161 Thanks: 0 Thanked 1 Time in 1 Post Why not just parent the objects to each other and rotate the transform? Making additional transforms by grouping can allow you to decouple an object's rotation from its orbital motion (although in real life, rotation to orbit duration ratios of 1:1, 2:1, and 3:1 are common, and 1:1 is what you get with straight parenting... the others can be done with a simple expression.) -- Mark __________________ Mark R. Wilkins author of MEL Scripting for Maya Animators www.melscripting.com

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is Off

## \$34

Month-to-month billing

## \$87

Billing every 3 months
 \$29/month Unlimited access to all videos Project files to download Easy to cancel at anytime Save \$5 per month or \$15 in total compared to monthly billing with this package.

## \$288

Billing every 12 months
 \$24/month Unlimited access to all videos Project files to download Easy to cancel at anytime Save \$10 per month or \$120 in total compared to monthly billing with this package.

Your plan will automatically renew. You can cancel at any time via your PayPal account to avoid being charged again.

You can view the FAQ on our video plans here. You can contact us directly here. By clicking one of the buttons above, you agree to our Terms and Privacy Policy.