Posted: 21st Mar 2021 16:50
I think it must be something about taking GetSpritePhysicsVelocityX() and GetSpritePhysicsVelocityY() and then throwing them into some cosinustangus voodoo thing. But I can't rightly recall what, exactly.
Posted: 21st Mar 2021 17:21
Should be a matter of
+ Code Snippet
ATan2(xvel, yvel)
Posted: 21st Mar 2021 17:54
Thanks, that's perfect! Just needed a bit of adjustment to make it fit the 3 o'clock clockwise standard:

+ Code Snippet
function dev_newAngle (a# as float)
	
	if a# < 0.0
		a# = 360.0 + a#		REM Make numbers positive
	endif
	a# = 360.0 - a#			REM Reverse the direction
	
	a# = a# + 90.0			REM Rotate 90 degrees
	if a# > 360.0			
		a# = a# - 360.0		REM Correct too big values
	endif
 
endfunction a#
Posted: 21st Mar 2021 18:21
ATan2(xvel, yvel)

can someone confirm the parameter order for ATan2 where it states ATan2( y, x ) "exactly matches the C++ atan2 function"?

the y, then x order seems to be re-enforced within the parameter descripts, as well.

meanwhile:

ATan2(0,1) produces 0.0 (straight up)

&

ATan2(1,0) = 90.0 (3 o'clock)

...which is what we get from ATanFull with x,y parameter order?

since ATan2 doesn't offer example results (like AtanFull does), i'd like to know what we should expect from ATan2 (beyond the -180 to 180 range).

add: i just noted the example code for ATan2 includes: result#=ATan2(y#,x#) so, i'm still confused.
Posted: 21st Mar 2021 23:17
atan2(y,x) appears to be the order for c++
I think it has to do with where the origin is. Either stright up or pointing to the right. Also atan2() returns radians i think
Posted: 22nd Mar 2021 0:55
@blink0k AppGameKit has a separate command for radians ATan2Rad, help states for certain that AppGameKit ATan2 is exactly the same as in C++ but in degrees
Posted: 22nd Mar 2021 1:02
Not sure why, but I'll take it. If I sub 90 from Atan2 results and wrap that angle, it works for all my stuff.

As I'm converting a Delphi game to AppGameKit right now, I noted that my Delphi code was more like 180-result, so the Atan2 implementation in AppGameKit is wrong/different.

Definitely degrees for aTan2 blink. Bit odd that it takes y,x though.
Posted: 22nd Mar 2021 1:51
So I search terms was "atan2 in layman's terms and this is the main result(not a link but a paragraph on its own):
What does atan2 return?
atan2() method returns a numeric value between -? and ? representing the angle theta of an (x, y) point. This is the counterclockwise angle, measured in radians, between the positive X axis, and the point (x, y)

Go further into an article linked below it and I came across;
Description
The Math.atan2() method returns a numeric value between -? and ? representing the angle theta of an (x, y) point. This is the counterclockwise angle, measured in radians, between the positive X axis, and the point (x, y). Note that the arguments to this function pass the y-coordinate first and the x-coordinate second.



So there is confirmation of the order, in fact literally every result I read into said the same about the order. Couldn't really find out/work out why. Have no clue what is meant by between negative/positive pi so i am assuming that is something used under the hood so to speak.

Also worthy of note is that the angle in the pic is counter clockwise which I have also read a number of times in various articles. I keep reading that atan is useful for working out the arctangent of only 2 quadrants(1 and 4) whereas atan2 is useful for all 4(ie on the pic you can see the divisions making 4 quadrants). What the heck all this means is well, I do not know! I mean what the purpose of each is, is what is missing - ie how to choose which you would use, when you would use and why...so atanfull I found useful in DBP when working out how to rotate a tree to match its billboard based on the camera and then slowly rotate it once the billboard is no longer needed towards a fixed angle(search my thread history and choose Tree LOD as the code is there). I can only guess that atan and atan2 would be useful for performance reasons maybe?
Posted: 22nd Mar 2021 1:51
Edit double post cos the forum is being dumb, c'mon TGC I keep seeing this again and again - sometimes when you click "post" nothing happens, clicked it again nothing, refreshed page to make sure I had not lost my connection and boom...2 posts.
Posted: 22nd Mar 2021 2:11
thanks for the Atan info, James.

and, i've seen others with the double-post issue in the past day or so and have reported the matter.

add: just experienced it myself with this post. i'm on Edge. you?
Posted: 22nd Mar 2021 2:31
Chrome, I haven't had this issue myself until now it was almost as though that the server end is experiencing some form of lag from time to time, my experience was that the button highlighted on clicking both times, but nothing happened until an F5 refresh, or perhaps it is session issue as it did take some time for me to read up and type notes in this pages post/edit box which I then re organised into a semi understandable form before I actually clicked post reply
Posted: 22nd Mar 2021 2:33
As a test I just left the page open a while before posting prev msg...lets see if I quick post this msg and the issue persists, results in edit to follow...


Edit - well nope issue still exists! Edit option is responsive though

Edit 2 - subscription notification is not working either now, also when did email alerts stop? I haven't had a single one since returning to the forum!