Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
19 May, 2013, 16:35:59 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1] 2   Go Down
  Print  
Author Topic: Tangent? -  (Read 774 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
BlakPilar
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: 20 February, 2013, 02:38:22
Date Registered: 16 July, 2011, 02:50:55
Posts: 735


Topic starter
Total Post Ratings: +43

View Profile
« on: 08 May, 2012, 02:02:03 »
0

Is there a way tangent could be implemented? I've tried sin/cos, but I always get something really small, usually 0, 1, or 2 (I think). I'm making a shooter that has angled bullets for shiggles because I have nothing to do in my pre-calc class now that it's AP season (my tests are towards the end), and right now I just use a sort of slope method, but I figured it might possibly be easier/better in some way to use an angle. Then again, I've been wrong before ^^
Logged
Happybobjr
James Oldiges
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: Yesterday at 22:34:34
Date Registered: 01 June, 2010, 00:52:05
Location: IN, United States
Posts: 2273


Total Post Ratings: +100

View Profile
« Reply #1 on: 08 May, 2012, 02:08:18 »
0

Could you give us a sample please?
Logged

School: East Central High School

Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Non-Cas |||  OS: 1.1 |||  Build: Old  |||  84+ keypad.   Being lent out
____________________________________________________________
thepenguin77
z80 Assembly Master
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: Yesterday at 21:48:33
Date Registered: 14 December, 2009, 04:21:52
Location: Purdue
Posts: 1483


Total Post Ratings: +778

View Profile
« Reply #2 on: 08 May, 2012, 02:12:27 »
0

Xspeed = cos(θ) * speed
Yspeed = sin(θ) * speed

That should get the job done right?
Logged

zStart v1.3.011 4-29-2013  zStart fully works on 83+BE's (except custom font)
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112
BlakPilar
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: 20 February, 2013, 02:38:22
Date Registered: 16 July, 2011, 02:50:55
Posts: 735


Topic starter
Total Post Ratings: +43

View Profile
« Reply #3 on: 08 May, 2012, 02:45:15 »
0

Basically what I have is all of my bullets' data stored in L1, with the format being this:

Offset | Meaning
n+0    | ^r = X
n+2    | ^r = Y
n+4    | Slope
n+5    | Flag for up/down


Now, I do realize I don't need the word-sized X and Y, but I didn't feel like working with one-byte variable numbers while I was writing this. Anywho, basically what id does right now is at every update the X is incremented by 1 and if X^slope is zero, I change Y based on the flag. Right now it works fine, but my question was instead of doing a slope, would it be easier to have something like tangent be used to calculate an angle? (I just remembered it's arctan(Y/X) = angle, not the other way around >.<)
« Last Edit: 08 May, 2012, 02:45:33 by BlakPilar » Logged
Builderboy
Physics Guru
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: Today at 11:51:23
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5642


Total Post Ratings: +589

View Profile
« Reply #4 on: 08 May, 2012, 03:30:55 »
0

Instead of using slope and a flag, would it not be easier to use just an angle instead?  That way you can specify the full range of directions in equal precision, and it would take up less data and use already implemented Axe commands.  Your slope would range from 0 to 256, where 0 is directly to the right, 64 is directly down, 128 is directly to the left, and 192 is directly up.  To extract the directions from the angle, simply use Cos(angle) for the X direction and Sin(angle) for the Y direction
Logged

BlakPilar
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: 20 February, 2013, 02:38:22
Date Registered: 16 July, 2011, 02:50:55
Posts: 735


Topic starter
Total Post Ratings: +43

View Profile
« Reply #5 on: 08 May, 2012, 03:33:20 »
0

Instead of using slope and a flag, would it not be easier to use just an angle instead?

Precisely my initial question lol. But I don't need to worry about left/right movement. The bullets start on the left side of the screen in the middle, and are fired so they go to the right either up or down.
Logged
Builderboy
Physics Guru
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: Today at 11:51:23
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5642


Total Post Ratings: +589

View Profile
« Reply #6 on: 08 May, 2012, 04:31:47 »
0

Well using an angle method still works well, and if this is for some sort of shooter game, that means you can re-use some code for any bullets that are being fired back at you Cheesy
Logged

Wretchedlout
LV3 Member (Next: 100)
***
Offline Offline

Last Login: 16 May, 2013, 01:16:32
Date Registered: 04 April, 2012, 08:11:00
Posts: 64

Total Post Ratings: +6

View Profile
« Reply #7 on: 08 May, 2012, 04:48:34 »
0

Couldn't you derive it?
Logged
Builderboy
Physics Guru
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: Today at 11:51:23
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5642


Total Post Ratings: +589

View Profile
« Reply #8 on: 08 May, 2012, 05:09:01 »
0

Derive what?
Logged

cooliojazz
Support Staff
LV7 Elite (Next: 700)
*
Offline Offline

Gender: Male
Last Login: Today at 00:23:49
Date Registered: 23 May, 2009, 19:28:11
Location: Colorado, USA
Posts: 614


Total Post Ratings: +52

View Profile WWW
« Reply #9 on: 08 May, 2012, 05:15:21 »
0

Tangent as in the trigonometric function, not the slope of a line at a point =P  So, no there is nothing useful to derive here...
Logged

Spoiler for Random signess:
You can not beat my skills.
Trust me.
So don't even try.
And remember never to trust someone who says, "Trust me."



TI File Editor Progress: Remade in java like a boss. 50% we'll call it? IDK =P
Java Libraries: JIRC - 90% JTIF - 5%
TI Projects: Unreal Notator - -5000%
Nomcraft, a Bukkit mod
Some of the music I write can be found here
The Rest Should Be Here (Bandcamp)
aeTIos
You got stair'd!
LV12 Extreme Poster (Next: 5000)
************
Offline Offline

Gender: Male
Last Login: Today at 14:09:09
Date Registered: 15 September, 2010, 06:00:00
Location: Netherlands, Overijssel
Posts: 3107


Total Post Ratings: +120

View Profile
« Reply #10 on: 08 May, 2012, 11:57:02 »
0

Yeah I would pretty much like a tan( function.
Logged

If something above sounds rude, feel free to vote it down, it was not meant to be rude<<lolol
--Always stay relAXEd!--


Spoiler for Hidden:


[







Spoiler for Still Alive:
This was a triumph.
I'm making a note here: HUGE SUCCESS.
It's hard to overstate my satisfaction.

Aperture Science:
We do what we must because we can.
For the good of all of us
Except the ones who are dead.

But there's no sense crying over every mistake
You just keep on trying till you run out of cake
And the science gets done and you make a neat gun
For the people who are still alive.

I'm not even angry.
I'm being so sincere right now.
Even though you broke my heart and killed me.
And tore me to pieces.
And threw every piece into a fire.
As they burned it hurt because
I was so happy for you.

Now these points of data make a beautiful line
And we're out of beta we're releasing on time.
So I'm GLaD I got burned think of all the things we learned
For the people who are still alive.

Go ahead and leave me.
I think I prefer to stay inside.
Maybe you'll find someone else to help you.
Maybe Black Mesa -
THAT WAS A JOKE. HA HA, FAT CHANCE.
Anyway, this cake is great:
It's so delicious and moist.

Look at me still talking when there's science to do.
When I look out there it makes me GLaD I'm not you.
I've experiments to run there is research to be done
On the people who are still alive

And believe me I am still alive.
I'm doing science and I'm still alive.
I feel FANTASTIC and I'm still alive.
While you're dying I'll be still alive.
And when you're dead I will be still alive.

Still alive
Still alive
calc84maniac
Epic z80 roflpwner
Coder Of Tomorrow
LV11 Super Veteran (Next: 3000)
*
Offline Offline

Gender: Male
Last Login: 14 May, 2013, 10:02:35
Date Registered: 28 August, 2008, 05:09:05
Location: Right behind you.
Posts: 2735


Total Post Ratings: +373

View Profile
« Reply #11 on: 08 May, 2012, 15:42:24 »
0

I feel like this would work:

1
2
Lbl Tan
Return sin(r1)*256//cos(r1)
Logged

"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman
C0deH4cker
LV5 Advanced (Next: 300)
*****
Offline Offline

Gender: Male
Last Login: 19 December, 2012, 22:22:42
Date Registered: 18 October, 2011, 23:19:08
Location: $9D95
Posts: 258


Total Post Ratings: +10

View Profile WWW
« Reply #12 on: 17 May, 2012, 04:56:55 »
0

Why *256? tan(angle) is defined as y/x, and with sin(angle) and cos(angle) being y/r and x/r respectively, tan(angle) can also be defined as sin(angle)/cos(angle), so i dont see why you would multiply sin(angle) by 256 first.
Logged

Hayleia
Programming Absol
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Last Login: Yesterday at 09:26:23
Date Registered: 01 June, 2011, 20:12:47
Location: ud-ud ?
Posts: 2043


Total Post Ratings: +254

View Profile
« Reply #13 on: 17 May, 2012, 08:40:27 »
0

Why *256? tan(angle) is defined as y/x, and with sin(angle) and cos(angle) being y/r and x/r respectively, tan(angle) can also be defined as sin(angle)/cos(angle), so i dont see why you would multiply sin(angle) by 256 first.
Else you would lose precision, as the division in Axe doesn't care about the remainder. For example, 7/2=3.5 but in Axe, 7/2=3 (if you don't do floating point math of course Wink)
This is also why cos and sin return between -127 and 127 because if it returned between -1 and 1, it would always be 0
Logged





Spoiler for what I am according to...:
me: useless
Pokemon Test: an Absol
turiqwalrus: an eggplant
p2: A HUMAN BEING !
Blackpilar and p2: iplantonlyplantwantplanttoplantknowplantifplantyouplantareplantaplantboyplantorplantaplantgirlplant
click here to know where you got your last +1s
C0deH4cker
LV5 Advanced (Next: 300)
*****
Offline Offline

Gender: Male
Last Login: 19 December, 2012, 22:22:42
Date Registered: 18 October, 2011, 23:19:08
Location: $9D95
Posts: 258


Total Post Ratings: +10

View Profile WWW
« Reply #14 on: 17 May, 2012, 21:58:23 »
0

But multiplying by 256 just changes it from something like $00A6 to $A600. It doesnt increase precision, but just changes the value. sin($A600) is completely different than sin($00A6).
Logged

Pages: [1] 2   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.294 seconds with 30 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.