Jump to content

[1.11]Significance of 2.500000277905201E-7D when performing rotation[Solved]


Recommended Posts

Posted

I am working on a rotation function that updates player's pitch and yaw based on the location of a block or entity near the player. I understand how to compute the angular change, theta, required from the players current look vector to the desired look vector using 2d or 3d vectors yada yada yada...

 

All that being said when I am reviewing rotation functions that others have coded I see something like:

                final double d0 = x - mc.thePlayer.posX;
	final double d1 = z - mc.thePlayer.posZ;
	final double d2 = y - mc.thePlayer.posY - mc.thePlayer.getEyeHeight();
	final double d3 = d0 * d0 + d2 * d2 + d1 * d1;

	if (d3 < 2.500000277905201E-7D) {
		return 0;
	}
                //DoStuff

 

So my question is what is the significance of the number 2.500000277905201E-7? I haven't been able to find useful posts about it.

 

 

Posted

First of all, that number is really just 2.5-10 (or 0.00000025). The small part at the end is a rounding error, watch

for some background.

 

What this code does is just clamp some value that probably gets progressively smaller to 0 at some very small value. This is to remove weird things caused by smaller and smaller values that are still not 0.

 

I understood the number itself and how floating point conversions are lossy (btw 2.5x10-7 == 0.00000025 != 2.5-10). I was only curious why it was being used there. It makes sense to clamp off the number at some small value though.

 

Thanks! I appreciate your explanation!

Posted

First of all, that number is really just 2.5-10 (or 0.00000025)

 

These are not the same thing.

2.5-10 is 0.0001048576

I think you meant 2.5 * 10-10

 

Also, you probably meant -7, not -10.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

First of all, that number is really just 2.5-10 (or 0.00000025)

 

These are not the same thing.

2.5-10 is 0.0001048576

I think you meant 2.5 * 10-10

 

Also, you probably meant -7, not -10.

yup. I caught that too. easy mistake to make sometimes.

Posted

I was tired, ok? :D

 

I'm mostly teasing. I made that post right after having a conversation involving Knuth's Up-Arrow Notation and an idle/clicker game.

(And the number 5.6↑↑3)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Oh god, not

...

 

5.6↑↑3 is only about 1 * 1024

(It's less now that I plug it into a calculator, but I was working backwards and just wanted something close; 5.65 is better)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I know it's not that big. I just remember those weird arrows from that video :D

 

Yup!  Two arrows and a small number on the end is rather reasonable. It's when you get 4+ that things go stupid.

 

(Windows calculator gives up at 5.65↑↑7)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I know it's not that big. I just remember those weird arrows from that video :D

 

Yup!  Two arrows and a small number on the end is rather reasonable. It's when you get 4+ that things go stupid.

 

(Windows calculator gives up at 5.65↑↑7)

What do these arrows even mean and how to write them on a PC?

Developer of Primeval Forest.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.