Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


[SOLVED] Objects orbiting speed is bound to its distance from source


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Sollum   GDNet+   -  Reputation: 759

Like
0Likes
Like

Posted 26 July 2013 - 02:10 PM

Good evening,

 

I've got stuck on simple math issue, which i don't know how to solve. Problem is with object rotation around another object (orbiting). Speed of rotation differs depending on distance from source.

        public boolean tryToFinishRotate()
	{
		boolean success = false;
		
		if (Parent != null)
		{
			float an = RotationAngle.get();
			an += RotationPerCycle.get();
			RotationAngle.set(an);
			
			float d = Distance.get();
			
			an = (float) Math.toRadians(an);
			
			float xp = Parent.PlacementPoint.getD1();
			float yp = Parent.PlacementPoint.getD2();
			float zp = Parent.PlacementPoint.getD3();
			float ap = Parent.PlacementPoint.getD4();
			
			float vx = (float) (Math.cos(an) - Math.sin(an));
			float vy = (float) (Math.sin(an) + Math.cos(an));
			
			xp += vx * d;
			yp += vy * d;
			
			PlacementPoint.set(xp, yp, zp, ap);
		}
		else 
		{
			success = true;
		}
		
		return success;
	}

Issue is, that both VX and VY are sort of direction vector, and by doing

X += VX * D (distance)

Y += VY * D (distance)

I am simply multiplying vector, which sort of binds orbiting speed to distance.

 

What i need to do is to adjust rotation angle, depending on distance from the source, but i am kinda out of ideas at this point :|

 

Anyone could give me some guidance?


Edited by Sollum, 28 July 2013 - 05:25 AM.


Sponsor:

#2 Bacterius   Crossbones+   -  Reputation: 9262

Like
0Likes
Like

Posted 26 July 2013 - 07:16 PM

Could you give some more information, like:

1. what are you trying to model here

2. why do you use a position/velocity approach to move your object, do you need a dynamical system or is a static, "on rails" orbiting motion fine

 

I'm asking because in real life, orbiting speed around a gravitational body is, in fact, bound to distance (at least in a circular orbit), and you may not be aware of this. Secondly, if you need a dynamical system, surely a position/velocity/acceleration approach would be much more flexible, otherwise you could just calculate the object's position on its orbit directly as a function of time and not have to worry about velocity at all.

 

So it's not clear what you are trying to do here, and giving us some more information about what you are looking for at a higher level will help us help you (and give more specific answers) smile.png


The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#3 DT....   Members   -  Reputation: 487

Like
1Likes
Like

Posted 26 July 2013 - 10:32 PM


What i need to do is to adjust rotation angle, depending on distance from the source, but i am kinda out of ideas at this point :|
 
Anyone could give me some guidance?

 

 

 

http://math.tutorvista.com/geometry/arc-length-formula.html

http://www.regentsprep.org/Regents/math/algtrig/ATM1/arclengthlesson.htm



#4 Sollum   GDNet+   -  Reputation: 759

Like
0Likes
Like

Posted 27 July 2013 - 02:52 AM

Could you give some more information, like:

1. what are you trying to model here

2. why do you use a position/velocity approach to move your object, do you need a dynamical system or is a static, "on rails" orbiting motion fine

 

I'm asking because in real life, orbiting speed around a gravitational body is, in fact, bound to distance (at least in a circular orbit), and you may not be aware of this. Secondly, if you need a dynamical system, surely a position/velocity/acceleration approach would be much more flexible, otherwise you could just calculate the object's position on its orbit directly as a function of time and not have to worry about velocity at all.

 

So it's not clear what you are trying to do here, and giving us some more information about what you are looking for at a higher level will help us help you (and give more specific answers) smile.png

 

1) I am trying to model proper rotation of objects around other objects

2) Frankly, no idea what should be used to achieve my goal

 

There are two sets of rules to object movement:

Distancing away

Rotation

 

My goal is to move sphere for same lenght on different distances from source.

 

Edit: I've made a picture of what i want to achieve

exp.png

al1 - traveling distance of o2 (object 2) should always be the same, whilst distance changes from d1 to d2

o2 rotates around o1


Edited by Sollum, 27 July 2013 - 03:56 AM.


#5 Sollum   GDNet+   -  Reputation: 759

Like
0Likes
Like

Posted 28 July 2013 - 05:24 AM

After turning ON my brain and reading a bit about arc lenght, i think i've done it, but i am not entirely sure i have done it right.

        public boolean tryToFinishRotate()
	{
		boolean success = false;
		
		if (Parent != null)
		{
			float d = Distance.get();
			
			float an = RotationAngle.get();
			if (d > 0)
				an += (float) (RotationPerCycle.get() / d);
			RotationAngle.set(an);
			
			float xp = Parent.PlacementPoint.getD1();
			float yp = Parent.PlacementPoint.getD2();
			float zp = Parent.PlacementPoint.getD3();
			float ap = Parent.PlacementPoint.getD4();
			
			float vx = (float) (Math.cos(an) - Math.sin(an));
			float vy = (float) (Math.sin(an) + Math.cos(an));
			
			//System.out.println(vx + " " + vy);
			
			xp += vx * d;
			yp += vy * d;
			
			PlacementPoint.set(xp, yp, zp, ap);
		}
		else 
		{
			success = true;
		}
		
		return success;
	}

RotationPerCycle has a different meaning now tho. Now its more like "Distance traveled per cycle".






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS