Author Topic: Axe Q&A  (Read 586813 times)

0 Members and 3 Guests are viewing this topic.

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Axe Q&A
« Reply #1545 on: July 02, 2012, 07:34:12 pm »
Qwerty.55 asked that question here, but apparently the font sprites are stored at different places in different OS versions, so it's not very useful.




Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: Axe Q&A
« Reply #1546 on: July 03, 2012, 09:31:39 am »
what with the lack of inverse trig functions, what is the best way to determine the angle (0-255) from one point to another on an x,y plane?

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: Axe Q&A
« Reply #1547 on: July 03, 2012, 09:47:02 am »
There's a tricky way using dot products, but Iambian wrote a much more accurate arctan Axiom that you could check out.
In-progress: Graviter (...)

Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: Axe Q&A
« Reply #1548 on: July 03, 2012, 10:15:08 am »
what dot-product method is there? all i can think of is cos(theta) = (u dot v)/(||u|| ||v||), and that would still need arccos

and thanks =)
* shmibs goes to check it out that axiom

edit, i found the axiom, but it's compiled as an 8xp rather than 8xv, what do?
http://ourl.ca/14229
« Last Edit: July 03, 2012, 11:02:38 am by shmibs »

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Axe Q&A
« Reply #1549 on: July 03, 2012, 10:57:34 am »
Doesn't Axe have a built in tan-1 routine?

Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: Axe Q&A
« Reply #1550 on: July 03, 2012, 11:05:07 am »
X_X
yes, it does.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axe Q&A
« Reply #1551 on: July 03, 2012, 10:31:20 pm »
what dot-product method is there? all i can think of is cos(theta) = (u dot v)/(||u|| ||v||), and that would still need arccos

It depends on what you need the angle for.  Sometimes you can use vector arithmetic to speed things up, but sometimes not.  What did you need the angle for?

Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: Axe Q&A
« Reply #1552 on: July 04, 2012, 12:52:14 am »
i was using it for determining the angle from those enemy tanks to the player tank here, and ended up using the built in tan^-1 method
out of curiosity, though, what other things do you mean?

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axe Q&A
« Reply #1553 on: July 04, 2012, 03:17:19 am »
One example that I've used it for is the aiming of a rocket.  The rocket rotates right if the target is to the right, and rotates left if the target is to the left.  You could use Tan^-1 to find the angle between them, but using the cross product is so much faster :D

Code: [Select]
If dx*vy - dy*vx < 0
  turnLeft
Else
  turnRight
End

Where dx/dy is the X and Y distance between you and your target, and vx/vy is your X and Y velocity.

EDIT: It IS the cross product.  The dot product will return positive if your velocity and your displacement are within 90 degrees of each other, which is not what we want.
« Last Edit: July 04, 2012, 01:58:23 pm by Builderboy »

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Axe Q&A
« Reply #1554 on: July 04, 2012, 02:19:36 pm »
Oh, my bad. I saw dx*vy-dy*vx and was like, wait, "cross product magnitude doesn't look like that at all, that looks more like dot product" but then I realized that that's a specialized form for cross product where the z component is 0 :P

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axe Q&A
« Reply #1555 on: July 04, 2012, 02:29:54 pm »
Exactly :D It technically is returning a vector, it's just that the vector is pointing into or out of the screen :P

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Axe Q&A
« Reply #1556 on: July 09, 2012, 11:09:22 am »
Would it be possible to have equates ?
I mean that for example if I write this
   test equ {V+17}
each time the parser hits the word "test", it replaces it with "{V+17}" before translating it into asm.

(note that here, V+17→°test would not work since V+17 is not constant)
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Axe Q&A
« Reply #1557 on: July 09, 2012, 12:20:29 pm »
If you're using {V+17} so much that you need an equate for it, you should probably either assign it to a variable (if it doesn't change much) or create a subroutine for it (if it changes all the time).




Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Axe Q&A
« Reply #1558 on: July 09, 2012, 12:33:41 pm »
In fact, V is the main pointer of an appvar and I have a lot of {V+1},{V+2},...{V+17}...{V+96} etc, and I may forget what each one is referring to. This is why I asked for equates, not only for {V+17}. And I thought about the subroutine but there would be two solutions with this: make the routine return V+17 so I have to do {Rout()} which is a bit ugly, or make two routines with one that would read and the other that would store, which is a bit too much.
For now, my solution is to store the number after the V+ into a constant with a logic name so for apples (for example) I can do {V+°Apple} to read or write to the right byte. But an equate would be even more efficient.
« Last Edit: July 09, 2012, 12:33:59 pm by Hayleia »
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Axe Q&A
« Reply #1559 on: July 09, 2012, 12:43:18 pm »
It would be very inefficient in terms of the code it produces, if I understand what you mean (meaning every time you use the equate, Axe inserts {V+17}, which I'd think is something like eight bytes).

EDIT: Oh, I see, that way if FOO translated to {V+17}, you could do something like 23→FOO and FOO→X and both would be valid statements.

It would still be no different than using {V+17} everywhere though, since FOO wouldn't actually exist. It'd be more like a macro than anything.