Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Sin, Cos, Tan? Any one know how!!

Author
Message
Mega_Dib
21
Years of Service
User Offline
Joined: 27th Jan 2004
Location:
Posted: 28th Jan 2004 00:52
Someone!! please help me!
Been programming for years but never bothered with angles,sin,etc.
Basically new project. Need formula for this.

Basic right-handed triangle.


******************* (enemy) Need rotation
* * for enemy
* *
* *
* *
* *
* *
* *
* *
**
(Your here)

I know all the sizes of the sides of the triangle, including the hypotenuse.
Obviously the lengths change at the enemies approach.I know Some Old Hens Can Always Hide There Old Age.(Rememberance for Trig). Experimented alot with all the Dark Basic Professional Trig, But cant get any results or come up with any algebra/equations to work. Im new to the Forums, so whos the best out there??
Thank you all for your help.
Mega_Dib
21
Years of Service
User Offline
Joined: 27th Jan 2004
Location:
Posted: 28th Jan 2004 01:02
The way the displayed the triangle looks nothing like that /\
||
Help!
qwe
21
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 28th Jan 2004 01:13
sin(a)=a/c
cos(a)=b/c
tan(a)=a/b
sin(b)=b/c
cos(b)=a/c
tan(b)=b/a

c is hypotenuse

i donno if this is only for right triangles.. or all triangles..

u kno there is "point object" command where you can point it to a 3d location

Dell Dimension 4550, Windows XP Home
2.52 ghz, 256 Mb RAM, Radeon 9500 Pro / 9700
Mega_Dib
21
Years of Service
User Offline
Joined: 27th Jan 2004
Location:
Posted: 28th Jan 2004 01:24
This is a 2D game. but thanks anyway Chris.
Just need to know how to convert sides of a triangle(which i know). Into an angle?
Dave J
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 28th Jan 2004 02:19
Quite simply:

Inverse Tan = First Side / Second Side


"Computers are useless they can only give you answers."
Dave J
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 28th Jan 2004 02:22 Edited at: 28th Jan 2004 02:22
Err, I might need to elaborate on that.

Tan-1 = (Opposite / Adjacent)

So if Opp = 6 and Adj = 2, the formula would go:

6 / 2 = 3

Atan(3) = 71.57


"Computers are useless they can only give you answers."
Wik
22
Years of Service
User Offline
Joined: 21st May 2003
Location: CT, United States
Posted: 28th Jan 2004 02:26 Edited at: 1st Mar 2004 04:12
can't you use point object or something?

Anyway Mattman posted about this.
http://darkbasic.thegamecreators.com/?m=forum_view&t=21997&b=2

copied and pasted:
These functions are used to find leg legnths or angle measures in a right triangle.

in the following:


you can find the angle measure of A.
Since you know the angle OPOSITE of A and the ADJECENT leg measurements you use TANGENT because as darwin stated the tangent is the oposite over adjacent. you do 12/24 which is .5 so to find measure A you kit the TAN-1 key on a calqulator of use the arc-tangent command in DB and type in .5. The calqulator then figures out for you that the measure of angle A is 26.56505118


Dave J
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 28th Jan 2004 02:31
Sorry, what was that? My explanation wasn't good enough? Bah! Let's step it up a notch.

The whole theory behind Sin, Cos and Tan is the Unit circle, they each give a certain length at a certain angle. This diagram demonstrates:



At 30 degrees, each of the 3 functions will give a different length to the point where it meets the outer edge of the circle. Or where Tan reaches the Asymptote.


"Computers are useless they can only give you answers."
DivW
21
Years of Service
User Offline
Joined: 31st Jul 2003
Location: Scotland
Posted: 28th Jan 2004 03:14
Mwuahaha! Step it up more, Exeat! Let's talk about Radians!

Mwuahahaha!!!!!

Whoops...wnet a but mad there. I'm really good with Geometry maths, angles, degrees, etc. so you can e-mail me if you want someone to do all the maths for you. I don't mind doing it, i need to keep the old knife sharp after all...

And forget what i saidd about Radians. Radians are for complete bastard ruthless maths teachers who enjoy watching people squirm.

-Dave

[email protected]

PS: I'm putting up a website at some point about things like game maths. This will include how to make a sprite travel in a circle always facing forwards, how to break out of a circle, how to calculate time delays, etc...

But the info's in my head, if anyone else needs it i'm there. E-mail above.

Your soul...it tastes like chicken

Official Website Coming Soon
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 28th Jan 2004 03:18
So you want to get the angle between you and the enemy?



"eureka" - Archimedes
DivW
21
Years of Service
User Offline
Joined: 31st Jul 2003
Location: Scotland
Posted: 28th Jan 2004 03:28
He didn't say anything about the angle...if it's 2D he might be looking for the co-ordinates...hmm...well if he is that's an even bigger bugger, but i can still do it I'm such a geek...

Your soul...it tastes like chicken

Official Website Coming Soon
Dave J
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 28th Jan 2004 04:40
Quote: "Mwuahaha! Step it up more, Exeat! Let's talk about Radians! "


Ok To convert from the standard degress to radians you can multiply the number by Pi / 180, likewise, to convert from radians to degrees you can multiply the number by 180 / Pi. Eg:

50 * Pi / 180 = 0.873
50 Degrees = 0.87 Radians

Gah, that's it for me lol.


"Computers are useless they can only give you answers."
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 28th Jan 2004 06:57
You can also work out the angle from the dot product of the two vectors which represent the adjacent side and the hypotenuse. Thats the method I like to use. Why you ask? Because I'm crazy, I reply.

Philip

What do you mean, bears aren't supposed to wear hats and a tie? P1.3ghz / 384 megs / GeForce MX 5200 128meg / WinXP home
Mega_Dib
21
Years of Service
User Offline
Joined: 27th Jan 2004
Location:
Posted: 28th Jan 2004 21:03
Thanks for all your support people. Im going to try these new equations now. I will email you DivW, when i get stuck again, cheers

Login to post a reply

Server time is: 2025-05-28 05:08:37
Your offset time is: 2025-05-28 05:08:37