Author |
Message |
Satisfaction
|
Posted: Fri May 09, 2008 8:17 pm Post subject: Turing Make an object move in a circular motion |
|
|
I'm trying to make a solar system but im having trouble making the planets move in a circular motion... Please someone help me... |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
CodeMonkey2000
|
Posted: Fri May 09, 2008 8:23 pm Post subject: RE:Turing Make an object move in a circular motion |
|
|
Well, do you know the universal gravitation and forces equation equations? |
|
|
|
|
 |
Satisfaction
|
Posted: Fri May 09, 2008 8:42 pm Post subject: RE:Turing Make an object move in a circular motion |
|
|
Sadly no |
|
|
|
|
 |
CodeMonkey2000
|
|
|
|
 |
Satisfaction
|
Posted: Fri May 09, 2008 10:52 pm Post subject: RE:Turing Make an object move in a circular motion |
|
|
Can this help me with making a oval/circle move in circular motion? o.o It's so complex.. |
|
|
|
|
 |
CodeMonkey2000
|
Posted: Sat May 10, 2008 1:37 am Post subject: RE:Turing Make an object move in a circular motion |
|
|
If you want constant circular motion, it's a lot more simple. The basic formula is y=r* sind (angle)+yOfWhatYouAreOrbiting and x= r* cosd(angle)+ xOfWhatYouAreOrbiting, r is the constant radius. To move the object, just increase the angle. Elliptical motion is a bit different though, you'll need to play around with the circular motion a bit. Although this isn't really planetary motion. |
|
|
|
|
 |
isaiahk9

|
Posted: Sat May 10, 2008 7:07 am Post subject: RE:Turing Make an object move in a circular motion |
|
|
CAn you not use Pic.Rotate, and have your picture have a bit of a axel farther out, like this :
o X
o is your axel, and x is your picture. If you rotate that, it will appear that x is moving in a circle. |
|
|
|
|
 |
[Gandalf]

|
Posted: Sat May 10, 2008 3:07 pm Post subject: RE:Turing Make an object move in a circular motion |
|
|
You could, but you'll be limited to that exact circular motion unless you change the original image. Also, you'll need an increasingly large image the larger you want your radius to be. With something a little more complicated, as CodeMonkey2000 describes, you get a faster and more flexible program. |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
CodeMonkey2000
|
Posted: Sat May 10, 2008 8:06 pm Post subject: RE:Turing Make an object move in a circular motion |
|
|
Plus isaiahk9's method will be much slower, since you keep generating and freeing images for each cycle. Pic.Rotate actually allocates memory for the newly generated rotation. |
|
|
|
|
 |
Satisfaction
|
Posted: Sat May 10, 2008 8:07 pm Post subject: RE:Turing Make an object move in a circular motion |
|
|
Any of you guys wanna help me do that? I'm so confused lol. I just want to make a solar system using pictures and make it move for my assumptive o.o |
|
|
|
|
 |
isaiahk9

|
Posted: Sat May 10, 2008 8:11 pm Post subject: RE:Turing Make an object move in a circular motion |
|
|
About memory for each picture, Codemonkey2000, wouldn't Pic.Free fix that. And wouldn't setscreen("offscreenonly") and View.Update make it just as fast?
To Satisfaction, if CodeMonkey2000 says that my way is less effective, I wouldn't doubt him. It would probably be best for him to explain his way. I've always used Pic.Rotate in the past through. lol |
|
|
|
|
 |
Tony

|
Posted: Sat May 10, 2008 9:16 pm Post subject: RE:Turing Make an object move in a circular motion |
|
|
@isaiahk9 -- There's certainly something wrong if saving current screen as an image, editing that image, saving it as a new instance in the memory, and loading that image onto screen... if all that takes about the same time as adding two vectors (velocity + acceleration) to a 2D position.
The only thing Pic.Free does is that it prevents your program from running out of picture identifiers and crashing runtime. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
CodeMonkey2000
|
Posted: Sat May 10, 2008 9:39 pm Post subject: Re: Turing Make an object move in a circular motion |
|
|
Well, Satisfaction doesn't seem to have the physics background for this, so I'm going explain basic circular motion. With circular motion you have a the object that is moving, and a focal point at the center. Now the distance from the focal point to the object is always constant, that's why we call it a radius. Now we can express the coordinates of the object as x and y, or we can express it using trig (I hope you know trigonometry... ). Consider this figure.
Px and Py is known, and stays constant. That's the point we orbit around. x and y is the coordinate of our object, or planet. To get x and y we need to add a to Px to get x and add b to Py to get y. r is constant, that's the radius. To get a we do r*cosd theta and to get b we do r*sind theta. Theta will vary from 0 to 360 degrees. Using this we see that
code: |
x=Px+r*cosd theta
y=Py+r*sind theta
|
Now we just vary theta and keep calculating the new coordinate (then drawing it of course). |
|
|
|
|
 |
|