### Author Topic: [Axiom] Aiming Utility  (Read 3908 times)

0 Members and 1 Guest are viewing this topic.

#### Iambian

• Coder Of Tomorrow
• Posts: 737
• Rating: +215/-3
• Cherry Flavoured Nommer of Fishies
##### [Axiom] Aiming Utility
« on: November 26, 2011, 04:11:26 am »
It spits out an angle that you can use to aim at targets given a delta X and Y. See the ReadME.

NOTE: This has not been tested. Please test this thing to see if it conforms to what the readme says. When I went about testing it, it drove me insane. I probably just need sleep.

Attached to this post is what I have so far. When I can verify that it works, I'll post another with source included in it. The arctangent routine that is used in the Axiom was sourced from CaDan. Please test it.

Arghablabbles. (This post will be edited as stuff is changed)

EDIT: Attachment replaced with one that actually works. This is to be version 0.02 of this Axiom. Thank you very much for your patience. I will continue to make this "better". And by better, I mean smaller with acceptable losses in accuracy, and also to make the routine "native" to the dimensions I gave it, rather than some hack job to make it "work". Also, source is included.
« Last Edit: November 28, 2011, 02:43:09 pm by Iambian »
A Cherry-Flavored Iambian draws near... what do you do? ...

#### Yeong

• Not a bridge
• LV12 Extreme Poster (Next: 5000)
• Posts: 3739
• Rating: +278/-12
• Survivor of Apocalypse
##### Re: [Axiom] Aiming Utility
« Reply #1 on: November 26, 2011, 07:35:09 am »

so with this, we can have that crazy shitload of bullets like CaDan in Axe?
Perfect.
Sig wipe!

#### Darl181

• Vy'o'us pleorsdti thl'e gjaemue
• CoT Emeritus
• LV12 Extreme Poster (Next: 5000)
• Posts: 3408
• Rating: +305/-13
• VGhlIEdhbWU=
##### Re: [Axiom] Aiming Utility
« Reply #2 on: November 26, 2011, 07:01:07 pm »
So this uses that giant method you posted in the CaDan topic? derp
Tho in my case imma stay with what's working already for Essence
« Last Edit: November 26, 2011, 07:03:23 pm by Darl181 »

#### epic7

• Chopin!
• LV11 Super Veteran (Next: 3000)
• Posts: 2200
• Rating: +135/-8
• I like robots
##### Re: [Axiom] Aiming Utility
« Reply #3 on: November 26, 2011, 07:02:46 pm »
YES!

#### Iambian

• Coder Of Tomorrow
• Posts: 737
• Rating: +215/-3
• Cherry Flavoured Nommer of Fishies
##### Re: [Axiom] Aiming Utility
« Reply #4 on: November 27, 2011, 02:46:19 am »
Remember guys. I need people to test this thing because I didn't think this thing would actually work the first time around. As far as I can tell, it doesn't crash the system, but I don't know if it's giving the right outputs.

so with this, we can have that crazy shitload of bullets like CaDan in Axe?
Perfect.
No. This allows you to aim like the enemies can in CaDan. Your Axe project still needs to be responsible for the bullets it outputs.
A Cherry-Flavored Iambian draws near... what do you do? ...

#### Darl181

• Vy'o'us pleorsdti thl'e gjaemue
• CoT Emeritus
• LV12 Extreme Poster (Next: 5000)
• Posts: 3408
• Rating: +305/-13
• VGhlIEdhbWU=
##### Re: [Axiom] Aiming Utility
« Reply #5 on: November 27, 2011, 11:23:32 am »
So this takes in X,Y,deltaX and deltaY?
How does it handle inflation...I'm supposing the coder has to inflate it theirself.  *256?
« Last Edit: November 27, 2011, 11:23:51 am by Darl181 »

#### Iambian

• Coder Of Tomorrow
• Posts: 737
• Rating: +215/-3
• Cherry Flavoured Nommer of Fishies
##### Re: [Axiom] Aiming Utility
« Reply #6 on: November 27, 2011, 01:57:25 pm »
So this takes in X,Y,deltaX and deltaY?
How does it handle inflation...I'm supposing the coder has to inflate it theirself.  *256?
No, it just takes a delta X and delta Y. You have to do the (X2-X1),(Y2-Y1) yourself. The Axiom takes two arguments and gives out a single answer.

Each 16 bit argument is truncated to 8 bits for you. I just simply chop off the high byte.
A Cherry-Flavored Iambian draws near... what do you do? ...

#### Quigibo

• The Executioner
• CoT Emeritus
• LV11 Super Veteran (Next: 3000)
• Posts: 2031
• Rating: +1075/-24
##### Re: [Axiom] Aiming Utility
« Reply #7 on: November 27, 2011, 02:26:49 pm »
So basically this is the function better known as "atan2".  That's cool!  I added this recently for the next version of axe.
___Axe_Parser___
Today the calculator, tomorrow the world!

