### Author Topic: Rotation  (Read 3930 times)

0 Members and 1 Guest are viewing this topic.

#### Pilchard123

• Tester
• Old Oak
• Thank You
• -Given: 0
• Posts: 899
• Eufloria: Yes
##### Re: Rotation
« Reply #45 on: May 21, 2011, 02:16:10 PM »
You always get the smallest angle. Just reverse the comparison signs and remove the break...else section. I don't know why I didn't say that before. Derp.

#### Aino

• Ent
• Thank You
• -Given: 1
• Posts: 1,483
• They'll eat you next!
• Eufloria: Yes
##### Re: Rotation
« Reply #46 on: July 25, 2011, 06:46:10 PM »
New question (yay!), which obviously is about rotation!

So the case is this:

The arrow shows the velocity, obviously that is ok and fine knowledge and simple to handle. But one/two more arrows, pointing theese ways:

Gives a challenge, or finding the values... Lets say you got the values you got there, then want to do this:

How the hell do you do that?

And please, no complicated stuff, I'm a bit tired of having to read the code 100 times to understand it(literally!). And if it is so complicated, please explain D:
(I also hope I explained myself very clearly this time, and hope for no question regarding my question about this little thing

#### Pilchard123

• Tester
• Old Oak
• Thank You
• -Given: 0
• Posts: 899
• Eufloria: Yes
##### Re: Rotation
« Reply #47 on: July 25, 2011, 07:53:13 PM »
So you want to turn the velocity 5 degrees to the left, so it is moving in a different direction? Or do you mean to move the point, but keep the velocity the same?

#### Aino

• Ent
• Thank You
• -Given: 1
• Posts: 1,483
• They'll eat you next!
• Eufloria: Yes
##### Re: Rotation
« Reply #48 on: July 25, 2011, 08:05:35 PM »
The last one, keeping the velocity the same, but the current position is changed by thoose 5...

#### hitman271

• Shoot
• Thank You
• -Given: 0
• Posts: 22
##### Re: Rotation
« Reply #49 on: July 27, 2011, 02:53:34 AM »
With vectors, you just add them together. So if one vector is { -100, -60 } and you want to move "5 distances" you would make "5 distances" a vector and just add those two vectors together. If this wasn't what you meant, give a more detailed question

#### annikk.exe

• Achiever
• Ent
• Thank You
• -Given: 0
• Posts: 1,794
##### Re: Rotation
« Reply #50 on: July 27, 2011, 03:34:28 AM »
I think I see what you mean.

If the red arrow is "pushing" with a force of 10, and the blue arrow with a force of 5, then the total force exerted would be 5 in the direction of the red arrow.

However, it's not clear what you wish to calculate.  Do you need to rotate an object?  If so then "distances" could be degrees.  Or perhaps you want to work out what direction something is travelling in after the result of several forces acting on it?

If you can explain what your diagrams mean, that will help.  :>  You have written "Lets say you got the values you got there, then want to do this:".  Do what?  "How the hell do you do that?"  Do what?  :>  If you can't put into words what you're trying to do, you're unlikely to be able to actually do it!  And we're even less likely to be able to help.

#### Aino

• Ent
• Thank You
• -Given: 1
• Posts: 1,483
• They'll eat you next!
• Eufloria: Yes
##### Re: Rotation
« Reply #51 on: July 27, 2011, 11:19:59 AM »
Ok, think of a ball, just rolling one way. Suddenly some strange wind appears and the angle of velocity is NOT changed, as it usually would be. But the ball is rather being pushed with the wind but still rolling the same exact way. This I hope help you

#### annikk.exe

• Achiever
• Ent
• Thank You
• -Given: 0
• Posts: 1,794
##### Re: Rotation
« Reply #52 on: July 27, 2011, 12:30:17 PM »
That's easy in that case.  It's just very simple vectors.

If I have a ball rolling west at x = -30
And some wind blows it south with a force of y = -10
Then the overall trajectory of the ball will be x = -30, y = -10

For diagonals, picture a ball rolling northwest at x = -15, y = -10
A wind blows the ball southwest by x = -5, y = 4
The overall trajectory of the ball will be x = -20, y = -6

See how that is working?  You just add both X's and both Y's to find the total X and total Y.  It really is that simple.

(click to show/hide)
« Last Edit: July 27, 2011, 12:34:12 PM by annikk.exe »

#### annikk.exe

• Achiever
• Ent
• Thank You
• -Given: 0
• Posts: 1,794
##### Re: Rotation
« Reply #53 on: July 27, 2011, 12:46:13 PM »

I will try to describe what I think you are trying to do.

You have a ball rolling in some arbitrary direction (EG North East).  You want to move the ball either left or right, such that you are "nudging" it along a line that is perpendicular to the direction of travel.  This must be done without affecting the direction the ball is travelling in.

So for example if the ball was travelling north.  The code should be capable of nudging the ball either west, or east.  After the nudge, the ball should still be travelling perfectly north.

Is that correct?  If that is the problem you're trying to solve, it may be helpful for you to note that where Line 1 is perpendicular to Line 2, m1 = 1 / -m2m is the "slope" variable from the slope/intercept equation of a line y = mx + c
Let me know if this is the problem and if so I shall explain further :>

#### Aino

• Ent
• Thank You
• -Given: 1
• Posts: 1,483
• They'll eat you next!
• Eufloria: Yes
##### Re: Rotation
« Reply #54 on: July 27, 2011, 01:46:06 PM »
By first read atleast, it seems like that is what I want

And the wind I meantioned, was just an exampling. The real purpose has no wind, my plans with this is to make the dot in "Tough Collisions" to jump from one side to another when you travel too fast, so it looks like you shake like hell

BTW, like my new Avatar?

#### annikk.exe

• Achiever
• Ent
• Thank You
• -Given: 0
• Posts: 1,794
##### Re: Rotation
« Reply #55 on: July 27, 2011, 01:54:27 PM »
heh :>

Look at the bit about calculating perpendicular lines.  :>

#### Aino

• Ent
• Thank You
• -Given: 1
• Posts: 1,483
• They'll eat you next!
• Eufloria: Yes
##### Re: Rotation
« Reply #56 on: July 27, 2011, 02:08:08 PM »
Annikk, I'm confused x.x

#### Pilchard123

• Tester
• Old Oak
• Thank You
• -Given: 0
• Posts: 899
• Eufloria: Yes
##### Re: Rotation
« Reply #57 on: July 27, 2011, 05:48:34 PM »
This is all so much easier that you're all making it out to be. Really.

Will the jump ALWAYS be at right angles to the velocity, or will it be in an arbitrary direction?

#### Aino

• Ent
• Thank You
• -Given: 1
• Posts: 1,483
• They'll eat you next!
• Eufloria: Yes
##### Re: Rotation
« Reply #58 on: July 27, 2011, 08:05:42 PM »
In all directions

But I made it all VERY VERY much harder than it really is(or to say for the purpose)...

My purpose of it was to make a speedup effect for the dot you are in Tough Collisions, where the dot shrinks and shakes, both illusions ofcourse, as the dot is actually just flowing normally in-game.

How I did it? Math.Random is your friend! I used it to add/subract some numbers to move it... Simple

• Tester
• Old Oak
• Thank You
• -Given: 0