#17775 - Lupin - Sun Mar 14, 2004 5:48 pm
My knowledge about trigonometry is quite blury so i hope you may help me a little bit :)
I am using the swi 0xA0000 function to get the angle between 2 points. I started to write a test to see if it works for me...
The goal is to display a sprite whenever it is in my frustum (the frustum is defined by an angle from 0...2047 (2047 entry lut for sin and cos)).
well, posX and posY is in this format:
IIII IIII IIFF FFFF FFFF FFFF FFFF FFFF
I = integer
F = fraction
i shift it down 17 bits because the docu said that the function will take a 16 bit value with 1 bit sign, 1 bit integer and 14 bit fraction (i shift by 17 and not by 16 because posX and posY is always positive).
ViewY is the rotation of my camera. I thought that after subtracting it from the angle between (0,0) and (posX, posY) i would get the X coordinate because each column of my screen represents 1 "degree" of my custom sin/cos function.
Well, of course it doesn't work ;(
I have no clue how to get it work but i think i do something very simple very wrong :P
Please tell me how to work with arctan2...
Last edited by Lupin on Sun Mar 21, 2004 8:50 pm; edited 1 time in total
I am using the swi 0xA0000 function to get the angle between 2 points. I started to write a test to see if it works for me...
The goal is to display a sprite whenever it is in my frustum (the frustum is defined by an angle from 0...2047 (2047 entry lut for sin and cos)).
Code: |
test = (ArcTan2(posX>>17,posY>>17)>>3)-ViewY; if((test <= 239) & (test >= 0)) { //visible sprites[4].attribute0 = A0_COLOR_256 | A0_SHAPE_SQUARE | (40); sprites[4].attribute1 = A1_SIZE_8 | (test); sprites[4].attribute2 = A2_PRIORITY(0) | (512+64); } else { //invisible sprites[4].attribute0 = 160; sprites[4].attribute1 = 240; } |
well, posX and posY is in this format:
IIII IIII IIFF FFFF FFFF FFFF FFFF FFFF
I = integer
F = fraction
i shift it down 17 bits because the docu said that the function will take a 16 bit value with 1 bit sign, 1 bit integer and 14 bit fraction (i shift by 17 and not by 16 because posX and posY is always positive).
ViewY is the rotation of my camera. I thought that after subtracting it from the angle between (0,0) and (posX, posY) i would get the X coordinate because each column of my screen represents 1 "degree" of my custom sin/cos function.
Well, of course it doesn't work ;(
I have no clue how to get it work but i think i do something very simple very wrong :P
Please tell me how to work with arctan2...
Last edited by Lupin on Sun Mar 21, 2004 8:50 pm; edited 1 time in total