#### DJ Omnimaga

• Now active at https://codewalr.us
• CoT Emeritus
• LV15 Omnimagician (Next: --)
• Posts: 55816
• Rating: +3151/-232
• CodeWalrus founder & retired Omnimaga founder
##### Re: [Axiom] Aiming Utility
« Reply #8 on: November 27, 2011, 04:13:47 pm »
This seems interesting. I sometimes had troubles in the past with enemy aiming when I worked on some shooters, although in my case it was TI-BASIC. Good work I guess
In case you are wondering where I went, I left Omni back in 2015 to form CodeWalrus due to various reasons explained back then, but I stopped calc dev in 2016 and am now mostly active on the CW Discord server at https://discord.gg/cuZcfcF

#### Iambian

• Coder Of Tomorrow
• Posts: 737
• Rating: +215/-3
• Cherry Flavoured Nommer of Fishies
##### Re: [Axiom] Aiming Utility
« Reply #9 on: November 28, 2011, 08:57:06 am »
So basically this is the function better known as "atan2".  That's cool!  I added this recently for the next version of axe.
Curious to know, but how are you calculating atan in your version? My guess is that you're going to use polynomial approximation?

My version uses a 256 byte LUT to help calculate the angle and it uses linear interpolation to fill the gap that the LUT creates. I can probably get away with a 64 byte LUT and further the linear interpolation to help give a "good enough" result, but I'd want a test routine to help me figure out if the values I'm getting are good.

And so it seems like I'm going to have to learn Axe (yeah, I don't know it very well) to pull together a test routine for this mess. Wish me luck on this one. Then I'll probably modify the routine and probably try to optimize it. But first thing is first. Gotta make sure it works.

EDIT: Also, I assume you're going to be using the tan-1( token? If you do that, what should I change mine to, since I happen to be using that as well?
EDIT2: Okay. Actually writing the test routine. Things appear to fail. Need some time to figure out the problem.
EDIT3: Success!
« Last Edit: November 28, 2011, 02:43:54 pm by Iambian »
A Cherry-Flavored Iambian draws near... what do you do? ...

#### Quigibo

• The Executioner
• CoT Emeritus
• LV11 Super Veteran (Next: 3000)
• Posts: 2031
• Rating: +1075/-24
##### Re: [Axiom] Aiming Utility
« Reply #10 on: November 28, 2011, 04:39:15 pm »
Yeah, mine is lossy, but its very compact and tiny.  The most I have seen it off is by 4 binary degrees but on average its usually less than 3.  It is exact every 45 degrees.  This is the routine I'm using:

Code: [Select]
p_ArcTan: .db __ArcTanEnd-1-$ex de,hl ;de = y pop hl ex (sp),hl ;hl = x push hl ld a,h ;\ xor d ; |Get pairity rla ;/ jr c,__ArcTanSS ;\ add hl,de ; | add hl,de ; |__ArcTanSS: ; | or a ; |hl = x +- y sbc hl,de ;/ ex de,hl ;de = x +- y ld b,6 ;\__ArcTan64: ; | add hl,hl ; |hl = 64y djnz __ArcTan64 ;/ call$3F00+sub_SDiv ;hl = 64y/(x +- y) pop af ;\ rla ; |Right side, fine ret nc ;/ sbc a,a ;\ sub h ; |Reverse sign extend ld h,a ;/ ld a,l ;\ add a,128 ; |Add or sub 128 ld l,a ;/ ret__ArcTanEnd:
The arguments are currently backwards; (X,Y) instead of the traditional (Y,X).  I'm not sure which one I'm going to use yet.
« Last Edit: November 28, 2011, 04:40:07 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

#### Builderboy

• Physics Guru
• CoT Emeritus
• LV13 Extreme Addict (Next: 9001)
• Posts: 5673
• Rating: +613/-9
• Would you kindly?
##### Re: [Axiom] Aiming Utility
« Reply #11 on: November 28, 2011, 05:43:42 pm »
I think (X,Y) would make more sense to newer users, as well as users that have not used the Atan2() function before.

#### Quigibo

• The Executioner
• CoT Emeritus
• LV11 Super Veteran (Next: 3000)
• Posts: 2031
• Rating: +1075/-24
##### Re: [Axiom] Aiming Utility
« Reply #12 on: November 29, 2011, 02:09:51 am »
Yeah.  Nearly every programming language uses (Y,X) and every spreadsheet and math program uses (X,Y).  So I think I'll end up sticking with X,Y just because it optimizes better, and its more consistent with the rest of the Axe syntax when looked at independently of other programming languages.  Iambian used this convention as well.

___Axe_Parser___
Today the calculator, tomorrow the world!

#### Iambian

• Coder Of Tomorrow