🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Get rotation angle from normalized 2D vector

Started by
49 comments, last by JoeJ 6 years ago
30 minutes ago, JoeJ said:

Revert to your old and working code, but use mine to generate a second 'rotmat2' matrix.

Then use debugger to compare the numbers of working rotmat and not-working rotmat2. They should have the same numbers, and you should see what's wrong by comparing them. 

That sounds like something i need to do.

I dont know how a debugger works, time to find out.

Good i dont have to use a float to text function.

 

26 minutes ago, JTippetts said:

This particular combination of arrogance and ignorance you have going on is astounding, and not in a good way.

Ignorance ?, i asked you if you have made such a function you still did not answer that question.

I simply dont have time to figure out how to display floating point values, it wont work with me, always problems with that floats, is that arrogance ?

Once you play my game you will forgive me.

S T O P C R I M E !

Visual Pro 2005 C++ DX9 Cubase VST 3.70 Working on : LevelContainer class & LevelEditor

Advertisement
10 minutes ago, the incredible smoker said:

I dont know how a debugger works, time to find out.

On the long run it will save you much more time than necessary to figure out.

Using Visual Studio, you need to switch from Release to Debug build, and if necessary setup all project stuff for debug (include directuries, libraries etc.)

Then you klick left beside code so a red dot appears. After running program (Local Windows Dedugger arrow button), program stops at this breakpoint and you can hover over variables or view them in various debug windows. You can also continue to execute program step by step, following how variables change, which functions get called, etc.

You can also make the breakpoint later while program is already running, e.g. at some point when there should be some rotation already.

Thanks again Joe,

i will place the red dot behind the matrix code, then go over the matrix variables with my mouse, thanks.

I think i disabled all debug info in the debug options, maybe i have to set that back.

S T O P C R I M E !

Visual Pro 2005 C++ DX9 Cubase VST 3.70 Working on : LevelContainer class & LevelEditor

55 minutes ago, the incredible smoker said:

Ignorance ?, i asked you if you have made such a function you still did not answer that question.

I simply dont have time to figure out how to display floating point values, it wont work with me, always problems with that floats, is that arrogance ?

Once you play my game you will forgive me.

I first made such a thing sometime in the late 90s. I assure, it's quite a trivial task.

You should make time to learn your trade, or you'll be doomed to wallow in your ignorance for a long time.

I won't play your game.

13 minutes ago, JTippetts said:

I won't play your game. 

Why not ?

S T O P C R I M E !

Visual Pro 2005 C++ DX9 Cubase VST 3.70 Working on : LevelContainer class & LevelEditor

3 hours ago, the incredible smoker said:

Ignorance ?, i asked you if you have made such a function you still did not answer that question.

I simply dont have time to figure out how to display floating point values, it wont work with me, always problems with that floats, is that arrogance ?

You got ignorance and arrogance reversed here.  Your arrogance was when several people tried to help you, and provided you evidence to back up their statements, you argued with them (about the range of atan2 which you can look up in seconds!).

The ignorance is not taking the time to figure out why you're having a problem.  Such as learning to effectively debug your code for example.  Using a debugger is a massive part of programming, disabling it or not using it is akin to shooting yourself in the foot.  When you run into a problem/bug, instead of plowing through it like it's slowing you down, try taking the time to solve it fully.  Otherwise, those bugs you leave behind will come back to bite you in the butt and the tangled mess will be horrific.

 

Edit:
Also, 2018 is about as long as 2017 was and 2019 will be.  Since you seemed confused on the length of 2018 earlier :)

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

I tryd the debugger, it works.

I had multiplyd the normal vector by 40 ( oops ).

I looked to the values and needed to set the _33 to 1.

After it all was fixed i have a new rendering problem : looks like it is behind the other meshes.

under.jpg.214e2f82c2391bfb036ff62739a68454.jpg

Here are the screenshots with the differences as it is now : rot2 is with the atan2f

begin.jpg.8bf5bac97cbc21ec6fb9606e26b4f33d.jpg

after more then hitting 20 times the F5 button it looks more matching :

after.jpg.e101c85372056d2d70a893ed5b9adb89.jpg

 

You was right JTippets, with the debugger i found out, it was not a priority of me.

With the debugger i tryd going to that line, wich did not occur, so i removed the if.

I was still thinking what i head when developing that function maybe.

i programmed to much, i need to take a break and start on the soundtrack.

Here is a small screenshot for you : you are right JTippets and all, you are all right.

screen.jpg.21a29ae20fb106b0267a54acdc6bf08d.jpg

 

I also had a crash and started to sweat,

all the sudden i noticed a "debug" button, ( fullscreen this wont work ).

After crashing in windowed mode i could use the debugger it took me right to where i was using a deleted class variables, very handy.

 

All the floats are displayed correct, and you can fill in a number also,

if i try this my values will change, reading the value from a edit and then writing to it again will change the value,

how do i fix such a thing ?, i need this for my edittor, now i have all integer level edittor and wanto make V2 next year.

S T O P C R I M E !

Visual Pro 2005 C++ DX9 Cubase VST 3.70 Working on : LevelContainer class & LevelEditor

50 minutes ago, the incredible smoker said:

after more then hitting 20 times the F5 button it looks more matching :

The first screenshot almost matches too, the difference is just floating point precision issues.

-4.37... is probably a tiny number close to zero, the number behind the e tells you how to shift the decimal point, and the sign the direction, e.g.:

1.0e-6f -> 0.000001

 

But notice the different signs on _11 and _12 (!)

This means you need to change code from:


	D3DXMatrixIdentity( &rotmat ); // after that z axis is (0,0,1) and _44 is 1.
	rotmat._11 = normalY;
	rotmat._12 = -normalX;
	rotmat._21 = -normalX;
	rotmat._22 = -normalY;
	

... to this:


	D3DXMatrixIdentity( &rotmat ); // after that z axis is (0,0,1) and _44 is 1.
	rotmat._11 = -normalY;
	rotmat._12 = normalX;
	rotmat._21 = -normalX;
	rotmat._22 = -normalY;
	

then it should work.

 

It is common when working with angles (or equivalent directions), you have to trial and error out swapping x/y and signs (4 options) until it works as expected.

Thank you JoeJ, it works perfect now.

If there is anything i can do for you...

S T O P C R I M E !

Visual Pro 2005 C++ DX9 Cubase VST 3.70 Working on : LevelContainer class & LevelEditor

5 hours ago, the incredible smoker said:

Thank you JoeJ, it works perfect now.

If there is anything i can do for you...

You're welcome :)

This topic is closed to new replies.

Advertisement