Author Topic: Rotation  (Read 3929 times)

0 Members and 1 Guest are viewing this topic.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Rotation
« on: May 08, 2011, 05:01:37 PM »
Well, so I wonder: rotation...

How do you do it?? I've tried this:

Code: [Select]
local Rotation = (r/360)*(3.1415*2)

for i = ModelPartStart[id],ModelPartEnd[id] do
DrawX = xpos + (math.cos(Rotation)*ModelPartX[i])
DrawY = ypos + (math.sin(Rotation)*ModelPartY[i])

it's a snippet from my current proj. and I thought it would go just fine, but then: it just twists and do stuff I wouldn't expect... and the Y-axis ain't working properly at all. Here's two comparisons:

1:


2:

Well, why the f**k?

Sniped50

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 97
  • Don't ask. About anything.
Re: Rotation
« Reply #1 on: May 08, 2011, 08:01:35 PM »
Did you want those spheres to rotate as if they were a single line? I'm not sure what exactly you were aiming for, but that's what I could gather since those are rather simple equations.

Also, what does that 'r' stand for? Is it something you called earlier in the code?
"Sometimes, the simplest solutions work the best."
- Mythbusters

"But the complex solutions look prettier."
- Me

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Re: Rotation
« Reply #2 on: May 08, 2011, 08:34:15 PM »
A straight line was what I was aiming for, and r stands for rotation or degree... But I think I might be able to solve this, cause in a new code I've made, it just moves around the center with the same shape, but I think I can solve this :)

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Re: Rotation
« Reply #3 on: May 08, 2011, 08:42:39 PM »
But still, don't stop helpin', cause if my new idea fails... I'll need to call for you again -.-

EDIT: And to simplify: I want the Yaw to rotate, nothing else...
« Last Edit: May 08, 2011, 08:53:34 PM by Aino »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Re: Rotation
« Reply #4 on: May 09, 2011, 01:56:25 PM »
YEEES! Figured it out, now to make moving sprites :)

I hope this tool will contribute to game making in Eufloria, that would be awesome IMO :)

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Re: Rotation
« Reply #5 on: May 09, 2011, 06:02:47 PM »
And now the whole thing turned crappy... It isn't drawing anything at all! Better take the rest of the day away from coding :)

And expect a new map to come soon, it's been some beta testing... But it seems like everyone(Bonobo(the others haven't responded yet :S)) had a hard time beating it... But still simple as hell(IMO) :D(this means it is beatable, but hard :D)

Bonobo

  • Achiever
  • Old Oak
  • ****
  • Thank You
  • -Given: 77
  • -Receive: 8
  • Posts: 629
  • Was born, still alive.
    • German Mac Mailing Lists
  • Eufloria: Yes
Re: Rotation
« Reply #6 on: May 09, 2011, 07:22:13 PM »
So much for the outing of mine one as a l4m0r ;)
Google+
Do you play Go? (aka iGo aka Baduk aka Weiqi)

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Re: Rotation
« Reply #7 on: May 09, 2011, 08:14:52 PM »
YEAH!!!!!!!!!!!!

seed YEAH!

sry for swearing, but this is a huge step for me(which are having plans becoming a programmer...) cause I just made that f**king thing work! Finally, time to make real 2D game, no more single dots :D

(it even supports animation :P)

EDIT: And lol, the code is approx. 160 lines long xD Im so happy now, but I won't leave the forum just now... gonna make some kind of 3D showof thing before I even imagine leaving this awesome forum :)
« Last Edit: May 09, 2011, 08:23:28 PM by Aino »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Re: Rotation
« Reply #8 on: May 12, 2011, 01:02:02 AM »
Need more help, which is about rotation...

Ok, so I need help about something I've been thinking about for ages, but now I need it kinda...

So the problem is to simply find the rotation or wahtever yuo call it between two entities, lets make a simple example:

Bob is lookng south, he sees a buddy and wants to talk to him, but noone talks without looking at the person they talk to? So how is bob gonna turn around and know when he sees his buddy(which angle is he supposed to look).

And those who can't seem to find out what I mean, I made a decently telling picture:



So now, help?

Widget

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 98
Re: Rotation
« Reply #9 on: May 12, 2011, 11:35:47 AM »
Couldn't you use the x/y position of the two points to calculate the measurements of a hypothetical right-angle triangle and work from there? A straight line between the two points would be your hypotenuse and you could use the measurements to calculate the relative angle.

There's probably a much easier way but that's all that springs to mind.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Re: Rotation
« Reply #10 on: May 12, 2011, 11:54:49 AM »
What did he say? I'm confused... what is all those crazy things? *googling*


EDIT: Are you talking abouth Pythagoras Theorem? If so, how do I use it to find angles?

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 17
  • Posts: 899
  • Eufloria: Yes
Re: Rotation
« Reply #11 on: May 12, 2011, 05:08:24 PM »
Trig.

Sine of angle = side opposite angle / hypotenuse
Cosine of angle = side next to angle / hypotenuse
Tangent of angle = side opposite angle / side next to angle

Use the inverse functions to get the angle.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Re: Rotation
« Reply #12 on: May 12, 2011, 05:28:59 PM »
Ok Pilchard, I know you love to confuse people... But this is my first time looking into this and please explain deeper and more understandable? Maybe you want to add some pictures too? :)

Edit: After some research, you refer to atan,asin and acos... which I am going to use on the exact thing you said now?
« Last Edit: May 12, 2011, 06:30:52 PM by Aino »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Rotation
« Reply #13 on: May 13, 2011, 01:46:43 PM »
Aino, the maths needed to calculate what you want is called Trigenometry.  This uses Sin, Cos (which are discussed in the Intermediate Guide) and also another one called Tan (which is short for "tangent") to calculate angles.

I'd recommend you find yourself a nice beginners guide to Trigenometry and work through that.  It will help you get up to speed on the subject.  :>

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Re: Rotation
« Reply #14 on: May 13, 2011, 02:16:57 PM »
>.<

Well, better get going...