translating x/y to angle?

Post everything that hasn't to do with MOHAA or MOHPA here, including site feedback/suggestions.

Moderator: Moderators

User avatar
Jack Ruby
General
Posts: 1443
Joined: Fri Feb 07, 2003 12:20 am
Location: london

Post by Jack Ruby »

Lolol,

Maths man, I just dont get it, never have, doubt I ever will.

The only time in my life I had some basic maths going was when I was a cashier at a bookmakers, after a few weeks I didnt even have to think, the numbers appeared to me from nowhere.
Philip II of Macedon sent a message to Sparta:
"If I win this war, you will be slaves forever."
The Spartan ephors sent back a one word reply: "If".
User avatar
TopTiger
Sergeant
Posts: 65
Joined: Fri Mar 05, 2004 12:46 pm
Location: The Netherlands
Contact:

Post by TopTiger »

well the world is built on maths... I hate maths... and i study civil engineering :? i'm a little weird.


but this topic is about the 2d game...
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

<<< Sorry for off topic :oops: >>>

Just wondering, where do you study CE TopTiger?
Image
PKM
General
Posts: 1888
Joined: Tue Aug 09, 2005 4:43 pm
Location: Philadelpia but stuck in San Antonio TX (hell)

Post by PKM »

TopTiger wrote:well the world is built on maths... I hate maths... and i study civil engineering :? i'm a little weird.


but this topic is about the 2d game...
correction: civilization is built on math, not the world. if you say you can see math in nature then that is an observation not a fact. the church of me abhors math. it may explain why our offerings are always a little off with each count. either that or deacon _map is pilfering again.
i'm not f****** angry, i'm from philadelphia .
Image
User avatar
TopTiger
Sergeant
Posts: 65
Joined: Fri Mar 05, 2004 12:46 pm
Location: The Netherlands
Contact:

Post by TopTiger »

jv_map wrote:<<< Sorry for off topic :oops: >>>

Just wondering, where do you study CE TopTiger?
I study in Alkmaar (HBO). Still need to go 3 years, but it's very interesting. I might go to TU delft, but then I have another 3-4 years to go. :(

sry for off topic.

ontopic:
Lizard, are there any ss of that 2d game?
correction: civilization is built on math, not the world. if you say you can see math in nature then that is an observation not a fact. the church of me abhors math. it may explain why our offerings are always a little off with each count. either that or deacon _map is pilfering again.
yes, civilization, sry
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

jv:

the arctan thing seems almost works, however they face the wrong ways... and not in the absolute opposite direction, but at an angle to it. this may be one of my methods with rotation or something, but i htink i got the radians to degrees thing mixed up. i did the
( tan(y/x)^-1 )
thing, and then divided that number by this
( PI / 180 )

[ ( tan(y/x)^-1 ) / ( PI / 180 ) ]

is that correct? i'm double checking my functions and there's nothing overly obvious but if i've got the calculations right then i'll take a deeper look.

TopTiger:

You really don't want SS's of it :P at this stage, it's a bunch of round red and blue circular images moving around the screen to different points (a lot of times bouncing off them) while various other features run... it's not that exciting, yet :P
When i get it to a workable stage maybe i'll post something, but it wont be very soon ;)

Personally, math hasn't ever struck it with me. i have a basic enough feel and i can understand some stuff like this.. but tbh, i dont enjoy it. it's just a tool for me. i enjoy games and the creation of them, and since math is an essential part... well there ya go. just like Rad or anything else to me :P
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Hmm well it could be 3 things:

1) The arctan you are using returns the angle in degrees. Try it without the 180/pi factor.

2) You are not using arctan but 1/tan. At least the way you wrote it suggests this.

tan^-1 (x) != [tan(x)]^-1

This is why generally the notation arctan(x) or atan(x) is preferred over tan^-1 (x).

3) A definition problem.

The angle you will get from the inverse tan is the following:

Code: Select all

y
^        (x,y)
|        /
|      /
|    /
|  /
|/ ) a
0------------->x
Given the point (x,y) then:

a = atan(y/x); when x > 0
a = atan(y/x) + pi; when x < 0
a = pi/2; when x = 0 and y > 0
a = -pi/2; when x = 0 and y < 0
a is undefined; when x = 0 and y = 0

However, in computer graphics, the y axis of a screen is often oriented down instead of up, so you will get the angle the other way around.

<<< Sorry for offtopic :oops: >>>

Ah very cool TopTiger :) .. I'm in Delft currently doing Aerospace Engineering.. Not a bad idea to go here after your HBO.. I believe you can already start your MSc programme after only a 1 year transfer programme, so that's pretty sweet 8-) .. only problem is they like concrete so much the CE building looks like a forgotten nazi bunker :P
Image
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

jv_map wrote:only problem is they like concrete so much the CE building looks like a forgotten nazi bunker :P
Most newer universities in Spain look like this. ;) A perfect shelter in case of a zombie outbreak! :twisted:
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
Post Reply